views:

47

answers:

1

I have the following file structure (XML files 'index.xml' in nested folders):

index.xml
foo/index.xml
foo/sub/index.xml
foo/.../index.xml
bar/.../index.xml

Now I have to transform each of this XML files with a given XSL stylesheet. The result should be the same folder structure (overwriting would be OK). What would be your approach to achieve this?

My system: OS X 10.6, Saxon XSLT processor

+1  A: 

Using Bash How about putting the find command in a file and make the file executable:

find . -iname "*.xml" -exec transformcommand {} \;

(The {} will be replaced with the found file.)

Using Ant If you want something more platform independent you could write a simple Ant task for it. Have a look at the Ant XSLT Task, which could be combined with the <for>-tag.

Example:

<xslt in="input.xml"
      out="output.txt"
      style="thexsltfile.xsl"
      force="true"
      classPath="lib/saxon9.jar"/>
aioobe
Thanks for your help. The ant solution works perfectly for me!
Myniva