OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   RE: [xml-dev] Problem designing complexType accepting a specified elemen

[ Lists Home | Date Index | Thread Index ]


Thanks for your answer. Do you mean that there is NO solution to solve my
problem using XML schema ? Are you sure about that because it will have a
big impact on the project I am working on...


-----Original Message-----
From: jcowan@reutershealth.com
To: Hess Yvan
Cc: xml-dev@lists.xml.org
Sent: 11.03.04 21:54
Subject: Re: [xml-dev] Problem designing complexType accepting a specified
element and a llowing any others.

Hess Yvan scripsit:

> I implemented the following xml schema complexType but it doesn't
> <xs:element name="metadata">
>   <xs:complexType>
>     <xs:choice minOccurs="0" maxOccurs="unbounded">
>       <xs:element name="identifier" type="xs:string"/>
>       <xs:any processContents="lax" minOccurs="0"
>     </xs:choice>
>   </xs:complexType>
> </xs:element>

First of all, you are specifying a choice between an identifier element
and any number of arbitrary elements, but the choice is itself repeated
any number of times.  So <ident/><ident/><ident/> will match.  But even
if you get past that problem, when an "identifier" element is seen,
the schema validator can't tell if it matches the explicit xs:element
declaration or the xs:any declaration.  This is what the UPA rule means:
an element has to match exactly one of the cases in a choice, and if it
matches more than one, the schema is incorrect.

<propaganda>The RELAX NG schema language doesn't have this problem,
and will handle this pattern correctly:

	metadata = element identifier {xsd:string}
		& element * - identifier {attribute * {text}*, ANY*}*
	ANY = element * {attribute * {text}*, ANY*}

Here we clearly specify that "metadata" means an identifier element
interleaved with any number of elements other than identifier elements
(with the latter allowed to contain any attributes and any child
elements).  The effect of interleaving is that the identifier element
appear before, after, or mixed in with the other elements.

You are a child of the universe no less         John Cowan
than the trees and all other acyclic
graphs; you have a right to be here.
  --DeXiderata by Sean McGrath                  jcowan@reutershealth.com


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS