473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Help needed with complex schema definition

Hi all,

I need to create an XSD schema that will reperesent the following:

<LIST>
<ITEM1/> 0-unbounded
<ITEM3/> 0-unbounded
</LIST>

or

<LIST>
<ITEM2/> 0-unbounded
<ITEM3/> 0-unbounded
</LIST>

The problem is that within the LIST item, the order of the elements
does not matter! I found that I can't use the all model with the
choice model as parent.
Other solutions I tried resulted in ambigouos definition of the ITEM3
element due to "Unique Particle Attribution rule".

This is the current unsatisfactory schema, since it contains sequence
which forces unwanted order:

<xs:complexType name="ListType">
<xs:sequence>
<xs:choice minOccurs="0">
<xs:element name="ITEM1" type="ITEM1Type" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="ITEM2" type="ITEM2Type" minOccurs="0"
maxOccurs="unbounded"/>
</xs:choice>
<xs:element name="ITEM3" type="ITEM3Type" minOccurs="0"
maxOccurs="unbounded"/>
</xs:complexType>

Any ideas?

Thanks in advance,

Gili Korman
ITG
Jul 20 '05 #1
7 2072
Gili Korman wrote:
The problem is that within the LIST item, the order of the elements
does not matter! I found that I can't use the all model with the
choice model as parent.
Other solutions I tried resulted in ambigouos definition of the ITEM3
element due to "Unique Particle Attribution rule".

This is the current unsatisfactory schema, since it contains sequence
which forces unwanted order:


How about

<xs:element name="list">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:choice>
<xs:element ref="item1" minOccurs="1" maxOccurs="1"/>
<xs:element ref="item2" minOccurs="1" maxOccurs="1"/>
<xs:element ref="item3" minOccurs="1" maxOccurs="1"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>

--
Klaus Johannes Rusch
Kl********@atmedia.net
http://www.atmedia.net/KlausRusch/
Jul 20 '05 #2
Hello if you want the item to appear in any order any number of times
try the following:

<xs:complexType name="ListType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="ITEM1" type="ITEM1Type" />
<xs:element name="ITEM2" type="ITEM2Type" />
<xs:element name="ITEM3" type="ITEM3Type" />
</xs:choice>
</xs:complexType>

or are you trying to model that ITEM1 and ITEM2 can only appear once
along with ITEM3, but there should be able to appear in any order any
number of times.

Is this valid:
<LIST>
<ITEM3/>
<ITEM1/>
<ITEM1/>
</LIST>

but not:

<LIST>
<ITEM3/>
<ITEM1/>
<ITEM2/>
</LIST>

Kind regards,
Eric

Gili Korman wrote:
Hi all,

I need to create an XSD schema that will reperesent the following:

<LIST>
<ITEM1/> 0-unbounded
<ITEM3/> 0-unbounded
</LIST>

or

<LIST>
<ITEM2/> 0-unbounded
<ITEM3/> 0-unbounded
</LIST>

The problem is that within the LIST item, the order of the elements
does not matter! I found that I can't use the all model with the
choice model as parent.
Other solutions I tried resulted in ambigouos definition of the ITEM3
element due to "Unique Particle Attribution rule".

This is the current unsatisfactory schema, since it contains sequence
which forces unwanted order:

<xs:complexType name="ListType">
<xs:sequence>
<xs:choice minOccurs="0">
<xs:element name="ITEM1" type="ITEM1Type" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="ITEM2" type="ITEM2Type" minOccurs="0"
maxOccurs="unbounded"/>
</xs:choice>
<xs:element name="ITEM3" type="ITEM3Type" minOccurs="0"
maxOccurs="unbounded"/>
</xs:complexType>

Any ideas?

Thanks in advance,

Gili Korman
ITG


Jul 20 '05 #3
gi***@itgil.com (Gili Korman) writes:
Hi all,

I need to create an XSD schema that will reperesent the following:

<LIST>
<ITEM1/> 0-unbounded
<ITEM3/> 0-unbounded
</LIST>

or

<LIST>
<ITEM2/> 0-unbounded
<ITEM3/> 0-unbounded
</LIST>
I'm not sure what this is trying to say. Can you try again?
The problem is that within the LIST item, the order of the elements
does not matter!
Do you mean "it does not matter" in the sense that all possible
orders should be allowed in the input? or in the sense that
the order cannot possibly carry any information? (If the order
cannot possibly carry any information, then a fixed order is
usually a good way to go.)
Any ideas?


Not until I understand better what it is you're trying to do.

-C. M. Sperberg-McQueen
World Wide Web Consortium
Jul 20 '05 #4
cm****@acm.org (C. M. Sperberg-McQueen) wrote in message news:<m2************@acm.org>...
gi***@itgil.com (Gili Korman) writes:
Hi all,

I need to create an XSD schema that will reperesent the following:

<LIST>
<ITEM1/> 0-unbounded
<ITEM3/> 0-unbounded
</LIST>

or

<LIST>
<ITEM2/> 0-unbounded
<ITEM3/> 0-unbounded
</LIST>


I'm not sure what this is trying to say. Can you try again?
The problem is that within the LIST item, the order of the elements
does not matter!


Do you mean "it does not matter" in the sense that all possible
orders should be allowed in the input? or in the sense that
the order cannot possibly carry any information? (If the order
cannot possibly carry any information, then a fixed order is
usually a good way to go.)
Any ideas?


Not until I understand better what it is you're trying to do.

-C. M. Sperberg-McQueen
World Wide Web Consortium

Sorry if I have been ambigouos, let me try to explain my list
constraints:

A. ITEM1 and ITEM2 can not co-exist in the list.
B. The list can contain any number of ITEM1 (0-unbounded) OR
any number of ITEM2 (0-unbounded), but only one of the types in a
list.
C. ITEM3 can also appear in the list, any number of times
(0-unbounded), with
or without the list having other elements.
D. The order of the list does not carry any information, and so it
does not
matter.

So, Klaus and Eric's schemas will not be good because they allow ITEM1
and ITEM2 types in the same list.

To Eric:

<LIST>
<ITEM3/>
<ITEM1/>
<ITEM2/>
</LIST>

is not OK.

<LIST>
<ITEM3/>
<ITEM1/>
<ITEM1/>
</LIST>

is OK.

Thanks for your input, hoping for salvation...
Jul 20 '05 #5
I would like to stress that since the order of the items in the list
does not matter, I am required to allow any order - and that is the
real problem !
Jul 20 '05 #6
gi***@itgil.com (Gili Korman) writes:
..., let me try to explain my list
constraints:

A. ITEM1 and ITEM2 can not co-exist in the list.
B. The list can contain any number of ITEM1 (0-unbounded) OR
any number of ITEM2 (0-unbounded), but only one of the types in a
list.
C. ITEM3 can also appear in the list, any number of times
(0-unbounded), with
or without the list having other elements.
D. The order of the list does not carry any information, and so it
does not matter.

So, Klaus and Eric's schemas will not be good because they allow ITEM1
and ITEM2 types in the same list.


Well, I repeat what I said earlier: if the order of the items in the
list does not carry any information, it is usually better practice to
specify a fixed order. Otherwise, you wind up with fierce, protracted
arguments between people who want to argue that

<LIST1/><LIST1/><LIST3/>

must be treated subtly differently from

<LIST3/><LIST1/><LIST1/>

or

<LIST1/><LIST3/><LIST1/>

and people who argue, on the contrary, that because the order of
items carries no information, these must NOT be treated separately.
It is better to nip such disagreements in the bud.

I am almost unwilling to tell you how to do what you say you want to
do, on the grounds that I am convinced you shouldn't do it, but if you
are determined to provide an opening for such disagreements, honesty
compels me to note that it's actually not impossible, just verbose.
In regex notation, what you want is

(list3* ((list1 (list1 | list3)*) | (list2 (list2 | list3)*))?)

that is: any number of list3 elements, followed optionally by a mixed
list of list1 and list3, or by a mixed list of list2 and list3. In
XML Schema terms:

<xsd:complexType name="LISTtype">
<xsd:annotation><xsd:documentation>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>A content model which allows any number of either LIST1 or
LIST2 elements, together with any number of LIST3 elements, in
any order.</p>
<p>The problem with this model is that it is intended to convey
the idea that "order doesn't matter" but will, by allowing
different orderings of the same material, inevitably lead some
users and some programmers to believe that there may be
meaningful differences in meaning based on order.
</p>
</div></xsd:documentation></xsd:annotation>
<xsd:sequence>
<xsd:element ref="LIST3" minOccurs="0" maxOccurs="unbounded"/>
<xsd:choice minOccurs="0">
<xsd:sequence>
<xsd:element ref="LIST1"/>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="LIST1"/>
<xsd:element ref="LIST3"/>
</xsd:choice>
</xsd:sequence>
<xsd:sequence>
<xsd:element ref="LIST2"/>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="LIST2"/>
<xsd:element ref="LIST3"/>
</xsd:choice>
</xsd:sequence>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>

The basic idea is that the instances of this content model will
inevitably be either mixtures of LIST1 and LIST3, or of LIST2 and
LIST3, or just sequences of LIST3. As long as you are just getting
LIST3 elements, you can't tell which of these three possibilities is
being realized. Once you see a LIST1 or a LIST2, however, you know
which path to take through the regular expression and the other kind
of list is no longer an option. Some people have said this
content-model pattern reminds them of a harpoon: once the barb is in,
the harpoon only goes one direction.

The more restrictive alternative is somewhat simpler:

<xsd:complexType name="simplerLISTtype">
<xsd:annotation><xsd:documentation>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>A simpler content model which prescribes an order and thus
makes it impossible for variations in the order of elements
to exist, let alone carry information.
</p>
<p>The only problem with this model is that some users will wish
to convey subtle shades of meaning by putting the elements in
different orders. The biggest virtue of this model is that it
makes such behavior impossible. (If the shades of meaning are
documented, they are worth having; otherwise, they are an
illusion and only lead to tears down the road.)
</p>
</div></xsd:documentation></xsd:annotation>
<xsd:sequence>
<xsd:choice minOccurs="0">
<xsd:element ref="LIST1" maxOccurs="unbounded"/>
<xsd:element ref="LIST2" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:element ref="LIST3" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>

I hope this helps.

-C. M. Sperberg-McQueen
Jul 20 '05 #7
That was a really great help. I had to use the first solution as my
requirements were to allow all orders...
Thanks a lot!
Jul 20 '05 #8

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

Similar topics

1
by: Ulf Heyder | last post by:
Hello, I have to deal with some xml schemas from a third party. This schema contains the following complex type. <?xml version="1.0"?> <xsd:schema ... elementFormDefault="qualified"> .......
1
by: Wolfgang Lipp | last post by:
my question is: do we need container elements for repeating elements in data-centric xml documents? or is it for some reason very advisable to introduce containers in xml documents even where not...
3
by: Robert Rolls | last post by:
I've got the following really simple schema : <?xml version="1.0" ?> <xs:schema targetNamespace="urn:503A2B4E-B364-47a4-AE5C-16E727275A70" xmlns:mstns="urn:503A2B4E-B364-47a4-AE5C-16E727275A70"...
7
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure...
2
by: bjhartin | last post by:
Hello all, I am having a problem with extending complex types. I have a simple base schema (FooBar.xsd) which defines XML documents of the following form: <Foo FooAttribute1="aaa"> <Bar...
4
by: olivier.scalbert | last post by:
Hello, I need to create an xsd to validate the following type of xml: <?xml version="1.0" encoding="UTF-8"?> <root <exception1 xsi:type="ExceptionAType"> <Type>1</Type> <Info>Bla bla</Info>...
0
by: peterpeter | last post by:
Hi. There is a XML schema problem that I have with key/keyref: I have a complex type "AExtended" which inherits from a base type "ABase". Both are allowed to be instantiated under the "Root"...
3
by: katis | last post by:
Hi all :) Is it posible in xsd to change only minOccurs value of element in complex type by extending this type? The problem I'm trying to solve is this: I have two complex types -...
1
by: gdev | last post by:
Having some trouble getting my head around setting access to specific schemas- here's my problem: I've created a specific schema that I only want certain users to control Problem: Even...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.