Page 1 of 1

XML xsd help

Posted: Wed Sep 28, 2005 8:39 am
by Yi
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


Posted: Wed Sep 28, 2005 10:22 am
by george

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,