---
title: " How to switch bewteen differenct JAXP？"
author: "RobertLeeJesus"
date: "2008-07-25T21:42:43Z"
tags: []
categories: ["Web前端"]
slug: "how-to-switch-bewteen-differenct-jaxp"
draft: false
lastmod: "2008-07-25T21:42:43Z"
id: 219669
url: "https://hidefromall.iteye.com/blog/219669"
---

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 &lt;!\[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    
                &lt;!\[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&lt;&gt;&lt;&gt;&lt;&gt;";  
                Node nodeValue = document.createCDATASection(vlaue);  
                eTemp.appendChild(nodeValue);  
        2.4 Result:  
   
                Apache JAXP Impl - Windows    
                &lt;!\[CDATA\[test-legal&lt;&gt;&lt;&gt;&lt;&gt;]]  
   
                Apache JAXP Impl - Linux    
                &lt;!\[CDATA\[test-legal&lt;&gt;&lt;&gt;&lt;&gt;]]  
   
                Oracle JAXP Impl - Windows    
                &lt;!\[CDATA\[test-legal&lt;&gt;&lt;&gt;&lt;&gt;]]  
   
                Oracle JAXP Impl - Linux    
                &lt;!\[CDATA\[test-legal&lt;&gt;&lt;&gt;&lt;&gt;]]