RE: [xsl] Multiple file XSL conversion

Subject: RE: [xsl] Multiple file XSL conversion
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 28 Jun 2005 21:00:51 +0100
If the transformations are independent of each other, then it's best to
invoke the stylesheet once for each document, rather than doing it all in a
single transformation, because the XSLT processor is otherwise likely to try
and hold all the documents in memory.

So you need some kind of application program to invoke the transformation.
You haven't explained what environment you're using: in Java, you would use
the JAXP API to compile the stylesheet once into a Templates object, and
then go into a loop:

for (int i=0; i<files.length; i++) {
  transformer = templates.newTransformer();
  transformer.transform(new StreamSource(files[i]), new StreamResult(....));
}

If it's a one-off job you could do it from shellscript, but that would be
much less efficient.

I've just remembered that on Saturday in Prague I heard Petr Pajas
describing his XML Editing Shell XSH, which looks like a good tool for this
kind of job - I haven't tried it though. See http://xsh.sf.net/ It's fairly
heavily Perl-based so you'll probably like it most if you're already a Perl
user.

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


> -----Original Message-----
> From: Andrew Borsz [mailto:andrew@xxxxxxxxxxxxxxx] 
> Sent: 28 June 2005 20:53
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> 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