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? 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?
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?
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.
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?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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"...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |