Re: open schema

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 UTC