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

Re: problem with occurence of elements

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Sun, 09 Mar 2008 18:52:14 -0400
Message-Id: <7.0.1.0.2.20080309184450.028636a0@CraneSoftwrights.com>
To: XML Schema List <xmlschema-dev@w3.org>
Re: problem with occurence of elements

At 2008-03-09 23:35 +0100, Andreas Peter wrote:
>This is my complexType:
>
>    <xs:complexType name="chapterType">
>        <xs:sequence>
>            <xs:element name="title"/>
>                <xs:choice>
>                    <xs:element name="subtitle"/>
>                    <xs:element name="author"/>
>                    <xs:element name="para"/>
>                    <xs:element name="sect1"/>
>                </xs:choice>
>        </xs:sequence>
>    </xs:complexType>
>
>I try to realise, that after the required title-element the author-, 
>para- and sect1-element can occure unboundedly and the 
>subtitle-element can occure only once. There should also be the 
>restriction that if an sect1-element occures the para-, author- or 
>subtitle-element should not occure.

You have a contradiction there:  you are requiring two different 
behaviours in the presence of sect1 ... the first case it allows the 
others, and the second case it does not.

To proceed, I'll assume that you did not mean for sect1 to be allowed 
in the first case:

   <xs:complexType name="chapterType">
     <xs:sequence>
       <xs:element name="title"/>
       <xs:choice>
         <!--the author- and para-element can occur unboundedly
             and the subtitle-element can occur only once-->
         <xs:sequence>
           <xs:element name="subtitle"/>
           <xs:choice maxOccurs="unbounded">
             <xs:element name="author"/>
             <xs:element name="para"/>
           </xs:choice>
         </xs:sequence>
         <!--if an sect1-element occurs the para-, author- or
             subtitle-element should not occur-->
         <xs:element name="sect1"/>
       </xs:choice>
     </xs:sequence>
   </xs:complexType>

I hope this helps.

. . . . . . . . . . Ken


--
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
Received on Sunday, 9 March 2008 22:52:34 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.