Thursday, November 14, 2024

#1042 - Processing Text Files in OIC

The use case is simple here - I've got a text file, cities.txt, I need to process in OIC. The file is as follows - 

The file structure is as follows - multiple city records, each with the following format - cityCode (4), countryCode (3), cityShortName(35), creationDate(10), cityLongName(60), nextUpdateDate(10).

  

I will require a native XSD (nXSD) to process this file. So where do I get such?

This is where my old buddy, a buddy I've long neglected, comes to my aid - JDeveloper. I've used JDev to create SOA Composites in the past and it does contain an nXSD generator.


Here is the nXSD it generated, based on the file above -

I created a new project in JDeveloper and included my cities.txt file.

The NXSD Schema wizard uses the text file as input - 





I then use the ruler to specify the field lengths - 

The result is as follows, I did change the default element names - 

<xsd:element name="Cities">

    <xsd:complexType>

      <xsd:sequence>

        <xsd:element name="City" minOccurs="1" maxOccurs="unbounded" nxsd:style="array" nxsd:cellSeparatedBy="${eol}">

          <xsd:complexType>

            <xsd:sequence>

              <xsd:element name="cityCode" type="xsd:string" nxsd:style="fixedLength" nxsd:length="4"/>

              <xsd:element name="countryCode" type="xsd:string" nxsd:style="fixedLength" nxsd:length="3"/>

              <xsd:element name="cityShort" type="xsd:string" nxsd:style="fixedLength" nxsd:length="35"/>

              <xsd:element name="creationDate" type="xsd:string" nxsd:style="fixedLength" nxsd:length="10"/>

              <xsd:element name="cityLong" type="xsd:string" nxsd:style="fixedLength" nxsd:length="60"/>

              <xsd:element name="nextUpdateDate" type="xsd:string" nxsd:style="fixedLength" nxsd:length="10"/>

            </xsd:sequence>

          </xsd:complexType>

        </xsd:element>

      </xsd:sequence>

    </xsd:complexType>

  </xsd:element>

Now to leveraging this in OIC - I copy the file to a OIC File Server folder -

The flow of the integration is as follows - 

ListFile is configured as follows - 
GetFileRef is configured as follows - 

filename is passed via the MAP action - 



ReadFile is configured as follows - 


ForEach City is configured as follows - 

The Log Action - 

Activate and test - 

























 




 

No comments:

Post a Comment