Wednesday, October 26, 2011

Native Format Builder generated from Excel formulas

here the reference manual:

http://download.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/nfb.htm

See "7.2.1.3 Defining a Fixed-Length Structure"

xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"

A typical entry consists of:


<element name="to_usd_rate" nxsd:style="fixedLength" nxsd:length="12"
nxsd:padStyle="head" nxsd:paddedBy="0">
<simpleType>
<restriction base="string">
<maxLength value="12" />
</restriction>
</simpleType>
</element>


I am generating all these elements with Excel, because I hate monkey work

I put this text in a file:
ABC Private Limited Street1 Bangalore Karnataka India


I put this in Excel

NAME LENGTH
company 22
address 10
city 10
region 10
country 5


and I use this formula to generate all tags:

="<xsd:element name="""&B11&""" nxsd:style=""fixedLength"" nxsd:length="""&C11&""" nxsd:padStyle=""head"" nxsd:paddedBy=""0""> <xsd:simpleType><xsd:restriction base=""xsd:string""> <xsd:maxLength value="""&C11&""" /> </xsd:restriction> </xsd:simpleType> </xsd:element>"


Here is the Excel file


Here is the generated nXSD:

<?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"
>


  <xsd:element name="Root-Element">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="company" nxsd:style="fixedLength" nxsd:length="22" nxsd:padStyle="head" nxsd:paddedBy="0"> <xsd:simpleType><xsd:restriction base="xsd:string"> <xsd:maxLength value="22" /> </xsd:restriction> </xsd:simpleType> </xsd:element>
        <xsd:element name="address" nxsd:style="fixedLength" nxsd:length="10" nxsd:padStyle="head" nxsd:paddedBy="0"> <xsd:simpleType><xsd:restriction base="xsd:string"> <xsd:maxLength value="10" /> </xsd:restriction> </xsd:simpleType> </xsd:element>
        <xsd:element name="city" nxsd:style="fixedLength" nxsd:length="10" nxsd:padStyle="head" nxsd:paddedBy="0"> <xsd:simpleType><xsd:restriction base="xsd:string"> <xsd:maxLength value="10" /> </xsd:restriction> </xsd:simpleType> </xsd:element>
        <xsd:element name="region" nxsd:style="fixedLength" nxsd:length="10" nxsd:padStyle="head" nxsd:paddedBy="0"> <xsd:simpleType><xsd:restriction base="xsd:string"> <xsd:maxLength value="10" /> </xsd:restriction> </xsd:simpleType> </xsd:element>
        <xsd:element name="country" nxsd:style="fixedLength" nxsd:length="5" nxsd:padStyle="head" nxsd:paddedBy="0"> <xsd:simpleType><xsd:restriction base="xsd:string"> <xsd:maxLength value="5" /> </xsd:restriction> </xsd:simpleType> </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

</xsd:schema>
<!--NXSDWIZ:C:\tmp\sample.dat:-->
<!--USE-HEADER:false:-->



The classes related to nXSD are in C:\Oracle\Middleware\Oracle_OSB1\soa\modules\oracle.soa.fabric_11.1.1\bpm-infra.jar

and in C:\Oracle\Middleware\Oracle_SOA1\jlib\oracle.soa.dbutils.jar

3 comments:

nags said...

How does the xsd get generated ? I don't find any macros in spreasheet. Kindly share.

vernetto said...

hi nags, there are no macros, only formulas.... actually in the formula I simply use "&" which is "chain 2 strings"

vernetto said...

hi nags, there are no macros, only formulas.... actually in the formula I simply use "&" which is "chain 2 strings"