Wednesday, 25 September 2013

Complex Flat File fixed length in NXSD

Ex:
          20130210                                                            à  Header 
0001284576196106212013062820130728                  à Details unbounded
0001284578196106212013062820130728
0001284580201210242013060120130604
0001284582193205082013102420141024
0001284584192103222013091420140914
0001302574192610152013092820140928
1111111111    6                                                            à Trailer  

NXSD Structure


<?xml version="1.0" encoding="UTF-8" ?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
            xmlns:tns="http://xmlns.nxsd.madhu/sampleFlatFile"
            targetNamespace=" http://xmlns.nxsd.madhu/sampleFlatFile"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            nxsd:version="NXSD"
            nxsd:stream="chars"
            nxsd:encoding="US-ASCII">


  <xsd:element name="Root-Element">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Request" type="tns:RequestType" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>


  <xsd:complexType name="DetailsType">

    <xsd:sequence>
      <xsd:element name="empId" type="xsd:string" minOccurs="0" nxsd:style="fixedLength" nxsd:length="10" nxsd:padStyle="tail" nxsd:paddedBy=" " />
      <xsd:element name="DOB" type="xsd:string" minOccurs="0" nxsd:style="fixedLength" nxsd:length="8" nxsd:padStyle="tail" nxsd:paddedBy=" " />
      <xsd:element name="joinDate" type="xsd:string" minOccurs="0" nxsd:style="fixedLength" nxsd:length="8" nxsd:padStyle="tail" nxsd:paddedBy=" " />
      <xsd:element name="joinEndDate" type="xsd:string" minOccurs="0" nxsd:style="fixedLength" nxsd:length="8" nxsd:padStyle="tail" nxsd:paddedBy=" " />
      <xsd:element name="Filler" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" />
    </xsd:sequence>
  </xsd:complexType>


  <xsd:complexType name="RequestType">
    <xsd:sequence>
      <xsd:element name="Header" type="tns:HeaderType" minOccurs="0" />
      <xsd:element name="Details" type="tns:DetailsType" maxOccurs="unbounded"    nxsd:style="array" nxsd:cellSeparatedBy="" nxsd:arrayTerminatedBy="1111111111" />
      <xsd:element name="Trailer" type="tns:TrailerType" minOccurs="0" />
    </xsd:sequence>
  </xsd:complexType>


  <xsd:complexType name="HeaderType">
    <xsd:sequence>
      <xsd:element name="HeaderID" type="xsd:string" nxsd:style="fixedLength" nxsd:length="10" />
      <xsd:element name="FileDate" type="xsd:string" nxsd:style="fixedLength" nxsd:length="8"                       nxsd:padStyle="tail" nxsd:paddedBy=" " />
 <xsd:element name="HeaderFiller" type="xsd:string" nxsd:style="terminated"            nxsd:terminatedBy="${eol}" />
    </xsd:sequence>
  </xsd:complexType>


  <xsd:complexType name="TrailerType">
    <xsd:sequence>
      <xsd:element name="TrailerID" type="xsd:string" nxsd:style="fixedLength" nxsd:length="10" nxsd:padStyle="tail" nxsd:paddedBy=" " nxsd:prefixWith="1111111111" />
      <xsd:element name="TotalEmpRecords" type="xsd:string" nxsd:style="fixedLength" nxsd:length="8" nxsd:padStyle="tail" nxsd:paddedBy=" " />
      <xsd:element name="TrailerFiller" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" />
    </xsd:sequence>
  </xsd:complexType>


</xsd:schema>     

Happy coding ....!

5 comments:

  1. Hi , This is good post very informative. Need help in removing the last lines and only getting data
    EURUSD GFB Mercy|0|2|1.523800|03/01/2016|
    EURTHB FLL Mercy|0|2|38.709000|03/01/2016|
    END-OF-DATA
    TIMEFINISHED=Tue Mar 1 10:01:18 EST 2016
    END-OF-FILE
    I am using below xsd























    Please help asap\\

    Ahmed

    ReplyDelete
  2. If there are multiple Array elements, how do we define that in nxsd.For example: Say we have the Detail record of array Type and then there is a subTotalRecord also of Array Type. If I use the above approach, the first subTotalRecord first element is not mapped . Please help and guide

    ReplyDelete
  3. Thanks and I have a neat present: Who Repairs House Siding contractor for home renovation

    ReplyDelete

Oracle Opatch utility 12c

 Hi Blog Viewers, This post will describes the how to apply single or multiple patches at a time. Prerequisites : Set the Oracle Home and Op...