How to switch bewteen differenct JAXP?
2008-07-23 17:42
309 查看
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<><><>]]
Oracle JAXP Impl - Linux
<![CDATA[test-legal<><><>]]
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<><><>]]
Oracle JAXP Impl - Linux
<![CDATA[test-legal<><><>]]
相关文章推荐
- How to switch bewteen differenct JAXP?
- play vim of how to switch to normal mode
- How to switch xcode on Mac?
- 25G Switch Vs. 40G Switch: How to Choose?
- How to switch off the automatic assignment of employee relationship
- how to find out the switch port by IP address
- How to switch trial to comercial license for HA without Internect connection on Nexenta
- How to switch a photo from jpg to png, and how to resize the photo for mac?
- 25G Switch Vs. 40G Switch: How to Choose?
- How to Install Open vSwitch on Linux
- How to reset password for cisco router and switch
- How to Programmatically Switch between the HubTile Visual States
- SDN00:How to Collect Switch Statistics (and Compute Bandwidth)
- How to implement switch statement in python
- LightSwitch how to realize two combobox linkage(如何实现2个下拉框联动)
- How to switch to the shell you want
- how to Customize Lightswitch beta 2 Login Screen to your Own design (如何定制LS的登录界面)
- How to Switch Between GDM and KDM on Ubuntu
- How to help people switch to Linux?
- How to Install Open vSwitch on Linux