XML query - schema included

Discussion in 'XML' started by Colin McGuire, Aug 20, 2003.

  1. 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
     
    Colin McGuire, Aug 20, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,558
    Markus
    Nov 23, 2005
  2. Fred Smith
    Replies:
    1
    Views:
    950
    Martin Honnen
    Feb 5, 2004
  3. Hari Om
    Replies:
    1
    Views:
    464
    Martin SChukrazy
    Mar 2, 2004
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,272
    Stanimir Stamenkov
    Apr 25, 2005
  5. Replies:
    3
    Views:
    2,877
Loading...

Share This Page