Simanchal Maharana
Simanchal Maharana

Reputation: 56

XSD creation for XML containing namespace

I have XML like below

<ACS:Instrument>
  <ACS:AsOfDate>2016-03-07T00:00:00Z</ACS:AsOfDate>
  <ACS:InstrumentID>12345</ACS:InstrumentID>
  <ACS:DenominatedCurrency>USD</ACS:DenominatedCurrency>
  <ACS:InstrumentName>INDUSTRY</ACS:InstrumentName>
</ACS:Instrument>

I want to create an XSD complex element for this XML.

Upvotes: 2

Views: 35

Answers (1)

kjhughes
kjhughes

Reputation: 111726

XML

<?xml version="1.0" encoding="UTF-8"?>
<ACS:Instrument xmlns:ACS="http://www.example.com/ACS">
    <ACS:AsOfDate>2016-03-07T00:00:00Z</ACS:AsOfDate>
    <ACS:InstrumentID>12345</ACS:InstrumentID>
    <ACS:DenominatedCurrency>USD</ACS:DenominatedCurrency>
    <ACS:InstrumentName>INDUSTRY</ACS:InstrumentName>
</ACS:Instrument>

XSD

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           elementFormDefault="qualified" 
           targetNamespace="http://www.example.com/ACS" 
           xmlns:ACS="http://www.example.com/ACS">
  <xs:element name="Instrument">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="AsOfDate" type="xs:dateTime"/>
        <xs:element name="InstrumentID" type="xs:integer"/>
        <xs:element name="DenominatedCurrency" type="xs:string"/>
        <xs:element name="InstrumentName" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Upvotes: 1

Related Questions