[xsd-users] Bug with groups and occurence

Bram De Wachter bdewacht at gmail.com
Wed Mar 21 06:41:57 EDT 2007


I have the following XSD, which describes general expressions
(binary/unary operators and constant operands)

<xs:element name="Expression" type="ExpressionType"/>

Where an Expression is:

<xs:complexType name="ExpressionType">
  <xs:group ref="ExpressionGroup">
...
</xs:complexType>

Expressions are either binary or unary operators or constants:

<xs:group name="ExpressionGroup">
  <xs:choice>
    <xs:group ref="BinaryOperatorsGroup"/>
    <xs:group ref="UnaryOperatorsGroup"/>
    <xs:element name="Constant" type="xs:int"/>
...
  </xs:choice>
</xs:group>


BinaryOperators can be Div, Add ...

<xs:group name="BinaryOperatorsGroup">
  <xs:choice>
    <xs:element name="Div" type="BinaryOperatorType"/>
    <xs:element name="Add" type="BinaryOperatorType"/>
  </xs:choice>
</xs:group>

While a Binary operator takes exactly two Expressions

<xs:complexType name="BinaryOperatorType">
  <xs:group ref="ExpressionGroup" minOccurs="2" maxOccurs="2"/>
</xs:complexType>

Et voilà, XSD tree 2.3.1 generates the BinaryOperatorType class with
only (!!!) containers (!!!) for all possible operators (unary/binary).
So it is impossible to find out the sequence in which the operands
appear.

Example:

<Expression>
  <Div>
    <Constant>5</Constant>
    <Sum>
      <Constant>2</Constant>
      <Constant>1</Constant>
    </Sum>
  </Div>
</Expression>

1/ There is no way to find out if the sum comes before the Constant 5
or the other way around.

2/ Also, it is not clear to me how both Constants (1 and 2) are
inserted in a single container.

Regards,
Bram De Wachter.




More information about the xsd-users mailing list