3

フォーマットされていないXMLは、ビルドの問題です。主にインデントが不十分な場合に、XMLドキュメントのスタイルチェックを含めたいと思います。

使用するのに最適なツールは何ですか?(ビルドはAntを使用します)。

4

2 に答える 2

1

XML を自動的に変換してインデントするクラスを作成できます。次に、実行する XML ファイルを Ant で指定するだけです。

始めるための何か:

String filePath = "test.xml";
String outputFilePath = "testOut.xml";

File xmlFile = new File(filePath);
File outputXmlFile = new File(outputFilePath);

Transformer transformer = TransformerFactory.newInstance().newTransformer();

transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3");

StreamSource ss = new StreamSource(xmlFile);
StreamResult sr = new StreamResult(outputXmlFile);      

transformer.transform(ss, sr);
于 2011-11-10T06:34:33.220 に答える