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

RE: new to schema: Unique Particle Attribution

From: Michael Kay <mike@saxonica.com>
Date: Wed, 6 Apr 2005 10:06:14 +0100
To: "'Kostas Karadamoglou'" <karadamoglou_k@yahoo.gr>, <xmlschema-dev@w3.org>
Message-ID: <8040.28492.1120563523@automsgid.listhub.w3.org>
schema choice unique particle attribution

 
> 
> I am new to xml schema and to this mailing list (if misuse it please 
> inform me).
> 
> I would like to write an element (question) which does the following:
> 
> question can have either:
> 
> title(optional), content and weight
> 
> or:
> 
> title, content(optional), weight(optional) and question

Since no repetition is involved you can tackle this by writing out all the
permitted sequences:

CW
TCW
TQ
TCQ
TWQ
TCWQ

and then factor them by combining those that start with the same
subsequence:

(CW)|(T(C(WQ?|Q)|WQ|Q))

that is,

choice (
  sequence(C, W),
  sequence (T,
    choice(
      sequence(C,
        choice (sequence (W, Q?), Q),
      sequence(W, Q),
      Q)
  )
)

Michael Kay
http://www.saxonica.com/


> 
> I tried to implement the above rules in an xml schema but I got a 
> "Unique Particle Attribution". Below I provide you with the 
> xml fragment 
> that implement the rules. Can you tell me how I can implement 
> these rules?
> 
>     <xs:group name="simpleQuestionItems">
>         <xs:sequence>
>             <xs:element ref="title" minOccurs="0" maxOccurs="1"/>
>             <xs:element ref="content"/>
>             <xs:element ref="weight"/>
>         </xs:sequence>
>     </xs:group>
> 
>     <xs:group name="complexQuestionItems">
>         <xs:sequence>
>             <xs:element ref="title"/>
>             <xs:element ref="content" minOccurs="0" maxOccurs="1"/>
>             <xs:element ref="weight" minOccurs="0" maxOccurs="1"/>
>             <xs:element ref="question" minOccurs="1" 
> maxOccurs="unbounded"/>
>         </xs:sequence>
>     </xs:group>
> 
>     <xs:element name="question">
>         <xs:complexType>
>             <xs:choice>
>                 <xs:group ref="simpleQuestionItems"/>
>                 <xs:group ref="complexQuestionItems"/>
>             </xs:choice>
>             <xs:attribute name="required" type="xs:boolean" 
> default="false"/>
>         </xs:complexType>
>     </xs:element>
> 
> 
> 
> 
Received on Wednesday, 6 April 2005 09:06:23 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.