Reputation: 3
I'm having a really hard time figuring this one out. I wish to make a XML Schema for the file I have but really don't seem to find a good way of doing it. Here's what it looks like :
<field name="NameOfField1">
<typeofvalue name="enumeration">
<val> val </val>
</type>
</field>
<field name="NameOfField2">
<typeofvalue name="float">
<val> val </val>
</type>
</field>
<field name="NameOfField3">
<otherinfo name="otherinfo">
<typeofvalue name="integer">
<val> val </val>
</type>
</otherinfo>
</field>
I have to validate the content of each field depending of their attribute "name". For example, if the value in "Val" needs to be an enumeration containing the values "None, Apple, Orange" or if it's an integer between 0 and 15...etc. Each field "name" can only appear once in the xml file, I have no control whatsoever on the XML file (I receive it as is and can't change it).
Help would be greatly appreciated because no examples I could find really helped me...Thanks !
Upvotes: 0
Views: 131
Reputation: 163262
I have to validate the content of each field depending of their attribute "name".
It's a well-known restriction of XSD 1.0 that you can't do this. This is fixed in XSD 1.1 with a facility called "conditional type assignment". It's implemented in both Saxon and Xerces, but not in any other schema processors as far as I know.
Upvotes: 1