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 UTC