[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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>
xs sequence

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

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.