[xsd-users] How to get xsi:type informations
Boris Kolpackov
boris at codesynthesis.com
Fri Jun 20 09:19:32 EDT 2008
Hi Christian,
Christian Heine <Hellhound_01 at web.de> writes:
> I've trouble to get the xsi:type informations from an xsd object. In
> my schema I've an abstract element which has to bee declared explicit
> by using the xsi:type attribute to make sure that only objects of the
> abstract type are returned.
>
> i.e.:
> <unit name="camera" xsi:type="br:UnitBypass"/>
> <unit name="blur" xsi:type="br:UnitInOut">
>
> So far so good and it works fine. But now i've to reinterprete the
> type for concrete object initialization. How i get the xsi:tpye
> information from the XSD unit object?
You normally don't need to do anything with the xsi:type attribute
when using the C++/Tree mapping (I assume you are using C++/Tree).
Everything is handled by the generated code and actual dynamic types
are instantiated. You can then discover the the actual object type
using, for example, dynamic_cast. For more information see Section 2.11,
"Mapping for xsi:type and Substitution Groups" in the C++/Tree Mapping
User Manual:
http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11
You may also find the 'polymorphism' example in examples/cxx/tree/
useful.
(If you still need to get the raw xsi:type attribute value for some
reason then let me know and I will provide with some pointers.)
Boris
More information about the xsd-users
mailing list