私はこのXMLファイルを持っています
<test> 
 <</test>
そして、私は以下のJavaコードでそれを変換しています.xsltファイルはxmlのコピーを作成するだけです.
public class XMLTransform {
public static void main(String[] args) {
try {
StreamSource source = new StreamSource(new File("file.xml"));
StreamSource stylesource = new StreamSource(new File("trans.xsl"));
SAXTransformerFactory transformFactory = (SAXTransformerFactory) TransformerFactory.newInstance();
Transformer transformer = transformFactory.newTransformer(stylesource);
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
StreamResult result = new StreamResult(System.out);
transformer.transform(source,result);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
私の問題は、Java が正規のキャリッジ リターン をアスキー文字である に置き換えることです。
改行の正規名を保持する方法について何か助けはありますか?