[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Problem designing complexType accepting a specified elem

  • To: 'Hess Yvan' <yvan.hess@i...>
  • Subject: RE: Problem designing complexType accepting a specified element and a llowing any others.
  • From: Barwell Jonathan <Jonathan.Barwell@a...>
  • Date: Fri, 12 Mar 2004 09:12:05 -0000
  • Cc: "'xml-dev@l...'" <xml-dev@l...>
  • Return-receipt-to: Barwell Jonathan <Jonathan.Barwell@a...>

xs any other
Title: RE: Problem designing complexType accepting a specified element and a llowing any others.

Yvan,

One solution in XML Schema would be to specify that the <xs:any> elements are in a different namespace using namespace="##other".  This would mean that any additional elements you want to include must be from a different namespace and would avoid confusing the parser.  It would mean that additional XML structures would need a namespace prefix.

Hope this helps if you want to maintain Schemas.

Jon

-----Original Message-----
From: Hess Yvan [mailto:yvan.hess@i...]
Sent: 11 March 2004 21:43
To: 'jcowan@r... '
Cc: 'xml-dev@l... '
Subject: RE: Problem designing complexType accepting a specified element and a llowing any others.


John,

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...

Yvan

-----Original Message-----
From: jcowan@r...
To: Hess Yvan
Cc: xml-dev@l...
Sent: 11.03.04 21:54
Subject: Re: 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
work:
>
> <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"
maxOccurs="unbounded"/>
>     </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 may appear before, after, or mixed in with the other elements. </propaganda>

--
You are a child of the universe no less         John Cowan
than the trees and all other acyclic http://www.reutershealth.com graphs; you have a right to be here. http://www.ccil.org/~cowan

  --DeXiderata by Sean McGrath                  jcowan@r...

-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://www.oasis-open.org/mlmanage/index.php>



************************************************************************
DISCLAIMER
The information contained in this e-mail is confidential and is intended
for the recipient only.
If you have received it in error, please notify us immediately by reply
e-mail and then delete it from your system. Please do not copy it or
use it for any other purposes, or disclose the content of the e-mail
to any other person or store or copy the information in any medium.
The views contained in this e-mail are those of the author and not
necessarily those of Admenta UK Group.
************************************************************************

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.