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

Re: [Moderator Action] How can I use the schema to declare an "open" model?

From: Morris Matsa <mmatsa@us.ibm.com>
Date: Wed, 10 Jan 2001 13:09:33 -0500
To: ht@cogsci.ed.ac.uk (Henry S. Thompson)
Cc: Badt <estee@isdn.net.il>, xmlschema-dev@w3.org
Message-ID: <OFA08FAE0D.819D4E59-ON852569D0.00639240@somers.hqregion.ibm.com>


Henry, do you mean <any> instead of <all>?


ht@cogsci.ed.ac.uk (Henry S. Thompson)@w3.org on 01/10/2001 03:53:12 AM

Sent by:  xmlschema-dev-request@w3.org


To:   Badt <estee@isdn.net.il>
cc:   xmlschema-dev@w3.org
Subject:  Re: [Moderator Action] How can I use the schema to declare an
      "open" model?



Badt <estee@isdn.net.il> writes:

> Meening a model of an element, which has a few sons that must appear and
any
> other sons, eg:
> <car>
>    <type>....</type>
>    <price>...</price>
>    <detail1>...</detail1>
>    <detail2>...</detail2>
>    <detail3>...</detail3>
>    <detail4>...</detail4>
> </car>
>
> I would like a schema that would validate that the car contains a price
and
> a type but permites anything else
> is there any way?
>
> I've of something like:
>
>    <xsd:all>
>         <xsd:element name='type'/>
>         <xsd:element name='price'/>
>         <xsd:any/>
>    </xsd:all>
>
> or a similar model
> it doesnt work of course and i willl be glad if any one with a better
idea
> would help

That model will work if you change it to a sequence, so you have two
alternatives as things stand:

 <xs:sequence>
  <xs:element name='type'/>
  <xs:element name='price'/>
  <xs:all minOccurs='0' maxOccurs='unbounded'/>
 <xs:sequence/>

 <xs:choice minOccurs='0' maxOccurs='unbounded'/>
  <xs:element name='type'/>
  <xs:element name='price'/>
  <xs:all namespace='##other'/>
 </xs:choice>

The first allows your elements all to share a namespace, but requires
fixed order.

The second allows any ordering, doesn't require the <type> and <price>
elements, and requires the extra elements to be in a separate
namespace.

ht
--
  Henry S. Thompson, HCRC Language Technology Group, University of
Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
         Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
               URL: http://www.ltg.ed.ac.uk/~ht/
Received on Wednesday, 10 January 2001 13:11:29 GMT

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