[xsd-users] Abstract objects problem
    Romain Garrigues 
    romain.garrigues at c-s.cnes.fr
       
    Thu Mar 15 12:08:09 EDT 2007
    
    
  
Hello all,
I'm a beginner in using this xsd library (parse version)
I have a problem with abstract objects.
This is my xsd file :
<xs:complexType name="AbstractTransformationModelType" abstract="true">
    <xs:sequence>
      <xs:element name="m_name" type="xs:string"/>
    </xs:sequence>
</xs:complexType>
<xs:complexType name="AffineTransformationModelType">
    <xs:complexContent>
 <xs:extension base="AbstractTransformationModelType">
     <xs:sequence>
  <xs:element name="m_a" type="xs:double"/>
     </xs:sequence>
 </xs:extension>
    </xs:complexContent>
</xs:complexType>
<xs:complexType name="ProjectiveTransformationModelType">
    <xs:complexContent>
 <xs:extension base="AbstractTransformationModelType">
     <xs:sequence>
  <xs:element name="m_b" type="xs:double"/>
     </xs:sequence>
 </xs:extension>
    </xs:complexContent>
</xs:complexType>
<xs:complexType name="CoordinatesTransformationModelType">
    <xs:sequence>
       <xs:element name="m_transformation" 
type="AbstractTransformationModelType" />
    </xs:sequence>
</xs:complexType>
I have defined an abstract concept (AbstractTransformationModelType), and 
two classes which are subclasses
of this concept (AffineTransformationModelType and 
ProjectiveTransformationModelType).
Then, CoordinatesTransformationModelType has an element which is that 
abstract concept.
Then, i have defined parsers for each complexType.
I don't understand how to define CoordinatesTransformationModel_parser in 
driver.cxx so i can parse different
xml files.
If i define it with AbstractTransformationModel_parser, i only have m_name 
of m_transformation.
If i define it with AffineTransformationModel_parser, it will be ok if there 
is an affine transformation
in xml file, but won't be ok if there is a projective transformation...
I just want a polymorphic comportment in fact...
The objective is to have the same code to parse different xml files, and i 
don't know how to do when
there are abstract type.
Best Regards.
Romain Garrigues.
    
    
More information about the xsd-users
mailing list