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
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