Re: Schema "can I" question...

> 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">
  <complexContent>
    <extension base="mark:ItemType">
      <sequence>
        <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"
processContents="skip"/>
      </sequence>
    </extension>
  </complexContent>
</complexType>

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
possible
> types which represent entities (people, vehicles, buildings etc.) which
have
> different properties (firstName, lastName etc.).
>
> I want to define a basic schema structure, but allow people to include
their
> own types without having to modify the schema. Validation would trap
misuse
> 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 UTC