all groups > dotnet xml > march 2007 >
You're in the

dotnet xml

group:

XSD newbie: Element based choice.



Re: XSD newbie: Element based choice. John Saunders
3/23/2007 7:15:40 PM
dotnet xml: [quoted text, click to view]

That's not a well-formed XML document. You need root element around all of
those.

[quoted text, click to view]

XML Schema cannot describe this situation. You'll have to check yourself.

John

XSD newbie: Element based choice. BLUE
3/23/2007 10:30:00 PM
Suppose I have an XML file like this:

<type>...</type>
<positionID>...</positionID>
<category>...</category>


I want to specify in my XML Schema that:

- if "type" is "One" I must have
<positionID>A_STRING</positionID>

- if "type" is "Two" I must have
<positionID>
<zoneID>A_POSITIVE_NUM</zoneID>
<sectorID>A_POSITIVE_NUM</sectorID>
<cellID>A_POSITIVE_NUM</cellID>
</positionID>

- if "type" is "Three" I must have
no category or empty category

- if "type" is "Four" I must have
the same thing as for case "Two" and "Three"


If this is not possible can I check this from my application or it would be
a semantic error and it would be better to separate the two schemas?


Thank you for any help!
Luigi.

Re: XSD newbie: Element based choice. Priya Lakshminarayanan
3/29/2007 11:29:16 AM
These constraints are called co-occurrence constraints and cannot be
specified using XML Schema. You can embed Schematron rules in your schema to
specify the same.
For more information on Schematron, check the following:
http://xml.ascc.net/resource/schematron/
http://www.xml.com/pub/a/2000/11/22/schematron.html

Thanks,
Priya

[quoted text, click to view]

AddThis Social Bookmark Button