[xsd-users] Mapping of complex type with simple type string
extension
Boris Kolpackov
boris at codesynthesis.com
Wed Jul 11 05:39:48 EDT 2012
Hi Daniel,
Please don't send multiple copies of the same question to the mailing
list. One is sufficient.
Daniel Berglund <daniel.berglund at scilifelab.se> writes:
> <complexType name="object">
> <simpleContent>
> <extension base="date">
> <attribute name="lang" type="language" use="required"/>
> </extension>
> </simpleContent>
> </complexType>
>
> If I understand correctly if we have the object of the complex type in the
> example you can acess date by object.base()?
No, object will simply derive from xml_schema::date class and you can
work with object as if it was date. Alternatively, if you want an
explicit reference to date, then you can do:
object o = ...;
xml_schema::date& d = o; // Implicit derived-to-base conversion.
> I'm having something similar but with a string instead of date.
Similarly, in this case your complex type will derive from xml_schema::string
which in turn derives from std::string. So you can do:
object o = ...;
const char* cs = o.c_str (); // Call std::string::c_str() directly.
o.assign ("foo"); // Call std::string::assign() directly.
std::string& s = o; // Implicit derived-to-base conversion.
Boris
More information about the xsd-users
mailing list