jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r169281 - /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java
Date Mon, 09 May 2005 11:10:10 GMT
Author: sylvain
Date: Mon May  9 04:10:08 2005
New Revision: 169281

URL: http://svn.apache.org/viewcvs?rev=169281&view=rev
Log:
Fix namespace-related issues that appear in some configurations by using DocumentBuilder rather
than an identity transform

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java?rev=169281&r1=169280&r2=169281&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/DOMWalker.java Mon
May  9 04:10:08 2005
@@ -20,6 +20,9 @@
 import java.io.InputStream;
 import java.util.Properties;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
@@ -33,6 +36,7 @@
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
 
 /**
  * Document walker class. This class provides an intuitive
@@ -41,8 +45,10 @@
 public final class DOMWalker {
 
     /** Static factory for creating stream to DOM transformers. */
-    private static final TransformerFactory factory =
-        TransformerFactory.newInstance();
+//    private static final TransformerFactory factory =
+//        TransformerFactory.newInstance();
+    private static final DocumentBuilderFactory factory =
+        DocumentBuilderFactory.newInstance();
 
     /** The DOM document being traversed by this walker. */
     private final Document document;
@@ -60,13 +66,13 @@
      */
     public DOMWalker(InputStream xml) throws IOException {
         try {
-            DOMResult result = new DOMResult();
-            Transformer transformer = factory.newTransformer();
-            transformer.transform(new StreamSource(xml), result);
-            document = (Document) result.getNode();
+            DocumentBuilder builder = factory.newDocumentBuilder();
+            document = builder.parse(xml);
             current = document.getDocumentElement();
-        } catch (TransformerException e) {
-            throw new IOException(e.getMessage());
+        } catch (IOException e) {
+            throw e;
+        } catch (Exception e) {
+            throw (IOException)new IOException(e.getMessage()).initCause(e);
         }
     }
 



Mime
View raw message