W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2001

Re: Schema "can I" question...

From: Jeff Rafter <jeffrafter@definedweb.com>
Date: Wed, 10 Jan 2001 10:07:21 -0800
Message-ID: <02d201c07b30$2dd9d0b0$f181fea9@lazarus>
To: <MarkH@i2.co.uk>
Cc: <xmlschema-dev@w3.org>
> 1) Can I allow arbitrary (i.e. unanticipated) elements in a <sequence>?

Yes, see the primer wrt the <any> element [1].

> 2) Alongside other specified elements?

Yes, again the primer gives you a couple of options. You could try simply
defining the content and add an <any> element.

<complexType name="vehicleItemType">
    <extension base="mark:ItemType">
        <element name="make" type="string" minOccurs="0" maxOccurs="1"/>
        <element name="color" type="string" minOccurs="0" maxOccurs="1"/>
        <any namespace="##any" minOccurs="0" maxOccurs="unbounded"

I believe that you can do what you are trying to do as shown above.  Another
option would be to not include the make and color elements and set the
processContents value to lax and hope that the validator was somehow able to
discern which elements it could obtain information (based on the namespace)
and validate only those-- however I think that this would be stretching the
meaning intended for lax.

Also note that I used the extension mechanism from some mythical
"mark:ItemType" which I would expect would have the <comment> element.  That
of course isn't necessary but may be useful so I added it.

Good luck,
Jeff Rafter
Defined Systems

> For example (see below), can I write a schema that explicitly describes
> <personItem> and <vehicleItem> (and would validate that instances of these
> items complied with the schema's type definition for them), while also
> allowing <witnessItem> which does not appear in the schema?
> Note: <items> is a collection of zero or more items from a range of
> types which represent entities (people, vehicles, buildings etc.) which
> different properties (firstName, lastName etc.).
> I want to define a basic schema structure, but allow people to include
> own types without having to modify the schema. Validation would trap
> of the anticipated types but simple not check anything in an items section
> that wasn't explicitly defined.
> <myDocument>
>  <items>
>    <personItem id='e0001'>
>     <comment>A software consultant</comment>
>     <firstName>Mark</firstName>
>     <lastName>Hughes</lastName>
>    </item>
>    <personItem id='e0002'>
>     <comment>W3C Fellow</comment>
>     <firstName>Henry</firstName>
>     <lastName>Thompson</lastName>
>    </item>
>    <vehicleItem id='e0003'>
>     <comment>Involved in accident</comment>
>     <make>Ford</make>
>     <color>Red</color>
>    </vehicleItem>
>    <witnessItem id='e0004'>
>     <comment>Witnessed in accident</comment>
>     <make>Ford</make>
>     <color>Red</color>
>    </vehicleItem>
>  </items>
> </myDocument>
> Thanks
> Mark
> --
> Mark Hughes
>   Agile HTML Editor
>     http://www.agilic.com
Received on Wednesday, 10 January 2001 13:07:44 GMT

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