Author: ningjiang
Date: Wed Jan 30 05:26:02 2013
New Revision: 1440280

URL: http://svn.apache.org/viewvc?rev=1440280&view=rev
Log:
CAMEL-6020 Fixed the issue of Camel Transformer using inconsistent sources

Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java?rev=1440280&r1=1440279&r2=1440280&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
 Wed Jan 30 05:26:02 2013
@@ -456,26 +456,29 @@ public class XsltBuilder implements Proc
             return new StreamSource((InputStream)body);
         }
         if (body != null) {
-            TypeConverter tc = 
exchange.getContext().getTypeConverterRegistry().lookup(Source.class, 
body.getClass());
-            if (tc != null) {
-                source = tc.convertTo(Source.class, exchange, body);
+            if (isAllowStAX()) {
+                source = 
exchange.getContext().getTypeConverter().tryConvertTo(StAXSource.class, 
exchange, body);
+            }
+            if (source == null) {
+                // then try SAX
+                source = 
exchange.getContext().getTypeConverter().tryConvertTo(SAXSource.class, 
exchange, body);
+            }
+            if (source == null) {
+                // then try stream
+                source = 
exchange.getContext().getTypeConverter().tryConvertTo(StreamSource.class, 
exchange, body);
+            }
+            if (source == null) {
+                // and fallback to DOM
+                source = 
exchange.getContext().getTypeConverter().tryConvertTo(DOMSource.class, 
exchange, body);
+            }
+            // as the TypeConverterRegistry will look up source the converter 
differently if the type converter is loaded different
+            // now we just put the call of source converter at last
+            if (source == null) {
+                TypeConverter tc = 
exchange.getContext().getTypeConverterRegistry().lookup(Source.class, 
body.getClass());
+                if (tc != null) {
+                    source = tc.convertTo(Source.class, exchange, body);
+                }
             }
-        }
-
-        if (source == null && isAllowStAX()) {
-            source = 
exchange.getContext().getTypeConverter().tryConvertTo(StAXSource.class, 
exchange, body);
-        }
-        if (source == null) {
-            // then try SAX
-            source = 
exchange.getContext().getTypeConverter().tryConvertTo(SAXSource.class, 
exchange, body);
-        }
-        if (source == null) {
-            // then try stream
-            source = 
exchange.getContext().getTypeConverter().tryConvertTo(StreamSource.class, 
exchange, body);
-        }
-        if (source == null) {
-            // and fallback to DOM
-            source = 
exchange.getContext().getTypeConverter().tryConvertTo(DOMSource.class, 
exchange, body);
         }
         if (source == null) {
             if (isFailOnNullBody()) {


Reply via email to