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

Re: open schema

From: Eddie Robertsson <eddie@allette.com.au>
Date: Mon, 27 Aug 2001 11:37:10 +1000
Message-ID: <3B89A446.D7A8B4D8@allette.com.au>
To: estee <estee@isdn.net.il>
CC: xmlschema-dev@w3.org
Hi estee,


> Is there any possibility to define (in an xml schema) a type,
> containing only simple types, of which some are required, and all the
> others unknown.In other words: define a type in which i know what
> elements are supposed to be present, but do not know which "might" be
> present. eg:the following type must contain 'a', 'b', and 'c', but
> might also contain some other elements. It is also important to state
> that the order af appearance is of no siginificance.
> <letters>        <a/>        <hollat/>        <c/>
> <club/>        <b/>        <smit/>        <pliq/>    </letters> I am
> searching for a solution in which all elements are of same namespaces.

What you need is to include the xs:any [1] declaration in your content
model. The xs:any declaration is used when you want to include arbitrary
elements in your content model. It lets you control in which namespace
the elements should be defined (using the namespace attribute) and how
the validation should be performed (using the processContents
attribute).
In your example the declaration of letter would probably be something
like:

<xs:complexType name="letterType">
   <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="a" type="xs:string"/>
      <xs:element name="b" type="xs:string"/>
      <xs:element name="c" type="xs:string"/>
      <xs:any namespace="##targetNamespace" processContents="strict"/>
   </xs:choice>
</xs:complexType>

By setting namespace="##targetNamespace" you specify that all the
elements must come from the targetNamespace of your schema.

 Cheers,
/Eddie

[1] http://www.w3.org/TR/xmlschema-0/#any
Received on Sunday, 26 August 2001 21:36:47 GMT

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