[xsl] Converting a Batch File to XML

Subject: [xsl] Converting a Batch File to XML
From: "Garvin Franco" <garvin_franco@xxxxxxxxxxx>
Date: Fri, 23 Jul 2004 15:31:11 -0400
Hello folks, looking for some insight here. Need to know if this is possible using XSLT. I prefer using a style sheet as I may use this style sheet in a Java,C++ and .NET environment.
I have a flat file that I need to convert to an XML structure. Now I can do this if the records in the file had the same structure, this is fairly simple. But my source fixed length file has mutliple records that need to be associated to a single node on the target xml. For example, my file is structured as follows...


FROM
Source: Fixed Length Data

H-A-HEADER........
I-AN-ITEM-1........
I-AN-ITEM-2........
S-A-SUMMARY-1..
I-AN-ITEM-3........
S-A-SUMMARY-2..

(Note: each record is on a new line)

TO
Target: XML Data

<someRoot>
<header>
<headerTag>A-HEADER</headerTag> <!-- note the header ID,'H',not transformed -->
</header>
<record>
<order>
<item>
<itemTag>AN-ITEM-1</itemTag> <!-- note the item ID,'I',not transformed -->
</item>
<item>
<itemTag>AN-ITEM-2</itemTag>
</item>
<summary>
<summaryTag>A-SUMMARY-1</summaryTag> <!-- note summary ID,'S',not transformed -->
</summary>
</order>
</record>
<record>
<order>
<item>
<itemTag>AN-ITEM-3</itemTag>
</item>
<summary>
<summaryTag>A-SUMMARY-2</summaryTag>
</summary>
</order>
<record>
</someRoot>


Would appreciate any thoughts or samples that you can provide to help me achieve this. I believe recursion will be needed here, right? Also, it may not be efficient to load the entire file into a variable, then start processing from there. These are some of the things I thought about, but I'm not to sure how to start.
Thanking you in advance for any ideas. Also, if this is not the forum for this, please advise...


Regards
Garvin

_________________________________________________________________
Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Current Thread