posted 19 years ago
Hi,
I'm currently working on a project that takes the Raw XML and transforms it into a pseudo 'form' type XML, and i'm trying to write an XML Schema to validate that developers have written the transformation stylesheets to output the data in the correct format.
The question is, is there way in XML Schema to define essentially two (or more) definitions for the same element, dependant upon a given attribute in it. Therefore if type='text' then it must have attributes A and B and optionally can have attribute C & D, but if type='date' then it must have attribute X and can optionally have attribute Y & Z?
I'm relatively inexperienced as far as XML Schema's go and the way the data has been defined from stage one is thus
<table>
<row>
<field type="text" name="field1" value="bob" style="font-weight:bold;"/>
<field type="date" name="field2" format="datetime" validatepast="true" value="1973-07-27 16:34:00"/>
</row>
</table>
I get the feeling it might be something to do with <xs:attributeGroup> element but i can't seem to get it working correctly.
obviously this is a very cut down version and there's a host of other tags, but i've tried to keep it simple as it covers what's needed.