为XML元素添加ID

首先下载Apache xalan,http://xml.apache.org/xalan-j/downloads.html

使用windows命令行模式,因为我没有设置java path,所以使用了如下的命令行:

java -cp xalan.jar;serializer.jar;xml-apis.jar;xercesImpl.jar org.apache.xalan.xslt.Process -IN books.xml -XSL idmaker2.xsl -OUT test.xml

其中IN后面是你要转化的源文件

XSL后面是XSLT文件

OUT是输出文件

参考:

http://xml.apache.org/xalan-j/commandline.html

http://lab.tojio.com/2009/03/06/unique-id-for-each-node-in-an-xml-file-en/

http://www.stylusstudio.com/xsllist/200512/post30240.html

http://www.roseindia.net/xml/dom/

原文地址:https://www.cnblogs.com/ainima/p/6331354.html