W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2008

Re: problem with occurence of elements

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

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

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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:14 UTC