Subject: XSD composite key constraint
Posted By: aldwinenriquez Post Date: 8/15/2005 3:20:50 AM
How do I implement composite key constraint for an xsd element I have. Basically I need to ensure that the two attributes (USERID and COURSEID) cannot be duplicated in the xml that I have.

How do I do that?

Aldwin Enriquez
"Dont you ever give up!"
Reply By: aldwinenriquez Reply Date: 8/15/2005 4:06:47 AM
I got it guys..I used xs:key element..

<xs:key name="unq_USER_COURSE">
  <xs:selector xpath="Courses"/>
  <xs:field xpath="@USERID"/>
  <xs:field xpath="@COURSEID"/>
</xs:key>

Aldwin Enriquez
"Dont you ever give up!"
Reply By: mhkay Reply Date: 8/15/2005 4:20:23 AM
Use an xsd:unique element with more than one xsd:field child; the combination of all the xsd:field's defines the composite key.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

Go to topic 33588

Return to index page 793
Return to index page 792
Return to index page 791
Return to index page 790
Return to index page 789
Return to index page 788
Return to index page 787
Return to index page 786
Return to index page 785
Return to index page 784