Parse several XML-files with batch

243 views Asked by At

I want to parse several/all files in a specific folder.

I usually parse my files like this:

java -jar saxon9he.jar -o:index.html -s:File.xml -xsl:Stylesheet.xslt
pause

Is there a way I can parse more than one file at once?

I tried something like this, but it won't work

java -jar saxon9he.jar -o:index.html -s:Folder/*.xml -xsl:Stylesheet.xslt
pause
2

There are 2 answers

0
Eduardo Yáñez Parareda On BEST ANSWER

You can't use wildcards to identify the files. If you want to parse several files, you must put all of them in a directory, then use -s:path_to_directory option along with -o:path_to_output_file option.

Doing this you'll parse all the files in the chosen directory.

0
Michael Kay On

The other (and more flexible) way of doing it is to control the processing from within the stylesheet, along the lines of:

<xsl:apply-templates select="collection('folder/?select=*.xml;recurse=yes')" mode="one-doc"/>

<xsl:template match="/" mode="one-doc">
  <xsl:result-document href="out/{....}.xml">
    ....
  </xsl:result-document>
</xsl:template>