Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: xs:choice and xs:sequence question

From: George Cristian Bina <george@---------.--->
To: d_a_carver@-----.---
Date: 1/12/2006 6:57:00 PM
Hi David,

oXygen reports the error with a link to the specification related with that:
http://www.w3.org/TR/xmlschema-1/#cos-nonambig

The idea is that when a parser sees the Description element it should be 
able to identify whether that Description is the Description from the 
first sequence inside the choice or the Description from the second 
sequence inside the choice without looking forward in your document to 
see what follows after Description. That is not possible if both 
sequences start with Description.

The general solution for these cases is to rewrite the content model in 
a non ambiguous way, sometimes this is simple but sometimes this may be 
difficult if not impossible.

In your case you have (d*, m?) | (d+, m, a). I think it is not possible 
to rewrite that in a non ambiguous way.
If the model (a, d+, m) | (d*, m?) works for you then use that as it is 
not ambiguous.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
www.---.com


David Carver wrote:
> 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, XMLSpy">XMLSpy, 
> MSXML and Oxygen.
> 
> 

From mike@s... Thu Jan 12 17:04:51 2006
Received: from lisa.w3.org ([128.30.52.41])
	by frink.w3.org with esmtp (Exim 4.50)


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent