xsl-list
[Top] [All Lists]

Using Saxon 8.5 and collection() to process a directory of XML fi les

2005-08-04 05:08:25

I've just had a requirement to process a directory of XML files, generating
10 output files per source XML file and placing them in a folder named the
same as the input file.  Mike mentioned in his annoucement email for Saxon
8.5 something along these lines, so I want to try and achieve it all in a
single stylesheet, rather then needing the host language.

So, given a folder of source XML files:

001.xml
002.xml
...
999.xml

The result of tranform should be a folder per XML file, named the same as
the XML file, with the 10 ouput files within it:

[001] <- folder
  first.html
  second.html
  ...
[002]
  first.html
  second.html
  ....

...
[999]
  first.html
  etc

I believe it's possible now to use the collection() function to get a
sequence of the input XML files.  Is it possible to get the filenames so
that I can create the corresponding output folder?

This is the code I think I need once I have the collection bit sorted (which
will wrap this code):

<xsl:for-each select="for $i in $outputFileNames return $i">
    <xsl:result-document href="{$dir}/{$folderName}/{.}.html">
        ....    
    </xsl:result-document>
</xsl:for-each>

$outputFileNames is the sequence of the 10 filenames eg 'first', 'second'
and so on.  $dir is the output folder.  $folderName needs to come from the
filename of the input XML - not sure if this is possible yet.

Once this is ready, I think the end user should be able to run this
stylesheet (with the correct path parameters but without any input XML) to
generate all of the necessary files.  It would be great to do all this in
the stylesheet, rather than requiring the host language to perform each
transform separately.

My question is - is this possible?

cheers
andrew

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>