Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

xml schema with 2 root elements

$
0
0

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


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>