RE: [xsl] Processing multiple files

Subject: RE: [xsl] Processing multiple files
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 1 Sep 2004 16:00:34 +0100
I'm copying the reply off-list, but please don't take the conversation
off-list. If it's worth discussing the issue, it's worth placing the
discussion in the archives.

My instinct would be to write a Java application that walks around the
directory structures and invokes one transformation on each directory,
supplying the PubFile as the principal source document. The stylesheet can
then read the related Activity documents using the document() function. The
Java application then invokes a new transformation on the next directory to
create another output file.

You can compile the stylesheet once and use it repeatedly, which makes this
efficient.

If you don't want to write any Java code but are comfortable with shell
scripting, then you could do the same thing from a script, but it would
probably be far less efficient.

An alternative solution would be to write an extension function that allows
you to read the list of directories from your stylesheet (perhaps returning
the list of contents as an XML document) and then use the document()
function to process the individual files. With many processors this has the
drawback that all the documents will be held in memory - and you still have
to write Java code, if that's what you were trying to avoid.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Esther_Strom@xxxxxxxx [mailto:Esther_Strom@xxxxxxxx] 
> Sent: 01 September 2004 15:21
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Processing multiple files
> 
> 
> 
> 
> 
> Could anyone point me in the right direction as far as finding info on
> processing multiple files?
> 
> Background: We have a multi-system application that includes an art
> management system, content management system, and publisher 
> (to PDF). A new
> output format is being added, and I've been told that I need 
> to develop a
> stylesheet that can loop through a directory of files and 
> process each in
> turn, adding them to a single output file.
> 
> So, for example, I have DirectoryA, which contains PubFile1,
> ActivityFile1A, ActivityFile1B, PubFile2, ActivityFile2A, 
> ActivityFile2B.
> What I need to do is take a few pieces of info from PubFile1 
> and start an
> output file (Output1). Then, I need to loop through all related
> ActivityFile documents and add the output of those to the 
> Output1 file.
> When that is complete, I need to move on to PubFile2 and 
> create Output2,
> looping through the ActivityFile2 docs and adding their 
> output to Output2.
> 
> I'm very new to XSLT, and although I've gotten to be fairly 
> comfortable
> navigating through single input docs, I have no idea how to 
> go about this.
> Any help would be much appreciated (since I'm on the digest, 
> an off-list
> reply would be even more appreciated...)
> |------------------------------|
> | E S T H E R  S T R O M, CLPP |
> | Notes Application Development|
> | McDougal Littell             |
> | 909 Davis Street             |
> | Evanston, IL 60201 USA       |
> | w: 847.424.3209              |
> | e: esther_strom@xxxxxxxx     |
> |------------------------------|

Current Thread