W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2006

Re: xs:choice and xs:sequence question

From: David Carver <d_a_carver@yahoo.com>
Date: Thu, 12 Jan 2006 09:16:42 -0500
Message-ID: <43C664CA.6080601@yahoo.com>
To: xmlschema-dev@w3.org
CC: George Cristian Bina <george@oxygenxml.com>

George you are correct, after re-running some tests yesterday none of 
the processors validated it, not sure what happened on the first run 
with Xerces and XSV.   Anyway, I did finally manage to get working what 
I wanted by doing the following:

This works:
    <xs:complexType name="ProcessingOutcomeMessage">
        <xs:choice>
            <xs:sequence>
                <xs:element name="ApplicationReasonCode" 
type="ApplicationReasonCode" />
                <xs:element name="Description" type="Description" 
maxOccurs="unbounded" />
                <xs:element name="MessageReasonCode" 
type="MessageReasonCode" />
            </xs:sequence>
            <xs:sequence>
                <xs:element name="Description" type="Description" 
minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="MessageReasonCode" 
type="MessageReasonCode" minOccurs="0" />
            </xs:sequence>
        </xs:choice>
    </xs:complexType>

The below doesn't work:

  <xs:complexType name="ProcessingOutcomeMessage">
      <xs:choice>
          <xs:sequence>
              <xs:element name="Description" type="Description" 
minOccurs="0" maxOccurs="unbounded" />
              <xs:element name="MessageReasonCode" type="Description" 
minOccurs="0" />
          </xs:sequence>
          <xs:sequence>
              <xs:element name="Description" type="Description" 
minOccurs="1" maxOccurs="unbounded" />
              <xs:element name="MessageReasonCode" 
type="MessageReasonCode" minOccurs="1" />
              <xs:element name="ApplicationReasonCode" 
type="ApplicationReasonCode" minOccurs="1">
                  <xs:annotation>
                      <xs:documentation 
source="http://www.starstandard.org">Contains a software specific 
application reason code.</xs:documentation>
                  </xs:annotation>
              </xs:element>
          </xs:sequence>
      </xs:choice>
  </xs:complexType>



The only way to get this to work was to have ApplicationReasonCode as 
the ApplicationReasonCode as the first element in the first sequence.  
If it was included after MessageReasonCode in the first sequence, every 
parser would complain about not being able to determine how to handle 
the Description element.   I would have thought that it wouldn't have 
mattered what order the elements were setup in the sequence but 
apparently in this case it does.   It would have been helpful if the 
specs were a bit clearer on exactly what has to occur in this type of 
situation.   Anyways, it now validates against Xerces, XSV, XML Spy, 
MSXML and Oxygen.
Received on Thursday, 12 January 2006 15:22:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:52 GMT