Re: [xsl] Applying XSL transformation to non-xml (but fixed structure) file

Subject: Re: [xsl] Applying XSL transformation to non-xml (but fixed structure) file
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 02 Jun 2010 12:32:28 +0100
On 02/06/2010 11:32, Christian Schouten wrote:
Hi all,

I need to apply an XSL transformation to a non-xml file that has a fixed
structure.
The goal is to read in the file, add/edit/delete a record and write it
back.

A sample file (start to finish) is as below:

It's very hard to judge from one sample file what is the range of possible inputs that your program needs to deal with; in particular, whether you can get by with a simple line-by-line analysis using regular expressions, or whether you need to do full recursive parsing based on a BNF grammar. Superficially, it looks like the second case, but I might be misjudging. The answer to this question fundamentally affects the design approach you adopt. In the second case, I would recommend writing a parser for the input format (perhaps using a tool such as JavaCC) that converts it into XML, and then write the XSLT transformation to process the resulting XML.


Michael Kay
Saxonica

Current Thread