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

Re: XML Schema: At Least One of X Elements Must Appear


xml schema at least one
From: "CHIUSANO, Joseph" <JCHIUSANO@l...>

> I am 99.9% sure that there is no way to represent in XML Schema that "at
> least one of the following X elements must appear in the XML document" -
> ... In other words, I don't believe that with the above approach (and
> using XML Schema) I can satisfy the requirement that "at least one of the
> possible REF01 qualifier values must be represented in the transaction".  I
> want to be 100% sure before I tell a client this.

In general, W3C XML Schemas 1.0 (WXS) cannot do these kind of constraints.

In your particular case, there may be an approach using keys, though I may
be hallucinating.

You add a default (fixed) declaration to some convenient elemet (e.g. the
root) which annotates the document with an attribute to the effect of
  required-REF01="FS"

Then you declare that attribute is a keyref. Then you declare that the
REF01 attribute is a key, but not unique.  

Now when you validate, the validator will check that there is an element
with REF01="FS" somewhere to match your required-REF01 attribute.

Sorry I have no code for this; I may be wrong.  In passing, even if WXS can
handle this case (which would be nice), it still may be prudent to adopt
Schematron as a standard part of your architecture. That way whenever
you have issues like this, you are not left scratching your head, but you
can rapidly get your constraints implemented.   {As a matter of software
engineering, how can you test your Schema (and implementation) 
works? You run enough cases through and evaluate them: and you need
some tool that is not based on XML Schemas to do the evaluation.  }

Cheers
Rick Jelliffe

Cheers
Rick

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.