Re: [xsl] Multiple file XSL conversion

Subject: Re: [xsl] Multiple file XSL conversion
From: JBryant@xxxxxxxxx
Date: Tue, 28 Jun 2005 15:07:35 -0500
Hi, Andrew,

If you just want to apply the stylesheet to each file in turn, it's a more 
or less (depending on your operating system) simple scripting problem. If 
you want to stick purely to XML and XSL, you can create a list of the 
files in an XML file, open it with the document function from your 
stylesheet, and then open each file with the document function, process 
the document, and write out the transformed content. In the latter case, 
you'll need XSLT2.0 (for the xsl:result-document instruction) or an 
extension that lets you write files in XSLT 1.0.

The general pattern looks like:

<xsl:for-each select="document('filelist.xml')/filename">
  <xsl:result-document href="someoutputname">
    <xsl:apply-templates/>
  </xsl:result-document>
</xsl:for-each>

You can get fancier by writing an extension function to read the contents 
of a directory. Then your controlling XML file can be a list of 
directories rather than a list of files. I recently did this because I 
couldn't know in advance which files to read from which directories.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)





Andrew Borsz <andrew@xxxxxxxxxxxxxxx> 
06/28/2005 02:53 PM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
[xsl] Multiple file XSL conversion






Hello,
I'm trying to figure out a good way to convert multiple XML files at 
the same time. Does anyone know the best way to take hundreds XML 
documents and transform them all with the same XSL stylesheet in one or 
two steps?

Any advice would be appreciated.

Thanks,

Andrew Borsz

Current Thread