XSLT:转换XML文件树 [英] XSLT: Transform XML files tree

查看:62
本文介绍了XSLT:转换XML文件树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下文件结构(嵌套文件夹中的XML文件'index.xml'):

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

现在,我必须使用给定的XSL样式表转换每个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?

我的系统:OS X 10.6,Saxon XSLT处理器

My system: OS X 10.6, Saxon XSLT processor

推荐答案

使用Bash 如何将find命令放入文件并使文件可执行:

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.)

使用Ant 如果您想要更独立于平台的内容,则可以为其编写一个简单的Ant任务.查看 Ant XSLT任务,可以将其与<一个href ="http://ant-contrib.sourceforge.net/tasks/tasks/for.html" rel ="nofollow noreferrer">< for>-标记.

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.

示例:

<xslt in="input.xml"
      out="output.txt"
      style="thexsltfile.xsl"
      force="true"
      classPath="lib/saxon9.jar"/>

这篇关于XSLT:转换XML文件树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆