[xsd-users] Re: Help needed xsd::short to str

Boris Kolpackov boris at codesynthesis.com
Mon Nov 12 01:47:27 EST 2007


Hi Waqqas,

In the future please send technical questions like these to the
xsd-users mailing list (which I've CC'ed) instead of to me directly.
This way a) other developers who may have experienced a similar
problem can provide you with a solution b) questions and answers
will be archived and available to others with similar problems.

Waqqas Sharif <waqqas at intrepid-geophysics.com> writes:

> I have got a quick question for you, which in my schema i have got
> one attribute defined as xsd::short. Is it possible to get this value as
> a string.  As far as i know when you try to access this object you get
> back a short. I can do the conversion myself, but just wondering is
> there any other way of doing this with XSD.

Converting this value from short to string is probably the easiest
way. You can use std::ostringstream, for example.

If you need to get the value exactly as it appears in XML, then you
will need to extract it from DOM yourself. There are two way to do
this.

The first is to use the DOM association feature. This way you can
keep the DOM tree around with each object model node associated
with the corresponding DOM node. For more information on this
see the mixed example in the examples/cxx/tree/ directory.

The second approach is to customize the type that contains this
float attribute and extract the string representation during
parsing. The advantage of this approach over the previous one
is that you don't need to keep the whole DOM tree around. For
more information on how to customize the generated types see
the C++/Tree Mapping Customization Guide:

http://wiki.codesynthesis.com/Tree/Customization_guide

And the 'wildcard' example in the examples/cxx/tree/custom/
directory.

Boris




More information about the xsd-users mailing list