complexContent extending simpleType breaks XmlBeans 2.2, 2.3

View: New views
1 Messages — Rating Filter:   Alert me  

complexContent extending simpleType breaks XmlBeans 2.2, 2.3

by dr.jeff :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here is DecimalType, which is a complexType with simpleContent that extends a simpleType, xs:decimal:

<xs:complexType name="DecimalType">
  <xs:simpleContent>
    <xs:extension base="xs:decimal">
      <xs:attribute ref="xs:decimal">
      </xs:attribute>
    </xs:extension>
  </xs:simpleContent>
</xs:complexType>

Here is AngleMeasureType, which is a complexType with complexContent that extends DecimalType by adding another attribute:

<xs:complexType name="AngleMeasureType">
  <xs:complexContent>
    <xs:extension base="tns:DecimalType">
      <xs:attribute name="angleUOM" type="xs:string">
      </xs:attribute>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

 

This process of changing from simpleContent (in DecimalType) to complexContent (in AngleMeasureType), while only adding attributes to the content, breaks the XmlBeans schema type system.

This has been tested with XmlBeans versions 2.2 and 2.3.

The resolution is to change AngleMeasureType to have simpleContent, as follows:

<xs:complexType name="AngleMeasureType">
  <xs:simpleContent>
    <xs:extension base="tns:DecimalType">
      <xs:attribute name="angleUOM" type="xs:string">
      </xs:attribute>
    </xs:extension>
  </xs:simpleContent>
</xs:complexType>

The error appears when calling xobj.validate(), or with the xsb dumper:

Unknown simple type variety
Exception in thread "main" java.lang.IllegalStateException: Unknown simple type variety
        at org.apache.xmlbeans.impl.tool.XsbDumper.error(XsbDumper.java:149)
        at org.apache.xmlbeans.impl.tool.XsbDumper.dumpTypeFileData(XsbDumper.java:1009)

LightInTheBox - Buy quality products at wholesale price