Saturday, June 9, 2012

Oracle SOA 11.1.1.5 Generate XSD From a Flat File

Oracle SOA 11.1.1.5 Generate XSD From a Flat File


This thread discusses steps to create an XML Schema (XSD) from a sample payload. The payload we are discussing here is a CSV file. The CSV file has header records, and the thread will highlight how the contents of the header records can be used in defining the elements of the generated schema.


  • Create a new SOA Project using JDeveloper you may call it GenerateXSDFormFlatFile. as shown below.
  • Press Next.





  • Choose the Empty Composite option .
  • Press Next.






  • From the resource pallet, choose the File Adapter in the Exposed Services Swim Lane.
  • Press Next.








  • Put the Service Name GenerateXSDFromFlatFile_FileAdapter.










  • Choose "Define from operation and schema" option.
  • Press Next.








  • Choose the option to Read File.
  • Choose Operation Name as Read.
  • Press Next.










  • Choose the directory where the file is located.
  • Press Next.










  • Choose the name of the file.
  • Press Next.








  • Press Next.










  • Ensure that the Native Format translation is not required is Unchecked.
  • On the Right Hand Side, click the Icon to Define Native Format.






  • Welcome screen will be displayed.
  • Press Next.






  • Since our file is comma delimited, choose this Delimited option.
  • Press Next.





  • Ensure that the file name is correct
  • Press Next.




  • Enter a name that will represent the record, Employee in this case.
  • Press Next.






  • Choose the Delimited By Symbol, Comma(,).
  • Press Next.





  • Check the Use the first record as the Field Name. This will ensure that entries in the header record are reflected as the elements of the schema.
  • Press Next.





  • The schema is generated in the xsd folder of the project.
  • Press Next.





  • Press Finish.



The Generated XSD looks like


<?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://TargetNamespace.com/ServiceName"
            targetNamespace="http://TargetNamespace.com/ServiceName"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"


            nxsd:version="NXSD"
            nxsd:stream="chars"
            nxsd:encoding="US-ASCII"
            nxsd:hasHeader="true"
            nxsd:headerLines="1"
            nxsd:headerLinesTerminatedBy="${eol}"
>




  <xsd:element name="Root-Element">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Employee" minOccurs="1" maxOccurs="unbounded">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="FirstName" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;" />
              <xsd:element name="LastName" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;" />
              <xsd:element name="Age" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;" />
              <xsd:element name="DOB" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;" />
              <xsd:element name="Salary" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="&quot;" />
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>


</xsd:schema>
<!--NXSDWIZ:C:\MindTelligent\Empoloyees.txt:-->
<!--USE-HEADER:true:-->



















































OCI Knowledge Series: OCI Infrastructure components

  Oracle Cloud Infrastructure (OCI) provides a comprehensive set of infrastructure services that enable you to build and run a wide range of...