Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to convert the TEXT file into an XML using plsql code

1029527Oct 24 2013 — edited Oct 24 2013

Hi all ,

I need to convert an TEXT file into an XML file how can i do it

Below is my sample TEXT file .

TDETL00000000020000000000000120131021115854ST2225SKU77598059          0023-000000010000

I want the above to be converted into the below format

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

<txt2xml>

  <!-- Processor splits text into lines -->

  <processor type="RegexDelimited">

  <regex>\n</regex>

        <!--

        This is used to specify that a message should be created per line in

        the incoming file;

        NOTE: this was designed to work with all the processors, however it

        only works correctly with 'RegexDelimited' processors (check the

        enclosing top processor type)

         -->

         <maxIterationsPerMsg>1</maxIterationsPerMsg>

  <!-- For lines beginning with FHEAD (File Header) -->

  <processor type="RegexMatch">

  <element>FHEAD</element>

  <regex>^FHEAD(.*)</regex>

  <processor type="RegexMatch">

  <element>OriginalLine</element>

  <regex>(.*)</regex>

  <consumeMatchedChars>false</consumeMatchedChars>

  </processor>

  <processor type="RegexMatch">

  <element>LineSeq,Type,Date</element>

  <regex>^(\d{10})(\w{4})(\d{14})$</regex>

  </processor>

  </processor>

  <!-- For lines beginning with TDETL (Transaction Details) -->

  <processor type="RegexMatch">

  <element>TDETL</element>

  <regex>^TDETL(.*)</regex>

  <processor type="RegexMatch">

  <element>OriginalLine</element>

  <regex>(.*)</regex>

  <consumeMatchedChars>false</consumeMatchedChars>

  </processor>

  <processor type="RegexMatch">

  <element>LineSeq,TransControlNumber,TransDate,LocationType,Location,ItemType,Item,UPCSupplement,InventoryStatus,AdjustReason,AdjustSign,AdjustQty</element>

  <regex>^(\d{10})(\d{14})(\d{14})(\w{2})(\d{4})(\w{3})([\w ]{13})([\w ]{5})(\d{2})(\d{2})([+-]{1})(\d{12})$</regex>

  </processor>

  </processor>

  <!-- For lines beginning with FTAIL (File Tail) -->

  <processor type="RegexMatch">

  <element>FTAIL</element>

  <regex>^FTAIL(.*)</regex>

  <processor type="RegexMatch">

  <element>OriginalLine</element>

  <regex>(.*)</regex>

  <consumeMatchedChars>false</consumeMatchedChars>

  </processor>

  <processor type="RegexMatch">

  <element>LineSeq,TransCount</element>

  <regex>^(\d{10})(\d{6})$</regex>

  </processor>

  </processor>

  </processor>

</txt2xml>

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 21 2013
Added on Oct 24 2013
1 comment
1,688 views