[xsd-users] Help on parsing GML

Boris Kolpackov boris at codesynthesis.com
Wed Jan 23 02:40:07 EST 2008


Hi Olivier,

Olivier Tournaire <olitour at gmail.com> writes:

> No, I would like to know how can I access for example the tag
> <gml:name>AC90-FZK-Haus-2x3-63020_</gml:name> ? I am able to obtain a
> const iterator to a sequence of _GenericApplicationPropertyOfCityModel.
> Then, back to CityGML schema, I found these line :
>
> <xs:element name="_GenericApplicationPropertyOfCityModel"
> type="xs:anyType" abstract="true"/>
>
> So, dereferencing iterator_begin, I obtain a xml_schema::type which is a
> typedef for ::xsd::cxx::tree::type. However, I do not know what to do
> with that stuff ...

CityGML (and GML) use polymorphism. For more information on support
for polymorphism in the C++/Tree mapping see Section 2.11, "Mapping
for xsi:type and Substitution Groups" in the C++/Tree Mapping User
Manual:

http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11

xs:anyType is mapped to xml_schema::type. Once you get a reference to
it, you can try to dynamic_cast it to various types (e.g., types for
gml:name and gml:boundedBy elements) as shown in the sample code for
Section 2.11.


>    <xs:element name="cityObjectMember" type="gml:FeaturePropertyType"
> substitutionGroup="gml:featureMember"/>
>
> I tried this, but it does not compile :
>
> for (;iterator_begin!=iterator_end;iterator_begin++)
>        {
>            if ( dynamic_cast<gml::FeaturePropertyType *>(
> (*iterator_begin).pointer ) == true )
>                ; // ...

This is covered in the above-mentioned section. The last line should
look like this instead:

  if (FeaturePropertyType* fpt =
        dynamic_cast<FeaturePropertyType*> (&(*iterator_begin)));
  {
    // It is a FeaturePropertyType, use fpt.
  }
  else
  {
    // Something else.
  }


Boris




More information about the xsd-users mailing list