RE: [xml-dev] xs:choice question...

From
Brian J Gentry <>
To
Brian J Gentry <>
Date
2006-01-16T18:52:22Z
ID
<>
Thread
RE: [xml-dev] xs:choice question...

Actually remove the <xs:sequence></xs:sequence> from the second <xs:element name="RequestedDeliveryDateTime" /> it should not be there.. sorry

Cheers,
brian




Brian J Gentry/NA/TNT/TPG

01/16/2006 01:47 PM

To
"Priscilla Walmsley" <[email protected]>
cc
"'Brian J Gentry'" <[email protected]>, [email protected]
Subject
RE: [xml-dev] xs:choice question...Link






That works in a vaccuum, im sorry i didnt fully elaborate the need in the first message.  I have a structure that looks like this:


<
xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.url/to/schema/namespace/OrderManagement/V1" elementFormDefault="qualified" attributeFormDefault="unqualified">
       
<xs:complexType name="OrderHeader">
               
<xs:sequence>
                       
<xs:element name="Comments"  minOccurs="0"/>
                       
<xs:element name="OrderWeight"  minOccurs="0"/>
                       
<xs:element name="OrderPieces"  minOccurs="0"/>
                       
<xs:element name="OrderVolume"  minOccurs="0"/>
                       
<xs:choice>
                               
<xs:sequence>
                                       
<xs:element name="RequestedShipDateTime" />
                                       
<xs:element name="RequestedDeliveryDateTime"  minOccurs="0"/>
                               
</xs:sequence>
                               
<xs:sequence>
                                       
<xs:element name="RequestedDeliveryDateTime" />
                               
</xs:sequence>
                       
</xs:choice>
                       
<xs:element name="RequestedShipDateTime"  minOccurs="0"/>
                       
<xs:element name="RequestedDeliveryDateTime"  minOccurs="0"/>
                       
<xs:element name="OrderDates"  minOccurs="0" maxOccurs="unbounded"/>
                       
<xs:element name="ShipFromParty" />
                       
<xs:element name="ShipToParty" />
                       
<xs:element name="OrderParty"  minOccurs="0" maxOccurs="unbounded"/>
                       
<xs:element name="OrderReference"  minOccurs="0" maxOccurs="unbounded"/>
                       
<xs:element name="OrderMonetary"  minOccurs="0" maxOccurs="unbounded"/>
               
</xs:sequence>
       
</xs:complexType>
</
xs:schema>

I still get the "non-deterministic" message when i apply your pattern.  


Cheers,

brian


"Priscilla Walmsley" <[email protected]>

01/16/2006 12:44 PM


To
"'Brian J Gentry'" <[email protected]>, <[email protected]>
cc
Subject
RE: [xml-dev] xs:choice question...







Why not just:

 

                       
<xs:choice>
                       
 <xs:sequence>
                                     
<xs:element name="A" minOccurs="1"/>
                                     
<xs:element name="B" minOccurs="0"/>
                         
</xs:sequence>
                       
 <xs:element name="B" minOccurs="1"/>
                     
</xs:choice>

Hope that helps,

Priscilla

 

-----------------------------------------------------------------
Priscilla Walmsley                
http://www.datypic.com
Author, Definitive XML Schema     (Prentice Hall PTR)
          Definitive XQuery (coming in 2006)

-----------------------------------------------------------------

 


From: Brian J Gentry [mailto:[email protected]]
Sent:
Monday, January 16, 2006 12:36 PM
To:
[email protected]
Subject:
[xml-dev] xs:choice question...



Hello,

       I have a schema that needs to require 1 of 2 elements, but also allow for both of them. So if the elements are A & B, then A alone is valid, B alone is valid, A & B are valid, but ~A & ~B is invalid.


I tried the following..


                     
<xs:choice>
                       
<xs:sequence>
                                     
<xs:element name="A" minOccurs="1"/>
                                     
<xs:element name="B" minOccurs="0"/>
                       
</xs:sequence>
                       
<xs:sequence>
                                     
<xs:element name="A" minOccurs="0"/>
                                     
<xs:element name="B" minOccurs="1"/>
                       
</xs:sequence>
                     
</xs:choice>

But this is not working as it makes the model non-deterministic.  Is there a way to solve this?


Thanks for your time and kind regards,

Brian Gentry