XML Transformer排除param xml:base

时间:2012-09-24 09:58:15

标签: java xml xml-parsing

使用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>    

附-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属性?

0 个答案:

没有答案