XML query - schema included

C

Colin McGuire

Hello, I have the following schema defined to validate XML that has
lots of students in a school, and each student has an age and a
studentID.
Here is my schema - I cannot figure out how to put in the schema that
the studentID must be unique (two students cannot have the same ID).

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="school">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="student" minOccurs="1" maxOccurs="3260">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="age" type="xsd:integer"/>
<xsd:element name="studentID" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>



I am thinking to make the studentID unique I have to put this in (I
dont know whether this is correct but think it is), but I do now know
where.


<xsd:unique name="UniqueStudentConstraint">
<xs:selector xpath="student"/>
<xs:field xpath="@studentID"/>
</xsd:unique>


Thank you
Colin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top