[xsd-users] reading simple_type
Boris Kolpackov
boris at codesynthesis.com
Tue Sep 7 12:05:35 EDT 2010
Hi Nick,
Nick Hunter <nickhunteur at gmail.com> writes:
> The " <xsd:attribute name="StartUp" use="required" /> " schema definition
> has not been declared with a 'type' and so the StartUp member of the Feature
> class is an ::xml_schema::simple_type in the tree.
>
> The problem I have run into is how to read the value "RenderingRootFeature"
> from the StartUp and Alias attributes. Is there a way to read a std::string
> from the ::xml_schema::simple_type?
No, not directly. In XML Schema, anySimpleType (which is mapped to
xml_schema::simple_type) is a base type for all simple types so we
cannot always store a "raw" representation there since the overhead
would be too high (as a side note, in the next major release of
XSD we are planning to re-design this implementation and map
anySimpleType to two types: simple_type which will still be a, now
abstract, base for all simple types and any_simple_type which will
be used for attributes/elements that use anySimpleType; the
any_simple_type type will have a string member containing the
raw data).
For now, there are two way to work around this. The simplest would
be to modify your schema and add type="xsd:string" to all the attributes
that miss the type declaration.
The other approach is a bit more complicated and involves customizing
xml_schema::simple_type. The advantage of this method is the ability
to use the schema without any modifications. The following post
describes how to do this (it talks about xml_schema::type but this
also applies to xml_schema::simple_type):
http://www.codesynthesis.com/pipermail/xsd-users/2009-October/002492.html
Boris
More information about the xsd-users
mailing list