Showing posts with label NFB. Show all posts
Showing posts with label NFB. Show all posts

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

Tuesday, December 21, 2010

JDeveloper, SOA Suite, File Adapter, Native Format Builder: Unable to generate native format

Still investigating the issue.... how frustrating....wasted one hour on this....

I was unimpressed by the MFL in Eclipse/OSB spitting NullPointerException when the input data contains "invalid" characters, but now NFB is also putting my patience at test....

It turned out that, when you let the wizard decide the field names and types, it leaves the last one undefined - in case it was empty in the sample file. If you manually set the type to string. the wizard is able to complete successfully. What a great error handling!