javax.xml.Transformを使用すると、変換されたxmlファイルにxml:base属性が含まれます。これがシナリオです。
サンプルXMLファイル:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE security [
<!ENTITY attachparam SYSTEM "attach-value.xml">
<!ENTITY udf SYSTEM "udfasset.xml">
]>
<property>
&attachparam;
</property>
attach-value.xml
<value regex=".+">localhost</value>
<value regex="^[A-Z]+">allow</value>
出力:
<?xml version="1.0" encoding="UTF-8" standalone="no">
<property>
<value regex=".+" xml:base="file:///home/bharathi/attach-value.xml">localhost</value>
<value regex="^[A-Z]+" xml:base="file:///home/bharathi/attach-value.xml">allow</value>
</property>
Javaコード:
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(document);
String tempFile = "/home/bharathi/out.xml";
LOGGER.log(Level.INFO, "tempFile is :: " + tempFile);
StreamResult result = new StreamResult(new File(tempFile));
transformer.transform(source, result);
変換時にxml:base属性を除外するにはどうすればよいですか?