How to switch bewteen differenct JAXP?

 How to switch bewteen differenct JAXP

 1 JAXP in Sun JDK uses the implementation from Apache Xerces by default. But we can change it by setting the system properties.   
         1.1 How to use the Oracle JAXP implementation?
                 1.1.1 Find the jar - JDEVELOPER_HOME/lib/xmlparserv2.jar
                 1.1.2 Put the jar in the classpath.  
                 1.1.3 Set the system variants in the JVM startup.  
                        -Djavax.xml.transform.TransformerFactory=oracle.xml.jaxp.JXSAXTransformerFactory  
                        -Djavax.xml.parsers.SAXParserFactory=oracle.xml.jaxp.JXSAXParserFactory  
                        -Djavax.xml.parsers.DocumentBuilderFactory=oracle.xml.jaxp.JXDocumentBuilderFactory
         1.2 How to use the apache xerces JAXP implementation?
                -Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
                -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
                -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
 
 2 How to use the CDATA section to store the raw data in xml file? With the CDATA section, parser or builder encapsulate the raw data within <![CDATA[ and ]] theorially. But for different implementations, it leads to differenct results. Sometimes it decides if it should encapsulate the raw data based on if it is necesary. Sometimes the raw data are legal from the start, so it ignores it. Sometimes not.   
        2.1 Program:
                Element eTemp = document.createElement("value");
                String sValue = "test-legal";
                Node nodeValue = document.createCDATASection(vlaue);
                eTemp.appendChild(nodeValue);
        2.2 Result:
 
                Apache JAXP Impl - Windows  
                <![CDATA[test-legal]]
         
                Apache JAXP Impl - Linux  
                test-legal
         
                Oracle JAXP Impl - Windows  
                test-legal
 
                Oracle JAXP Impl - Linux  
                test-legal
 
        2.3 Program:
                Element eTemp = document.createElement("value");
                String sValue = "test-legal<><><>";
                Node nodeValue = document.createCDATASection(vlaue);
                eTemp.appendChild(nodeValue);
        2.4 Result:
 
                Apache JAXP Impl - Windows  
                <![CDATA[test-legal<><><>]]
 
                Apache JAXP Impl - Linux  
                <![CDATA[test-legal<><><>]]
 
                Oracle JAXP Impl - Windows  
                <![CDATA[test-legal&lt;&gt;&lt;>&lt;&gt;]]
 
                Oracle JAXP Impl - Linux  
                <![CDATA[test-legal&lt;&gt;&lt;>&lt;&gt;]]

       
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值