Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsd schema for xml

Status
Not open for further replies.

Spunny

Programmer
Jun 30, 2010
3
0
0
US
Hi,

I have existing xml schema which I need to modify to get the following data.

XSD Schema:

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema id="sschema" elementFormDefault="qualified" xmlns:xsd=" <xsd:element name="MSG" type="MessageType"/>
<xsd:complexType name="MessageType">
<xsd:choice>
<xsd:element name="TRANSACTIONS" type="TransactionsType" />
<xsd:element name="CLIENTS" type="ClientsType" />
</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="TransactionsType">
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:element name="Transaction" type="TransactionType"/>
</xsd:sequence>
<xsd:attribute name="ChildCount" type="xsd:int" />
</xsd:complexType>
<xsd:complexType name="ClientsType">
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:element name="CLIENT" type="ClientType"/>
</xsd:sequence>
<xsd:attribute name="ChildCount" type="xsd:int" />
</xsd:complexType>
<xsd:complexType name="TransactionType">
<xsd:sequence>
<xsd:element name="ACTION" type="ActionTypes" minOccurs="1" maxOccurs="1" />
<xsd:element name="ACCOUNTS" minOccurs="1" maxOccurs="1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ACCOUNT" minOccurs="1" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="DEBIT_ACCOUNT" type="xsd:short" />
<xsd:element name="CREDIT_ACCOUNT" type="xsd:short" />
<xsd:element name="AMOUNT" type="xsd:string" />
<xsd:element name="ID" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="ActionTypes">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Add"/>
<xsd:enumeration value="Update"/>
<xsd:enumeration value="Delete"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>

My xml for above schema for transactions looks likes this:

<TRANSACTIONS ChildCount='1'>
<TRANSACTION>

...........

......

</TRANSACTION>

</TRANSACTIONS>

Now they want me to add another element in transactions element like this:

<TRANSACTIONS ChildCount='1'>
<SOURCE_TRANSACTION>

...........

......

</SOURCE_TRANSACTION>


<DEST_TRANSACTION>

...........

......

</DEST_TRANSACTION>

</TRANSACTIONS>

How can I add another element to 'Transactions' element because Transactions element is defined as type 'TransactionType'.

Dest_Transaction has different data structure. Both Source_transaction and Dest_transaction should be placed under 'Transactions' parent element.

Thank You
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top