473,756 Members | 3,566 Online
Bytes | Software Development & Data Engineering Community
+ 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="unbo unded"/>

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

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

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

</xs:all>

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

The above definition cannot be validated correctly...

Thanks in advance!

Mavis

Oct 10 '06 #1
2 1971
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:annotatio n>
<xs:appinfo>
<pattern xmlns="http://www.ascc.net/xml/schematron"
name="testGroup ing">
<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="unbo unded"/>
<xs:element name="B-2" type="xs:string " minOccurs="0"
maxOccurs="unbo unded"/>
<xs:element name="B-3" type="xs:string " minOccurs="0"
maxOccurs="unbo unded"/>
<xs:element name="B-4" type="xs:string " minOccurs="0"
maxOccurs="unbo unded"/>
</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="unbo unded"/>

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

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

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

</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:annotatio n>
<xs:appinfo>
<pattern xmlns="http://www.ascc.net/xml/schematron"
name="testGroup ing">
<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="unbo unded"/>
<xs:element name="B-2" type="xs:string " minOccurs="0"
maxOccurs="unbo unded"/>
<xs:element name="B-3" type="xs:string " minOccurs="0"
maxOccurs="unbo unded"/>
<xs:element name="B-4" type="xs:string " minOccurs="0"
maxOccurs="unbo unded"/>
</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="unbo unded"/>

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

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

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

</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
3099
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
3061
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 schema to be legal, so that if I threw my UI.xml and UISchema.xml at a validator it would succeed. I have just learned that the order of elements is important, that is if you define a schema with element a followed by element b, then in the xml...
8
2352
by: MENTAT | last post by:
Hi Guys, Newbie question here. Part of my xml looks like this. <node> <description/> <config/> <log/> <transition/> <node>
34
4175
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 "push_back" a copy of this into a vector V. This is repeated many times in an iterative process. Ok whenever I "push_back" a copy of Class A, I also want to assign a pointer contained in an exisiting instance of a Class B to this
9
110933
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 elements (and how many) the array holds, which means, that the following is NOT a solution for me:
3
3508
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 elements that I am trying to validate. XML:
8
5635
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 combination(12!) I hacked a few lines of code and tried a few things from Python CookBook (http://aspn.activestate.com/ASPN/Cookbook/), but they are hell slow.
2
6943
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> <frequency>sdsad</frequency> <recurEnd>kjdskdj</recurEnd> </Recur>
3
2082
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
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8713
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
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 we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.