473,474 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

a set of elements occur in any order with multiple occurrences

Could you please help me with this xsd definition?

I need to define a set of elements occur in any order with multiple
occurrences, but the same kind of elements need to group together...

Sth like this....

<xs:element name="A">
<xs:complexType>
<xs:all>

<xs:element name="B-1" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

<xs:element name="B-2" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

<xs:element name="B-3" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

<xs:element name="B-4" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

</xs:all>

</xs:complexType>
</xs:element>

The above definition cannot be validated correctly...

Thanks in advance!

Mavis

Oct 10 '06 #1
2 1957
Hi,

xs:all has a number of limitations in XML Schema. The closest you can
get with XML schema alone is to specify a 0 to 4 choice of the same
content that you have in xs:all. The full checking can be done either
at application level or using a Schematron rule embedded in the XML
Schema, sull working sample below:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="A">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<pattern xmlns="http://www.ascc.net/xml/schematron"
name="testGrouping">
<rule context="A">
<assert
test="not(B-1[following-sibling::*[not(self::B-1)][following-sibling::B-1]])">
B-1 elements should stay together. </assert>
<assert
test="not(B-2[following-sibling::*[not(self::B-2)][following-sibling::B-2]])">
B-2 elements should stay together. </assert>
<assert
test="not(B-3[following-sibling::*[not(self::B-3)][following-sibling::B-3]])">
B-3 elements should stay together. </assert>
<assert
test="not(B-4[following-sibling::*[not(self::B-4)][following-sibling::B-4]])">
B-4 elements should stay together. </assert>
</rule>
</pattern>
</xs:appinfo>
</xs:annotation>
<xs:choice maxOccurs="4">
<xs:element name="B-1" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="B-2" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="B-3" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="B-4" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Basically each assert test not to have an element followed by an
element different than it and then that followed by an element with the
same name as the initial one.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
mavis wrote:
Could you please help me with this xsd definition?

I need to define a set of elements occur in any order with multiple
occurrences, but the same kind of elements need to group together...

Sth like this....

<xs:element name="A">
<xs:complexType>
<xs:all>

<xs:element name="B-1" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

<xs:element name="B-2" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

<xs:element name="B-3" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

<xs:element name="B-4" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

</xs:all>

</xs:complexType>
</xs:element>

The above definition cannot be validated correctly...

Thanks in advance!

Mavis
Oct 11 '06 #2
Thanks a lot!!!

-M
George Bina wrote:
Hi,

xs:all has a number of limitations in XML Schema. The closest you can
get with XML schema alone is to specify a 0 to 4 choice of the same
content that you have in xs:all. The full checking can be done either
at application level or using a Schematron rule embedded in the XML
Schema, sull working sample below:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="A">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<pattern xmlns="http://www.ascc.net/xml/schematron"
name="testGrouping">
<rule context="A">
<assert
test="not(B-1[following-sibling::*[not(self::B-1)][following-sibling::B-1]])">
B-1 elements should stay together. </assert>
<assert
test="not(B-2[following-sibling::*[not(self::B-2)][following-sibling::B-2]])">
B-2 elements should stay together. </assert>
<assert
test="not(B-3[following-sibling::*[not(self::B-3)][following-sibling::B-3]])">
B-3 elements should stay together. </assert>
<assert
test="not(B-4[following-sibling::*[not(self::B-4)][following-sibling::B-4]])">
B-4 elements should stay together. </assert>
</rule>
</pattern>
</xs:appinfo>
</xs:annotation>
<xs:choice maxOccurs="4">
<xs:element name="B-1" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="B-2" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="B-3" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="B-4" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Basically each assert test not to have an element followed by an
element different than it and then that followed by an element with the
same name as the initial one.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
mavis wrote:
Could you please help me with this xsd definition?

I need to define a set of elements occur in any order with multiple
occurrences, but the same kind of elements need to group together...

Sth like this....

<xs:element name="A">
<xs:complexType>
<xs:all>

<xs:element name="B-1" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

<xs:element name="B-2" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

<xs:element name="B-3" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

<xs:element name="B-4" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>

</xs:all>

</xs:complexType>
</xs:element>

The above definition cannot be validated correctly...

Thanks in advance!

Mavis
Oct 11 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Marcio Rosa da Silva | last post by:
Hi! In dictionaries, unlinke lists, it doesn't matter the order one inserts the contents, elements are stored using its own rules. Ex: >>> d = {3: 4, 1: 2} >>> d {1: 2, 3: 4}
4
by: Christine McGavran | last post by:
To continue a previous thread, sort of... I have defined a schema for describing a windows-style user interface. My application correctly parses and uses that schema. I'm now trying to get that...
8
by: MENTAT | last post by:
Hi Guys, Newbie question here. Part of my xml looks like this. <node> <description/> <config/> <log/> <transition/> <node>
34
by: Adam Hartshorne | last post by:
Hi All, I have the following problem, and I would be extremely grateful if somebody would be kind enough to suggest an efficient solution to it. I create an instance of a Class A, and...
9
by: Rafal Konopka | last post by:
How can you caount the number of occurrences of elements in an array? For example var arr1 = ; how can I count how many 1s, 2s, 3s, etc.? Despite the example, I never actually know what...
3
by: Jody Greening | last post by:
How do I write a schema that is only validating elements: 1,4,7,8,9 and ignores every other element? I also need to not to care about the order of the elements or how many are in between...
8
by: Mir Nazim | last post by:
Hello, I need to write scripts in which I need to generate all posible unique combinations of an integer list. Lists are a minimum 12 elements in size with very large number of possible...
2
by: klikic | last post by:
Hi. How can create a unordered sequence with defined elements that can occur ones and "other" elements that are ignored. Example: XML: <Recur> <ignoredElement>saasda</ignoredElement>...
3
by: ANoobee | last post by:
What is the best approach to force atleast one of a few optional elements required in an XSD? This is what I'm tring to do: <email> <to> <cc> <bcc> </email>
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.