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

trouble getting correct schema

I am beginning to wonder if it is not possible to get this working.

I am trying to do:

<root>
<a/>
<b/>
<c/>
</root>

With the following conditions:
1) a,b,c can be in any order
2) a and b can only be used 1 time
3) c can be used 0 to unbounded times.

Trying to do this with sequence, choice, all, each seem to miss one
part of the requirements.

Is this not possible?

Jul 23 '06 #1
4 1202
It is possible:

c*, (a, c*, b)|(b, c*, a), c*
<xs:element name="a"/>
<xs:element name="b"/>
<xs:element name="c"/>

<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice>
<xs:sequence>
<xs:element ref="a"/>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="b"/>
</xs:sequence>
<xs:sequence>
<xs:element ref="b"/>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="a"/>
</xs:sequence>
</xs:choice>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

cmay wrote:
I am beginning to wonder if it is not possible to get this working.

I am trying to do:

<root>
<a/>
<b/>
<c/>
</root>

With the following conditions:
1) a,b,c can be in any order
2) a and b can only be used 1 time
3) c can be used 0 to unbounded times.

Trying to do this with sequence, choice, all, each seem to miss one
part of the requirements.

Is this not possible?
Jul 24 '06 #2
George,

Thanks for the reply and suggestion.

It looks like you are creating optional lists that depict the different
orders that could appear.

So while this might be doable for a,b,c the list would quickly grow out
of control if it were to expand from 3 possible elements to 10 or more.

Is that right?
Chris


George Bina wrote:
It is possible:

c*, (a, c*, b)|(b, c*, a), c*
<xs:element name="a"/>
<xs:element name="b"/>
<xs:element name="c"/>

<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice>
<xs:sequence>
<xs:element ref="a"/>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="b"/>
</xs:sequence>
<xs:sequence>
<xs:element ref="b"/>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="a"/>
</xs:sequence>
</xs:choice>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

cmay wrote:
I am beginning to wonder if it is not possible to get this working.

I am trying to do:

<root>
<a/>
<b/>
<c/>
</root>

With the following conditions:
1) a,b,c can be in any order
2) a and b can only be used 1 time
3) c can be used 0 to unbounded times.

Trying to do this with sequence, choice, all, each seem to miss one
part of the requirements.

Is this not possible?
Jul 24 '06 #3
cmay wrote:
So while this might be doable for a,b,c the list would quickly grow out
of control if it were to expand from 3 possible elements to 10 or more.
Is that right?
Some constraints are better expressed in the application than in the schema.
Jul 24 '06 #4
Hi Chris,

Yes, that is correct.
It is easy to create a more relaxed model and add these constraints at
some other level, at application level as Joe suggested or you can use
embedded Schematron rules inside XML Schema. You can find a working XML
Schema with embedded Schematron rules below.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="a"/>
<xs:element name="b"/>
<xs:element name="c"/>

<xs:element name="root">
<xs:annotation>
<xs:appinfo>
<pattern xmlns="http://www.ascc.net/xml/schematron"
name="testRootContent">
<rule context="root">
<assert test="count(a)=1">a should be used 1 time.</assert>
<assert test="count(b)=1">b should be used 1 time.</assert>
</rule>
</pattern>
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="a"/>
<xs:element ref="b"/>
<xs:element ref="c"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
cmay wrote:
George,

Thanks for the reply and suggestion.

It looks like you are creating optional lists that depict the different
orders that could appear.

So while this might be doable for a,b,c the list would quickly grow out
of control if it were to expand from 3 possible elements to 10 or more.

Is that right?
Chris


George Bina wrote:
It is possible:

c*, (a, c*, b)|(b, c*, a), c*
<xs:element name="a"/>
<xs:element name="b"/>
<xs:element name="c"/>

<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice>
<xs:sequence>
<xs:element ref="a"/>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="b"/>
</xs:sequence>
<xs:sequence>
<xs:element ref="b"/>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="a"/>
</xs:sequence>
</xs:choice>
<xs:element ref="c" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

cmay wrote:
I am beginning to wonder if it is not possible to get this working.
>
I am trying to do:
>
<root>
<a/>
<b/>
<c/>
</root>
>
With the following conditions:
1) a,b,c can be in any order
2) a and b can only be used 1 time
3) c can be used 0 to unbounded times.
>
Trying to do this with sequence, choice, all, each seem to miss one
part of the requirements.
>
Is this not possible?
Jul 25 '06 #5

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

Similar topics

0
by: Sarah Tegtmeier | last post by:
Hi I have a question about the correct use of the attribute xsi:schemaLocation. My programm has to process XML files where the value of this attribute causes some problems. The programm is...
4
by: Group IIS | last post by:
Hi all, I am using ALTOVA XMLSpy. The start of my XML file looks like this: <?xml version="1.0" encoding="UTF-8" ?> <Submission xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
2
by: AlexS | last post by:
Hello, I have error when reading schema using XmlSchema. Read and then .Compile: System.Xml.Schema.XmlSchemaException: May not be nominated as the {substitution group affiliation} of any...
5
by: Don | last post by:
Hi: I have created an xsd from my xml document. I pop this xsd in the following directory: C:\program files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\xml. That give me...
2
by: John Jenkins | last post by:
Hi, I have a lot of schemas to load into a schema collection. I load them in by reading each one into a XMLTextReader from disk and add them into a schema collection. I have a couple of issues to...
4
by: bibsoconner | last post by:
Hi, I hope someone can please help me. I'm having a lot of trouble with schema files in .NET. I have produced a very simple example that uses "include" to include other schema files. It all...
1
by: santoshs | last post by:
I think this question has been asked before... I have instance DB2T, within which I would like to create multiple schemas. I want to then create the same set of tables within each schema. My...
4
by: Jonas Bush | last post by:
I've got the some code to try and validate some xml. Against my schema, the "Good" xml (below) produces a couple of warnings, which I don't care about. The "Bad" xml (also below), produces warnings...
3
by: h4xPace | last post by:
I am building a MySQL query application, and I have run into a small snag. MySQL has released a set of classes that extend the .NET framework base data classes (command, connection, etc), and I am...
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
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
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
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
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.