Hello:
( Please redirect me to the correct list if this is not where I m
supposed to
ask this question )
Our application essentially sends xml 'commands' to another system.
These commands are essentially one xml element signifying which
command it is (
3 types of commands ) and a corresponding data required by that
command.
Because some different teams are involved, we do not have freedom to
change the
XML structure ( xml vocabulary )
XML appears in one of the following 3 forms
<COMMAND>REQUES T1</COMMAND>
<COMMAND_DATA >
<REQ1_DAT1> something </REQ1_DAT1>
<REQ1_DAT2> something </REQ1_DAT2>
....
</COMMAND_DATA>
or
<COMMAND>REQUES T2</COMMAND>
<COMMAND_DATA >
<REQ2_DAT1> something </REQ2_DAT1>
<REQ2_DAT2> something </REQ2_DAT2>
<REQ2_DAT3> something </REQ2_DAT3>
....
</COMMAND_DATA>
or
<COMMAND>REQUES T3</COMMAND>
<COMMAND_DATA >
<REQ3_DAT1> something </REQ3_DAT1>
....
</COMMAND_DATA>
We need to essentially build a schema that will restrict the xml to be
in one
of these 3 forms. Is it possible to do this at all.
I had trouble defining it as the definition for COMMAND_DATA is
changing
depending on what the COMMAND is.
I tried something like
<xs:simpleTyp e name="req1Typ">
<xs:restricti on base="xs:string ">
<xs:pattern value="REQUEST1 "/>
</xs:restriction>
</xs:simpleType>
<xs:simpleTyp e name="req2Typ">
<xs:restricti on base="xs:string ">
<xs:pattern value="REQUEST2 "/>
</xs:restriction>
</xs:simpleType>
<xs:simpleTyp e name="req1Typ">
<xs:restricti on base="xs:string ">
<xs:pattern value="REQUEST2 "/>
</xs:restriction>
</xs:simpleType>
<xs:complexTy pe name req1DatTyp>
<xs:sequence>
<xs:element name="REQ1_DAT1 "/>
<xs:element name="REQ1_DAT2 "/>
...
<xs:sequence>
</xs:complexType>
<xs:complexTy pe name req2DatTyp>
<xs:sequence>
<xs:element name="REQ2_DAT1 "/>
<xs:element name="REQ2_DAT2 "/>
<xs:element name="REQ2_DAT3 "/>
...
<xs:sequence>
</xs:complexType>
<xs:complexTy pe name req3DatTyp>
<xs:sequence>
<xs:element name="REQ3_DAT1 "/>
...
<xs:sequence>
</xs:complexType>
<xs:complexTy pe name="choice_on _aggregation" >
<xs:choice>
<xs:sequence>
<xs:element name="COMMAND" type="req1Typ">
<xs:element name="COMMAND_D ATA" type="req1DatTy p">
</xs:sequence>
<xs:sequence>
<xs:element name="COMMAND" type="req2Typ">
<xs:element name="COMMAND_D ATA" type="req1DatTy p">
</xs:sequence>
<xs:sequence>
<xs:element name="COMMAND" type="req3Typ">
<xs:element name="COMMAND_D ATA" type="req1DatTy p">
</xs:sequence>
</xs:choice>
</xs:complexType>
<element name"GLOBAL" type="choice_on _aggregation"/>
But though my xml editor ( xmlspy ) reported this to be a valid
schema, when I
used its 'generate sample XML' feature, it ended up generating xml
that did not
comply with the schema !!
When I used xerces to validate I got an error like
"http://www.bellsouth.c om/wfaif":COMMAND and
"http://www.bellsouth.c om/wfaif":COMMAND (or elements from their
substitution group) violate "Unique Particle Attribution". During
validation against this schema, ambiguity would be created for those
two particles"
Any help will be greatly appreciated
Thanks
--sony