[xsd-users] ifc

Boris Kolpackov boris at codesynthesis.com
Fri Jan 21 09:54:03 EST 2011


Hi Giuseppe,

giuseppe ferrari <giuseppe500 at yahoo.it> writes:

> this is the logic of the xsd :
> A uos tag that contains entities , all entities inherit from ifc:Entity -
> 2 uos class ex:uos and ifc::uos , only the ifc::uos contains entities, 
> but how casting or extract the entities?
> 
> auto_ptr<ex::iso_10303_28> h (common::iso_10303_28_("c:\\esempioifcxml.xml"));

As described in 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

You will need to use dynamic_cast to discover the actual types of polymorphic
elements:

ex::uos& ex_uos (h->uos ());

if (ifc::uos* uos = dynamic_cast<ifc::uos*> (&ex_uos))
{
  for (ifc::uos::Entity_iterator i (uos->Entity ().begin ());
       i != uos->Entity ().end ()
       ++i)
  {
    ex::Entity& e (*i);

    if (ifc::IfcOrganization* org = dynamic_cast<ifc::IfcOrganization*> (&e))
    {
      // This entity is IfcOrganization.
    }
    else if (ifc::IfcApplication* app = dynamic_cast<ifc::IfcApplication*> (&e))
    {
      // This entity is IfcApplication.
    }
    ...
  }
}

> I'm sorry, for these question, but i can't find a book on xsd at store, can 
> you advice me a good book?

Definitive XML Schema by Priscilla Walmsley looks like a good introduction.

Boris



More information about the xsd-users mailing list