- From: George Cristian Bina <george@oxygenxml.com>
- Date: Mon, 20 Feb 2006 11:11:34 +0200
- To: Ramkumar Menon <ramkumar.menon@gmail.com>
- Cc: xmlschema-dev@w3.org
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
http://www.oxygenxml.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
Received on Monday, 20 February 2006 09:09:40 UTC