December 10, 2009 at 11:07 am
Hello everybody,
There is a need to construct an xsd schema with validates the xml with the following requirements: a root tag must contain two elements: one must appear only once, another may appear multiple times. The order of the elements is random. Here is an example:
Code:
<University>
<Rector name="hans"/> <!-- appears only once -->
<Student name="tomas"/> <!-- appears multiple times -->
<Student id="maggy"/>
</University>
I have created the xsd to validate such kind of xmls but still there is a problem:
Code:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="University">
<xs:choice maxOccurs="unbounded">
<xs:choice maxOccurs="1">
<xs:element name="Rector">
<xs:attribute name="name" type="xs:string" use="required" />
</xs:element>
</xs:choice>
<xs:choice maxOccurs="unbounded">
<xs:element name="Student">
<xs:attribute name="name" type="xs:string" use="required" />
</xs:element>
</xs:choice>
</xs:choice>
</xs:element>
The problem with an xsd is that there is no restriction on quantity for Rector elements, it still appears multiple time.
Does anybody solved this kind of problems?
Any help is kindly appreciated.
Tim
December 10, 2009 at 1:04 pm
You might want read the following article:
http://www.sqlservercentral.com/articles/Schemas%2fDTDs/3118/
Note: Based on context I assume it's homework or something similar.
Therefore, I didn't post the answer right away, since -back to the old days when I was at school- it would have been considered as cheating...
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply