XSLT: Transform XML files tree

落爺英雄遲暮 提交于 2019-12-12 01:35:55

问题


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:


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"/>


来源:https://stackoverflow.com/questions/2765146/xslt-transform-xml-files-tree

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!