Batch XSLT Transformation, find | xarg xsltproc

走远了吗. 提交于 2019-12-25 06:31:15

问题


I'd like to recursively find every "foo.xml" file and on each foo.xml apply the xslt bar.xsl and save over the original foo.xml. When I run the following commands, separately, they work.

find . -name foo.xml
xsltproc -o foo.xml bar.xsl foo.xml

But, when I pipe them, nothing happens to foo.xml.

find . -name foo.xml | xargs xsltproc -o foo.xml bar.xsl

I think I'm missing something simple... Thanks, in advanced.


回答1:


Warning both of these will obviously overwrite the xml's with the transformation as asked in the question.

With xargs you want to do something like

find . -name foo.xml -print0 | xargs -I {} -0 xsltproc -o {} transform.xsl {}

Or with -exec

find . -name foo.xml -exec  xsltproc -o {} transform.xsl {} \;


来源:https://stackoverflow.com/questions/22794421/batch-xslt-transformation-find-xarg-xsltproc

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