castor
  1. castor
  2. CASTOR-1676

Invalid schema generated with <xsd:all> containing element with maxOccurs unbounded value.

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: 1.0.4
    • Fix Version/s: None
    • Component/s: XML
    • Labels:
      None
    • Environment:
      Windows Xp
    • Number of attachments :
      0

      Description

      I am generating schema from xml instance using the XMLInstance2Schema API.
      Schema st_schema =
      new XMLInstance2Schema().createSchema(l_reader_xmlInstance);

      The input XML instance is

      <CONTACT>
      <NAME index="1">a</NAME>
      <FAX index="1">a</FAX>
      <NAME index="1">a</NAME>
      <TELEPHONE index="1">a</TELEPHONE>
      </CONTACT>

      Generated schema is:

      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="CONTACT">
      <xsd:complexType>
      <xsd:all>
      <xsd:element name="NAME" maxOccurs="unbounded">
      <xsd:complexType mixed="true">
      <xsd:sequence/>
      <xsd:attribute name="index" type="xsd:integer"/>
      </xsd:complexType>
      </xsd:element>
      <xsd:element name="FAX">
      <xsd:complexType mixed="true">
      <xsd:sequence/>
      <xsd:attribute name="index" type="xsd:integer"/>
      </xsd:complexType>
      </xsd:element>
      <xsd:element name="TELEPHONE">
      <xsd:complexType mixed="true">
      <xsd:sequence/>
      <xsd:attribute name="index" type="xsd:integer"/>
      </xsd:complexType>
      </xsd:element>
      </xsd:all>
      </xsd:complexType>
      </xsd:element>
      </xsd:schema>

      The generated schema contains <xsd:all> with <xsd:element name="NAME" maxOccurs="unbounded">.
      where as maxOccurs in <xsd:all> element does not allow unbounded as the value. maxOccurs in xsd:all element allows either 0 or 1 only.
      So schema validation is failing in my application.

      Please do favour ASAP and thanks in advance.

        Issue Links

          Activity

          Hide
          Werner Guttmann added a comment -

          What would you expect your XML schema to look like ?

          Show
          Werner Guttmann added a comment - What would you expect your XML schema to look like ?
          Hide
          Adisesha Rao added a comment -

          Thank you very much for reacting quickly on the bug.
          The generated schema should be compliant of w3c specification.
          Please find the schema provided below, which is generated using Trang tool.

          <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
          <xs:element name="CONTACT">
          <xs:complexType>
          <xs:sequence>
          <xs:choice maxOccurs="unbounded">
          <xs:element ref="FAX"/>
          <xs:element ref="NAME"/>
          </xs:choice>
          <xs:element ref="TELEPHONE"/>
          </xs:sequence>
          </xs:complexType>
          </xs:element>
          <xs:element name="FAX">
          <xs:complexType>
          <xs:simpleContent>
          <xs:extension base="xs:NCName">
          <xs:attribute name="index" use="required" type="xs:integer"/>
          </xs:extension>
          </xs:simpleContent>
          </xs:complexType>
          </xs:element>
          <xs:element name="NAME">
          <xs:complexType>
          <xs:simpleContent>
          <xs:extension base="xs:NCName">
          <xs:attribute name="index" use="required" type="xs:integer"/>
          </xs:extension>
          </xs:simpleContent>
          </xs:complexType>
          </xs:element>
          <xs:element name="TELEPHONE">
          <xs:complexType>
          <xs:simpleContent>
          <xs:extension base="xs:NCName">
          <xs:attribute name="index" use="required" type="xs:integer"/>
          </xs:extension>
          </xs:simpleContent>
          </xs:complexType>
          </xs:element>
          </xs:schema>

          The generated schema should not contain <xsd:all> with an element with maxOccurs value unbounded.

          Show
          Adisesha Rao added a comment - Thank you very much for reacting quickly on the bug. The generated schema should be compliant of w3c specification. Please find the schema provided below, which is generated using Trang tool. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="CONTACT"> <xs:complexType> <xs:sequence> <xs:choice maxOccurs="unbounded"> <xs:element ref="FAX"/> <xs:element ref="NAME"/> </xs:choice> <xs:element ref="TELEPHONE"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="FAX"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:NCName"> <xs:attribute name="index" use="required" type="xs:integer"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name="NAME"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:NCName"> <xs:attribute name="index" use="required" type="xs:integer"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:element name="TELEPHONE"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:NCName"> <xs:attribute name="index" use="required" type="xs:integer"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:schema> The generated schema should not contain <xsd:all> with an element with maxOccurs value unbounded.

            People

            • Assignee:
              Unassigned
              Reporter:
              Adisesha Rao
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: