XML xsd help

This should cover W3C XML Schema, Relax NG and DTD related problems.
Posts: 1
Joined: Wed Sep 28, 2005 8:31 am

XML xsd help

Post by Yi » Wed Sep 28, 2005 8:39 am

Hey peoples! :D

Got a situation I have to find my way around, but I want to know if there even is a way around:

Say I have an XML document that has the following
<student no="1">Baxter</student>

The xsd schema allows the integers 1 through to 9 for the 'student no' attribute and the strings, say Baxter, Erin, Katie.... for the 'Student' element content.

I've got a handle on the enumeration for this, however what I really want is for the enumerations to be linked, so to speak.

Like this, if the xml document were to have 'student no' as 1, then the only string that can be inserted as 'student' element content is 'Baxter'

I.e This is valid :
<student no="1">Baxter</student>

This will not be valid:
<student no="1">Somename</student>

Thanks in advance to anyone who can help me out. :D


Site Admin
Posts: 2102
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Wed Sep 28, 2005 10:22 am


That is called co-occurence constraint and it is not supported by XML Schema. Possible options are:
- perform the check at application level
- use Schematron embedded in XML Schema (oXygen supports that)
- use Relax NG or Relax NG with embedded Schematron rules (oXygen supports also that)

Best Regards,

Post Reply