camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: git commit: CAMEL-7130 XsltBuilder uses the StaxSource by default
Date Thu, 23 Jan 2014 02:55:57 GMT
Hi Dan,

You are right, I did some test (by running the example inside Karaf) and confirmed Xalan 2.7.1
doesn’t support StaxSource. I will keep digging the code to find a better solution for
it.

Regards,

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com(http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com(http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On January 22, 2014 at 9:21:03 PM, Daniel Kulp (dkulp@apache.org) wrote:
>  
>  
> Willem,
>  
> Can you try these changes with Xalan 2.7.1 on the class path? Possibly  
> in OSGi with the Xalan 2.7.1 bundle?
>  
> I don’t think Xalan actually supports StaxSource. I believe  
> the in-jdk transformer does, but Xalan doesn’t. It would be good  
> to double check and then see if we can detect it and provide a work  
> around if there is a problem.
>  
> Dan
>  
>  
> On Jan 22, 2014, at 2:57 AM, ningjiang@apache.org wrote:
>  
> > Updated Branches:
> > refs/heads/master 9bedde2ca -> cc192f87b
> >
> >
> > CAMEL-7130 XsltBuilder uses the StaxSource by default
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/camel/repo  
> > Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cc192f87  
> > Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cc192f87  
> > Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cc192f87  
> >
> > Branch: refs/heads/master
> > Commit: cc192f87b7c4a43c6cff0646486384c9946e2ac9
> > Parents: 9bedde2
> > Author: Willem Jiang  
> > Authored: Wed Jan 22 15:57:23 2014 +0800
> > Committer: Willem Jiang  
> > Committed: Wed Jan 22 15:57:23 2014 +0800
> >
> > ----------------------------------------------------------------------  
> > .../apache/camel/builder/xml/XsltBuilder.java | 3 ---  
> > .../camel/component/xslt/XsltDTDTest.java | 20 ++++++++++++++++--  
> > .../camel/component/xslt/SaxonXsltDTDTest.java | 22 ++++++++++++++++++--  
> > 3 files changed, 38 insertions(+), 7 deletions(-)
> > ----------------------------------------------------------------------  
> >
> >
> > http://git-wip-us.apache.org/repos/asf/camel/blob/cc192f87/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
 
> > ----------------------------------------------------------------------  
> > diff --git a/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java
 
> b/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java  
> > index 3a7b9a4..d4291b2 100644
> > --- a/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java  
> > +++ b/camel-core/src/main/java/org/apache/camel/builder/xml/XsltBuilder.java  
> > @@ -452,9 +452,6 @@ public class XsltBuilder implements Processor  
> {
> > return (Source) body;
> > }
> > Source source = null;
> > - if (body instanceof InputStream) {
> > - return new StreamSource((InputStream)body);
> > - }
> > if (body != null) {
> > if (isAllowStAX()) {
> > source = exchange.getContext().getTypeConverter().tryConvertTo(StAXSource.class,
 
> exchange, body);
> >
> > http://git-wip-us.apache.org/repos/asf/camel/blob/cc192f87/camel-core/src/test/java/org/apache/camel/component/xslt/XsltDTDTest.java
 
> > ----------------------------------------------------------------------  
> > diff --git a/camel-core/src/test/java/org/apache/camel/component/xslt/XsltDTDTest.java
 
> b/camel-core/src/test/java/org/apache/camel/component/xslt/XsltDTDTest.java  
> > index b66d62d..db5d63c 100644
> > --- a/camel-core/src/test/java/org/apache/camel/component/xslt/XsltDTDTest.java
 
> > +++ b/camel-core/src/test/java/org/apache/camel/component/xslt/XsltDTDTest.java
 
> > @@ -16,6 +16,7 @@
> > */
> > package org.apache.camel.component.xslt;
> >
> > +import java.io.InputStream;
> > import java.util.List;
> >
> > import javax.xml.transform.TransformerException;
> > @@ -25,15 +26,28 @@ import org.apache.camel.ContextTestSupport;  
> > import org.apache.camel.Exchange;
> > import org.apache.camel.builder.RouteBuilder;
> > import org.apache.camel.component.mock.MockEndpoint;  
> > +import org.apache.camel.converter.IOConverter;
> > +import org.apache.camel.impl.DefaultExchange;
> >
> >
> > public class XsltDTDTest extends ContextTestSupport {
> > + private static final String MESSAGE =
> > + "]>&xxe;";  
> >
> > - public void testSendEntityMessage() throws Exception {  
> > + public void testSendingStringMessage() throws Exception  
> {
> > + sendEntityMessage(MESSAGE);
> > + }
> > +
> > + public void testSendingInputStreamMessage() throws Exception  
> {
> > + InputStream is = IOConverter.toInputStream(MESSAGE, new  
> DefaultExchange(context));
> > + sendEntityMessage(is);
> > + }
> > +
> > + private void sendEntityMessage(Object message) throws  
> Exception {
> >
> > MockEndpoint endpoint = getMockEndpoint("mock:result");  
> > + endpoint.reset();
> > endpoint.expectedMessageCount(1);
> > - String message = "]>&xxe;";  
> >
> > template.sendBody("direct:start1", message);
> >
> > @@ -44,6 +58,8 @@ public class XsltDTDTest extends ContextTestSupport  
> {
> > String xml = exchange.getIn().getBody(String.class);
> > assertTrue("Get a wrong transformed message", xml.indexOf("> subject=\"\">")
> 0);
> >
> > +
> > +
> > try {
> > template.sendBody("direct:start2", message);
> > fail("Expect an exception here");
> >
> > http://git-wip-us.apache.org/repos/asf/camel/blob/cc192f87/components/camel-saxon/src/test/java/org/apache/camel/component/xslt/SaxonXsltDTDTest.java
 
> > ----------------------------------------------------------------------  
> > diff --git a/components/camel-saxon/src/test/java/org/apache/camel/component/xslt/SaxonXsltDTDTest.java
 
> b/components/camel-saxon/src/test/java/org/apache/camel/component/xslt/SaxonXsltDTDTest.java
 
> > index 30802ff..b826608 100644
> > --- a/components/camel-saxon/src/test/java/org/apache/camel/component/xslt/SaxonXsltDTDTest.java
 
> > +++ b/components/camel-saxon/src/test/java/org/apache/camel/component/xslt/SaxonXsltDTDTest.java
 
> > @@ -16,6 +16,7 @@
> > */
> > package org.apache.camel.component.xslt;
> >
> > +import java.io.InputStream;
> > import java.util.List;
> >
> > import javax.xml.transform.TransformerException;
> > @@ -24,18 +25,33 @@ import org.apache.camel.CamelExecutionException;  
> > import org.apache.camel.Exchange;
> > import org.apache.camel.builder.RouteBuilder;
> > import org.apache.camel.component.mock.MockEndpoint;  
> > +import org.apache.camel.converter.IOConverter;
> > +import org.apache.camel.impl.DefaultExchange;
> > import org.apache.camel.test.junit4.CamelTestSupport;  
> > import org.junit.Test;
> >
> >
> > public class SaxonXsltDTDTest extends CamelTestSupport  
> {
> >
> > + private static final String MESSAGE =
> > + "]>&xxe;";  
> > +
> > + @Test
> > + public void testSendingStringMessage() throws Exception  
> {
> > + sendEntityMessage(MESSAGE);
> > + }
> > +
> > @Test
> > - public void testSendEntityMessage() throws Exception {  
> > + public void testSendingInputStreamMessage() throws Exception  
> {
> > + InputStream is = IOConverter.toInputStream(MESSAGE, new  
> DefaultExchange(context));
> > + sendEntityMessage(is);
> > + }
> > +
> > + private void sendEntityMessage(Object message) throws  
> Exception {
> >
> > MockEndpoint endpoint = getMockEndpoint("mock:result");  
> > + endpoint.reset();
> > endpoint.expectedMessageCount(1);
> > - String message = "]>&xxe;";  
> >
> > template.sendBody("direct:start1", message);
> >
> > @@ -46,6 +62,8 @@ public class SaxonXsltDTDTest extends CamelTestSupport  
> {
> > String xml = exchange.getIn().getBody(String.class);
> > assertTrue("Get a wrong transformed message", xml.indexOf("> subject=\"\">")
> 0);
> >
> > +
> > +
> > try {
> > template.sendBody("direct:start2", message);
> > fail("Expect an exception here");
> >
>  
> --
> Daniel Kulp
> dkulp@apache.org - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
>  
>  


Mime
View raw message