|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to do a choice on aggregation with w3C XML schema
On Thu, 2003-12-18 at 09:14, John Cowan wrote: > santony@b... scripsit: > > > We need to essentially build a schema that will restrict the xml to > > be in one of these 3 forms. Is it possible to do this at all. > > Not in W3C XML Schema. So if you need this kind of validation, get > with the program and use RELAX NG, which is perfect for this kind of thing. > Here's a (partial) RELAX NG schema, in compact notation, that will > validate your documents: Thanks a zillion John: I also found out - to my surprise - unlike what I thought xml schema is not the 'most powerful' and definitely not the 'solve anything' kind of validator. I m surprised why it does not have xslt like <xsl:if> constructs. >From the standards this is what I violated http://www.w3.org/TR/xmlschema-1/#non-ambig Thanks again --sony > > start = command1 | command2 | command3 > > command1 = element COMMAND "REQUEST1", > element COMMAND_DATA { > element REQ1_DAT1 {text}, > element REQ1_DAT2 {text}, > ... > } > > command2 = element COMMAND "REQUEST2", > element COMMAND_DATA { > element REQ2_DAT1 {text}, > element REQ2_DAT2 {text}, > ... > } > > command3 = element COMMAND "REQUEST3", > element COMMAND_DATA { > element REQ3_DAT1 {text}, > element REQ3_DAT2 {text}, > ... > } > > Now this assumes that you really do know how many REQi_DATj elements > exist for each type; no extant schema language can help you much if you > are allowed an arbitrary number of them. The "..." is not part of RELAX > NG syntax any more than it is of XML Schema. > > > But though my xml editor ( xmlspy ) reported this to be a valid schema, > > XML Spy is notoriously unreliable at checking what is and what is not a > valid XML Schema. Indeed, no schema should be called valid unless it's > been checked with several different validators. > > > When I used xerces to validate I got an error like > > > > "http://www.bellsouth.com/wfaif":COMMAND and > > "http://www.bellsouth.com/wfaif":COMMAND (or elements from their > > substitution group) violate "Unique Particle Attribution". During > > validation against this schema, ambiguity would be created for those > > two particles" > > To XML Schema, your choice looks like "COMMAND | COMMAND | COMMAND", and > it can't cope. Differentiating on the content of the element is too subtle. > RELAX NG, on the other hand, eats this stuff up. > > You can find RELAX NG validators and other tools for various environments > at http://www.relaxng.org . > > Moral: Don't define document types like this. Let ordering do its > natural work next time, instead of doubling up with ordering *and* > magic element names. -- Sony Antony <santony@b...>
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||






