[xsd-users] Some difficulties with GML/CityGML Tree Parser generation : a bug?

Boris Kolpackov boris at codesynthesis.com
Thu Oct 22 09:15:40 EDT 2009


Hi Erwann,

Erwann HOUZAY <erwann.houzay at ign.fr> writes:

> I've tried your solution (well I have very few knowledge about  
> codesynthesis, so I don't understand all...)
>
> Well, is works now but sub-element under cityObjectMember are not  
> detected...
>
> I've tried the sample on cityGML website (http://www.citygml.org/1539/)  
> and it doesn't work.
>
> cityObjectMember  if exported correctly in the output file...

You mean that your application doesn't "see" them but they are in the
output file, right? If that's the case then it is most likely because
of the polymorphism. You need to figure out the actual element type
and cast the pointer to it, for example:

for(gml::AbstractFeatureCollectionType::featureMember_iterator 
      itFeature=model->featureMember().begin();
    itFeature!=model->featureMember().end();
    itFeature++)
{
   // Note the use of references!
   //
   gml::FeaturePropertyType& feature = (*itFeature); 
   gml::AbstractFeatureType& af = feature._Feature().get();

   if (CityObjectGroupType* cog = dynamic_cast<CityObjectGroupType*> (&af))
   {
      // Handle cog. 
   }
   else if (BuildingType* b = dynamic_cast<BuildingType*> (&af))
   {
      // Handle building.
   }

   ...
}

See Section 2.11, "Mapping for xsi:type and Substitution Groups" in the 
C++/Tree Mapping User Manual for more information:

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

Boris



More information about the xsd-users mailing list