473,394 Members | 1,944 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,394 software developers and data experts.

<xs:all> with unbounded elements

Hi,

I would like to create a schema that validate the following xml:

<music>
<pop/>
<rock/>
<pop/>
</music>

that is, <rock> should only appear once while <pop> can appear several
times. In addition, <pop> and <rock> elements can appear in any order.

I would propose the following (invalid) schema:

<xs:element name="music">
<xs:complexType>
<xs:all>
<xs:element name="rock"/>
<xs:element name="pop" maxOccurs="unbounded"/>
</xs:all>
</xs:complexType>
</xs:element>

This schema is invalid because the constraint maxOccurs within <xs:all>
cannot be greater that 1. (Nevertheless it represents what I'm looking
for)

It seems that neither <xs:all> nor <xs:sequence> nor <xs:choice> gives
this possibility. So my question is: is there another way of defining
such a behaviour with a schema ?

I tried to generate the schema with XMLSpy but it gave me something
like:

<xs:element name="music">
<xs:complexType>
<xs:sequence>
<xs:element name="pop"/>
<xs:element name="rock"/>
<xs:element name="pop"/>
</xs:sequence>
</xs:complexType>
</xs:element>

Which is not really usefull since I don't know in advance the number of
<pop> elements.

Thanks

Jul 20 '05 #1
2 4016

that is, <rock> should only appear once while <pop> can appear several
times. In addition, <pop> and <rock> elements can appear in any order.

in dtd syntax you need

(rock,pop*)|(pop+,rock,pop*)

It should be easy enough to translate that back to xsd syntax.

David

Jul 20 '05 #2
The problem is that if I add new elements like <metal>, <soul>, etc...
the syntax you propose becomes too complex to define. My real-life
problem has about 20 different elements.
And the translation to xsd gives a solution with similar complexity.

Jul 20 '05 #3

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

Similar topics

3
by: Kimmo J?rvikangas | last post by:
Dear XML (Schema) experts, As an example I have the following schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"...
1
by: Bernd Oninger | last post by:
As far as I know one could use other xsd schemas with the import and the xlink feature. What are the differences (beside the syntax)? Bernd
1
by: Ed Bacon | last post by:
I am trying to produce a generic "audit report" for various transactions in our application. Each transaction type defines a document (and has an associated schema). When a transaction leads to a...
2
by: SA | last post by:
Hi all, in the following situation: <xs:element name="Type"> <xs:simpleType> <xs:restriction base="xs:NMTOKEN">
5
by: Jeff | last post by:
We are using .Net and the wsdl Utility to generate proxies to consume web services built using the BEA toolset. The data architects on the BEA side create XML schemas with various entities in...
5
by: Bart van Deenen | last post by:
Hi all I have a form with a couple of input fields, embedded within spans. I am using script.aculo.us for dragging and dropping, and want to reorder the input fields that way. The input fields are...
2
by: mavis | last post by:
The usage of <xs:choice maxOccurs="unbounded"> When we want to define a set of elements that could be in any order and with any occurences (0-unbounded), we can use <xs:choice...
2
by: Aray | last post by:
I googled for it for few houres, but didn't resolve it, any hints will be thinkfull. I want to use the following XSD file to guarantee <element1is unique, but it doesn't work. The following...
1
by: cedric.louyot | last post by:
Hi, I've written a schema that looks like : <xs:schema> <xs:complexType name="myType"> <xs:sequence> <xs:element name="e1" type="T1" maxOccurs="unbounded"/> <xs:element name="e2"...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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,...
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.