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:
I have created the xsd to validate such kind of xmls but still there is a problem:Code:<University> <Rector name="hans"/> <!-- appears only once --> <Student name="tomas"/> <!-- appears multiple times --> <Student id="maggy"/> </University>
The problem with an xsd is that there is no restriction on quantity for Rector elements, it still appears multiple time.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>
Does anybody solved this kind of problems?
Any help is kindly appreciated.
Tim


Reply With Quote
Bookmarks