You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2011/10/27 10:58:33 UTC

svn commit: r1189684 - in /camel/branches/camel-2.8.x: ./ camel-core/src/main/java/org/apache/camel/builder/xml/ camel-core/src/main/java/org/apache/camel/converter/jaxp/ components/camel-saxon/src/main/java/org/apache/camel/component/xquery/

Author: davsclaus
Date: Thu Oct 27 08:58:32 2011
New Revision: 1189684

URL: http://svn.apache.org/viewvc?rev=1189684&view=rev
Log:
CAMEL-4588: Converting to DOMSource should accept Node instead of Document, as it can then accept more types.

Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java
    camel/branches/camel-2.8.x/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 27 08:58:32 2011
@@ -1 +1 @@
-/camel/trunk:1186106,1186625,1186772,1187221,1187485,1187882,1187893,1188070-1188085,1188642,1188674,1188879,1188881,1189600
+/camel/trunk:1186106,1186625,1186772,1187221,1187485,1187882,1187893,1188070-1188085,1188642,1188674,1188879,1188881,1189600,1189681

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java?rev=1189684&r1=1189683&r2=1189684&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java Thu Oct 27 08:58:32 2011
@@ -37,7 +37,7 @@ import javax.xml.transform.sax.SAXSource
 import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamSource;
 
-import org.w3c.dom.Document;
+import org.w3c.dom.Node;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.ExpectedBodyTypeException;
@@ -385,7 +385,9 @@ public class XsltBuilder implements Proc
             return false;
         } else if (body instanceof String) {
             return false;
-        } else if (body instanceof Document) {
+        } else if (body instanceof byte[]) {
+            return false;
+        } else if (body instanceof Node) {
             return false;
         }
 

Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java?rev=1189684&r1=1189683&r2=1189684&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java Thu Oct 27 08:58:32 2011
@@ -172,21 +172,22 @@ public class XmlConverter {
     }
 
     /**
-     * Converts the given Document to a Source
+     * Converts the given Node to a Source
+     * @deprecated  use toDOMSource instead
      */
-    @Converter
-    public DOMSource toDOMSource(Document document) {
-        return new DOMSource(document);
+    @Deprecated
+    public Source toSource(Node node) {
+        return toDOMSource(node);
     }
 
     /**
      * Converts the given Node to a Source
      */
     @Converter
-    public Source toSource(Node node) {
+    public DOMSource toDOMSource(Node node) {
         return new DOMSource(node);
     }
-    
+
     /**
      * Converts the given String to a Source
      */
@@ -331,7 +332,6 @@ public class XmlConverter {
         return toSAXSource(toSource(source), exchange);
     }
 
-    
     /**
      * Converts the source instance to a {@link StAXSource} or returns null if the conversion is not
      * supported (making it easy to derive from this class to add new kinds of conversion).
@@ -344,6 +344,17 @@ public class XmlConverter {
     }    
     
     /**
+     * Converts the source instance to a {@link StAXSource} or returns null if the conversion is not
+     * supported (making it easy to derive from this class to add new kinds of conversion).
+     * @throws XMLStreamException
+     */
+    @Converter
+    public StAXSource toStAXSource(byte[] in, Exchange exchange) throws XMLStreamException {
+        XMLStreamReader r = new StaxConverter().createXMLStreamReader(new ByteArrayInputStream(in), exchange);
+        return new StAXSource(r);
+    }
+
+    /**
      * Converts the source instance to a {@link SAXSource} or returns null if the conversion is not
      * supported (making it easy to derive from this class to add new kinds of conversion).
      *
@@ -362,8 +373,16 @@ public class XmlConverter {
     public SAXSource toSAXSource(InputStream source, Exchange exchange) throws IOException, SAXException, TransformerException {
         return toSAXSource(toStreamSource(source), exchange);
     }
-    
-    
+
+    /**
+     * Converts the source instance to a {@link SAXSource} or returns null if the conversion is not
+     * supported (making it easy to derive from this class to add new kinds of conversion).
+     */
+    @Converter
+    public SAXSource toSAXSource(byte[] in, Exchange exchange) throws IOException, SAXException, TransformerException {
+        return toSAXSource(toStreamSource(in, exchange), exchange);
+    }
+
     /**
      * Converts the source instance to a {@link StAXSource} or returns null if the conversion is not
      * supported (making it easy to derive from this class to add new kinds of conversion).
@@ -639,6 +658,7 @@ public class XmlConverter {
     public DOMSource toDOMSourceFromSAX(SAXSource source) throws IOException, SAXException, ParserConfigurationException, TransformerException {
         return new DOMSource(toDOMNodeFromSAX(source));
     }
+
     @Converter
     public DOMSource toDOMSourceFromStAX(StAXSource source) throws IOException, SAXException, ParserConfigurationException, TransformerException {
         return new DOMSource(toDOMNodeFromStAX(source));
@@ -650,6 +670,7 @@ public class XmlConverter {
         toResult(source, result);
         return result.getNode();
     }
+
     @Converter
     public Node toDOMNodeFromStAX(StAXSource source) throws ParserConfigurationException, IOException, SAXException, TransformerException {
         DOMResult result = new DOMResult();

Modified: camel/branches/camel-2.8.x/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java?rev=1189684&r1=1189683&r2=1189684&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java (original)
+++ camel/branches/camel-2.8.x/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java Thu Oct 27 08:58:32 2011
@@ -527,7 +527,9 @@ public abstract class XQueryBuilder impl
             return false;
         } else if (body instanceof String) {
             return false;
-        } else if (body instanceof Document) {
+        } else if (body instanceof byte[]) {
+            return false;
+        } else if (body instanceof Node) {
             return false;
         }