[xsd-users] how to convert xml_schema::type to std::string EOM

Boris Kolpackov boris at codesynthesis.com
Thu Oct 4 09:26:21 EDT 2012


Hi Arul,

Prakash, Arul <Arul.Prakash2 at rsa.com> writes:

> What I am trying to do is in my xsd the element is of type "anyType",so
> after code generation it is converted to type "xml_schema::type". In my xml
> the element has a string (Eg:<request>sample</request>).Here <request> is of
> type "anytype",so while constructing the xml using codesynthesis how can I
> map a string to "anyType".

In XML Schema xs:anyType matches any content. That is, any valid XML
fragment, with nested elements, attributes, text, etc. As a result,
XSD cannot map it to just a string. If your element always contains
a string, then it is best to change its type to xs:string.

If it has to be anyType for some reason, then there are other ways to
get its content. However, they will require some extra effort from
your side. For details, refer to the 'mixed' and 'custom/mixed'
examples in the XSD distribution.

Boris



More information about the xsd-users mailing list