W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2002

Re: [xmlschema-dev] <none>

From: Eddie Robertsson <erobertsson@allette.com.au>
Date: Wed, 13 Feb 2002 10:48:35 +1100
Message-ID: <3C69A9D3.B9319D43@allette.com.au>
To: Eamon.Galavan@risk.sungard.com
CC: xmlschema-dev@w3.org
Hi,

Eamon.Galavan@risk.sungard.com wrote:

> 1.  How do I specify an unordered sequence (i.e. the equivalent of <all>
> with maxOccurs ="unbounded") in a schema
>
> e.g. so the following xml would be valid
>
> <chars>
>      <a/>
>      <a/>
>      <c/>
>      <b/>
>      <a/>
>      <b/>
>      <c/>
>      <b/>
> </chars>

Since you don't need internal grouping (all child elements grouped together)
you can achieve this but specifying a choice group with minOccurs="0" and
maxOccurs="unbounded":

<xs:choice minOccurs="0" maxOccurs="unbounded">
   <xs:element name="a" type="..."/>
   <xs:element name="b" type="..."/>
   <xs:element name="c" type="..."/>
</xs:choice>

> 2. How do I specify a schema that only validates a section of an xml file
> e.g. a schema that will validate <a> and <b> below only
>
> <chars>
>      <a/>
>      <I don't care what data is here/>
>      <b/>
>      <don't care about this either/>
> </chars>
>
> I have tried <any>, but any data I seemed to try to add to the xml file
> seem invalid, and if I didn't enter any data, I got an error saying the
> data is incomplete.

<any> is the way to go but make sure that the processContents attribute is
set to skip if you don't want the contents processed.

<xs:any processContents="skip">

BUT, remember that even the values you put as any need to be well-formed XML.
In your example above
<I don't care what data is here/> is not a valid XML element name.

Cheers,
/Eddie
Received on Tuesday, 12 February 2002 18:37:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:26 GMT