jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r746603 - in /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons: AbstractSession.java xml/Exporter.java
Date Sat, 21 Feb 2009 23:43:21 GMT
Author: jukka
Date: Sat Feb 21 23:43:21 2009
New Revision: 746603

URL: http://svn.apache.org/viewvc?rev=746603&view=rev
Log:
JCR-1952: DOMException: NAMESPACE_ERR thrown when exporting document view

Use the new XML serializer classes instead of the JAXP-based SerializingContentHandler for
serializing JCR export formats

Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java?rev=746603&r1=746602&r2=746603&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java
Sat Feb 21 23:43:21 2009
@@ -34,18 +34,13 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
 
 import org.apache.jackrabbit.commons.xml.DocumentViewExporter;
 import org.apache.jackrabbit.commons.xml.Exporter;
 import org.apache.jackrabbit.commons.xml.ParsingContentHandler;
 import org.apache.jackrabbit.commons.xml.SystemViewExporter;
+import org.apache.jackrabbit.commons.xml.ToXmlContentHandler;
+import org.apache.jackrabbit.commons.xml.XmlnsContentHandler;
 import org.apache.jackrabbit.util.XMLChar;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
@@ -279,7 +274,8 @@
             boolean skipBinary, boolean noRecurse)
             throws IOException, RepositoryException {
         try {
-            ContentHandler handler = getExportContentHandler(out);
+            ContentHandler handler =
+                new XmlnsContentHandler(new ToXmlContentHandler(out));
             exportDocumentView(absPath, handler, skipBinary, noRecurse);
         } catch (SAXException e) {
             Exception exception = e.getException();
@@ -311,7 +307,8 @@
             boolean skipBinary, boolean noRecurse)
             throws IOException, RepositoryException {
         try {
-            ContentHandler handler = getExportContentHandler(out);
+            ContentHandler handler =
+                new XmlnsContentHandler(new ToXmlContentHandler(out));
             exportSystemView(absPath, handler, skipBinary, noRecurse);
         } catch (SAXException e) {
             Exception exception = e.getException();
@@ -465,35 +462,4 @@
         }
     }
 
-    /**
-     * Creates a {@link ContentHandler} instance that serializes the
-     * received SAX events to the given output stream.
-     *
-     * @param stream output stream to which the SAX events are serialized
-     * @return SAX content handler
-     * @throws RepositoryException if an error occurs
-     */
-    private ContentHandler getExportContentHandler(OutputStream stream)
-            throws RepositoryException {
-        try {
-            SAXTransformerFactory stf = (SAXTransformerFactory)
-                SAXTransformerFactory.newInstance();
-            TransformerHandler handler = stf.newTransformerHandler();
-
-            Transformer transformer = handler.getTransformer();
-            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
-            transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-            transformer.setOutputProperty(OutputKeys.INDENT, "no");
-
-            handler.setResult(new StreamResult(stream));
-            return handler;
-        } catch (TransformerFactoryConfigurationError e) {
-            throw new RepositoryException(
-                    "SAX transformer implementation not available", e);
-        } catch (TransformerException e) {
-            throw new RepositoryException(
-                    "Error creating an XML export content handler", e);
-        }
-    }
-
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java?rev=746603&r1=746602&r2=746603&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java
Sat Feb 21 23:43:21 2009
@@ -39,7 +39,6 @@
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.helpers.NamespaceSupport;
 
 /**
  * Abstract base class for document and system view exporters. This class
@@ -429,9 +428,6 @@
             String namespace = (String) entry.getKey();
             String prefix = (String) entry.getValue();
             handler.startPrefixMapping(prefix, namespace);
-            attributes.addAttribute(
-                    NamespaceSupport.XMLNS, prefix, "xmlns:" + prefix,
-                    "CDATA", namespace);
         }
 
         // Emit the start element event, and clear things for the next element



Mime
View raw message