Hi,
I have schema like this:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema id="MessageSchema" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="MESSAGE" type="MessageType"/>
<xsd:complexType name="MessageType">
<xsd:choice>
<xsd:element name="TRNS" type="TrnType" />
<xsd:element name="CLNTS" type="ClntsType" />
<xsd:element name="ACT" type="ActType" />
<xsd:element name="POSS" type="PossType" />
</xsd:choice>
<xsd:attribute name="MessageID" type="xsd:string" use="required"/>
<xsd:attribute name="ApplicationName" type="xsd:string" use="required"/>
<xsd:attribute name="MessageCreationTime" type="xsd:dateTime" use="required"/>
</xsd:complexType>
............
..............
<xsd:complexType name="TranType">
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:element name="TRANSACTION" type="TransactionType"/>
</xsd:choice>
<xsd:attribute name="ChildCount" type="xsd:int" />
</xsd:complexType>
.........
<xsd:complexType name="PositionsType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="POSITION" type="PositionType"/> </xsd:choice>
With this schema, my xml allows only one root under Message. Like this:
<MESSAGE.. attributes>
<TRANS>
<TRANSACTION>... </TRANSACTION>
</TRANS>
</MESSAGE>
BUT I need to allow TRANS AND POS to go either as one or 2. Rest only one at a time
<MESSAGE.. attributes>
<TRANS>
<TRANSACTION>... </TRANSACTION>
</TRANS>
<POSS>
<POSITION>...</POSITION>
</POSS>
</MESSAGE>
How can I do it in schema.
Thank You