Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Ignore Order while validating XSD

From: George Cristian Bina <george@---------.--->
To: Ramkumar Menon <ramkumar.menon@-----.--->
Date: 2/20/2006 1:12:00 PM
Hi Ram,

You can relax the content model to a choice with maxOccurs-"unbounded" 
of your possible elements and then embed a couple of Schematron rules to 
check that the number of occurrences for each element. For instance if 
you want an element test to contain a,b,c and one or more x elements in 
any order then the schema looks like below:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:sch="http://www.ascc.net/xml/schematron">
   <xs:element name="test">
     <xs:annotation>
       <xs:appinfo>
         <sch:pattern name="Check the number of occurences.">
           <sch:rule context="test">
             <sch:assert test="count(a)=1">Element a should appear 
once.</sch:assert>
             <sch:assert test="count(b)=1">Element b should appear 
once.</sch:assert>
             <sch:assert test="count(c)=1">Element c should appear 
once.</sch:assert>
             <sch:assert test="count(x)>=1">Element a should appear al 
least once.</sch:assert>
           </sch:rule>
         </sch:pattern>
       </xs:appinfo>
     </xs:annotation>
     <xs:complexType>
       <xs:choice maxOccurs="unbounded">
         <xs:element name="a"/>
         <xs:element name="b"/>
         <xs:element name="c"/>
         <xs:element name="x"/>
       </xs:choice>
     </xs:complexType>
   </xs:element>
</xs:schema>

This scales well with the number of elements.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
www.---.com


Ramkumar Menon wrote:
> Hi,
>  
> is it possible to ignore the document order while using schema validator 
> to validate an XSD ?
> If not, is there an alternative to the following issue ?
> I have an element that has a set of elements witihn it, one of them 
> being maxOccurs="unbounded". Since I wanted to use the "xsd:all" group 
> so that I can assume unordered child nodes, the node with 
> maxOccurs="unbounded" prevents me from making such a definition.
>  
> Any help will be appreciated.
> pls reply direcly to my email id, since I am not on this mailing list.
>  
> rgds,
> Ram
> 
> -- 
> Shift to the left, shift to the right!
> Pop up, push down, byte, byte, byte!
> 
> -Ramkumar Menon
> A typical Macroprocessor

From u.ende@m... Mon Feb 20 11:29:43 2006
Received: from aji.w3.org ([133.27.228.225])
	by frink.w3.o


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent