You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Boba <bo...@gmail.com> on 2017/03/27 21:43:03 UTC

Camel 2.15.1 XSLT returning only the closing tags

I am trying to do a really simple xml to xml transformation using the xslt
uri, I have dumbed it down so the input and transformed messages are
basically the same to try and work this out...
I used stylus studio to create the xml to xml mapping (I'm not knowledgeable
in xslt) 
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<Message>
			<element1>
				<xsl:value-of select="Message/element_1"/>
			</element1>
			<element2>
				<xsl:choose>
					<xsl:when test="Message/Type = 1">Request</xsl:when>
					<xsl:otherwise>End</xsl:otherwise>
				</xsl:choose>
			</element2>
			<element3>
				<xsl:value-of select="Message/element_3"/>
			</element3>
			<element4>
				<xsl:value-of select="Message/element_4"/>
			</element4>
			<element5>
				<xsl:value-of select="Message/element_5"/>
			</SessionID>
			<element6>
				<xsl:value-of select="Message/element_6"/>
			</element6>
		</Message>
	</xsl:template>
</xsl:stylesheet>

It works well running camel standalone on my windows vm but when I deploy to
Tomcat7 on oracle java 8 (now and 7 previously) on ubuntu 14.04 32bit VM
server, the bulk of the response is just close tags i.e.

<?xml version="1.0" encoding="UTF-8"?>
<Message>
 <element1/>
 <element2>End</element2>
 <element3/>
 <element4/>
</Message>

I use the Camel spring XML DSL and am referencing the xsl files from the
local 

<to uri="xslt:file:///home/xsltfiles/ssTestsheet1.xsl"/>

There are a few posts that suggest a number of options including using the
xalan transformer factory
<to
uri="xslt:///home/xsltfiles/ssTestsheet1.xsl?transformerFactory=transformerFactory"/> 

or saxon
<to uri="xslt:///home/xsltfiles/ssTestsheet1.xsl?saxon=true"/> 

I added the relevant dependencies in my POM
        <dependency>
           <groupId>org.apache.camel</groupId>
           <artifactId>camel-saxon</artifactId>
           <version>${camel-version}</version>
         </dependency>

         <dependency>
           <groupId>xalan</groupId>
           <artifactId>xalan</artifactId>
           <version>2.7.1</version>
         </dependency>

I have also tried, as suggested by one post, converting the body to
java.io.InputStream just before the XSLT
<convertBodyTo type="java.io.InputStream"/>

So I have been at this solidly over the week-end and today... I can't see
what is wrong

Any help ...please




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-15-1-XSLT-returning-only-the-closing-tags-tp5796448.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel 2.15.1 XSLT returning only the closing tags

Posted by bob anderson <bo...@gmail.com>.
Hi Tomo.

Thanks for looking at my problem, I have changed the names etc..but the
input document does have values for all elements. Also when using camel
standalone all the values of the input document are populated in the output
document, it is when I deploy to Tomcat on Ubuntu that it returns empty
elements. I'll clean up the code to a few lines and post it later

Bob

On Tue, Mar 28, 2017 at 6:23 AM, Tomohisa Igarashi <tm...@gmail.com>
wrote:

> Hi,
>
> On 03/28/2017 06:43 AM, Boba wrote:
>
>> I am trying to do a really simple xml to xml transformation using the xslt
>> uri, I have dumbed it down so the input and transformed messages are
>> basically the same to try and work this out...
>> I used stylus studio to create the xml to xml mapping (I'm not
>> knowledgeable
>> in xslt)
>> <?xml version='1.0' ?>
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>>         <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
>>         <xsl:template match="/">
>>                 <Message>
>>                         <element1>
>>                                 <xsl:value-of select="Message/element_1"/>
>>                         </element1>
>>                         <element2>
>>                                 <xsl:choose>
>>                                         <xsl:when test="Message/Type =
>> 1">Request</xsl:when>
>>                                         <xsl:otherwise>End</xsl:otherw
>> ise>
>>                                 </xsl:choose>
>>                         </element2>
>>                         <element3>
>>                                 <xsl:value-of select="Message/element_3"/>
>>                         </element3>
>>                         <element4>
>>                                 <xsl:value-of select="Message/element_4"/>
>>                         </element4>
>>                         <element5>
>>                                 <xsl:value-of select="Message/element_5"/>
>>                         </SessionID>
>>                         <element6>
>>                                 <xsl:value-of select="Message/element_6"/>
>>                         </element6>
>>                 </Message>
>>         </xsl:template>
>> </xsl:stylesheet>
>>
>> It works well running camel standalone on my windows vm but when I deploy
>> to
>> Tomcat7 on oracle java 8 (now and 7 previously) on ubuntu 14.04 32bit VM
>> server, the bulk of the response is just close tags i.e.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <Message>
>>  <element1/>
>>  <element2>End</element2>
>>  <element3/>
>>  <element4/>
>> </Message>
>>
>
> This could be the correct output if the valued of Message/element_[134]
> are actually empty though, is your input really have those values?
>
> Thanks,
> Tomo
>
> I use the Camel spring XML DSL and am referencing the xsl files from the
>> local
>>
>> <to uri="xslt:file:///home/xsltfiles/ssTestsheet1.xsl"/>
>>
>> There are a few posts that suggest a number of options including using the
>> xalan transformer factory
>> <to
>> uri="xslt:///home/xsltfiles/ssTestsheet1.xsl?transformerFact
>> ory=transformerFactory"/>
>>
>> or saxon
>> <to uri="xslt:///home/xsltfiles/ssTestsheet1.xsl?saxon=true"/>
>>
>> I added the relevant dependencies in my POM
>>         <dependency>
>>            <groupId>org.apache.camel</groupId>
>>            <artifactId>camel-saxon</artifactId>
>>            <version>${camel-version}</version>
>>          </dependency>
>>
>>          <dependency>
>>            <groupId>xalan</groupId>
>>            <artifactId>xalan</artifactId>
>>            <version>2.7.1</version>
>>          </dependency>
>>
>> I have also tried, as suggested by one post, converting the body to
>> java.io.InputStream just before the XSLT
>> <convertBodyTo type="java.io.InputStream"/>
>>
>> So I have been at this solidly over the week-end and today... I can't see
>> what is wrong
>>
>> Any help ...please
>>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.
>> com/Camel-2-15-1-XSLT-returning-only-the-closing-tags-tp5796448.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>


-- 
Bob Anderson
+27 (0) 82 389 0335
[image: View my profile on LinkedIn]
<http://ng.linkedin.com/pub/bob-anderson/2/25/9b5>

Re: Camel 2.15.1 XSLT returning only the closing tags

Posted by Tomohisa Igarashi <tm...@gmail.com>.
Hi,

On 03/28/2017 06:43 AM, Boba wrote:
> I am trying to do a really simple xml to xml transformation using the xslt
> uri, I have dumbed it down so the input and transformed messages are
> basically the same to try and work this out...
> I used stylus studio to create the xml to xml mapping (I'm not knowledgeable
> in xslt)
> <?xml version='1.0' ?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
> 	<xsl:template match="/">
> 		<Message>
> 			<element1>
> 				<xsl:value-of select="Message/element_1"/>
> 			</element1>
> 			<element2>
> 				<xsl:choose>
> 					<xsl:when test="Message/Type = 1">Request</xsl:when>
> 					<xsl:otherwise>End</xsl:otherwise>
> 				</xsl:choose>
> 			</element2>
> 			<element3>
> 				<xsl:value-of select="Message/element_3"/>
> 			</element3>
> 			<element4>
> 				<xsl:value-of select="Message/element_4"/>
> 			</element4>
> 			<element5>
> 				<xsl:value-of select="Message/element_5"/>
> 			</SessionID>
> 			<element6>
> 				<xsl:value-of select="Message/element_6"/>
> 			</element6>
> 		</Message>
> 	</xsl:template>
> </xsl:stylesheet>
>
> It works well running camel standalone on my windows vm but when I deploy to
> Tomcat7 on oracle java 8 (now and 7 previously) on ubuntu 14.04 32bit VM
> server, the bulk of the response is just close tags i.e.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Message>
>  <element1/>
>  <element2>End</element2>
>  <element3/>
>  <element4/>
> </Message>

This could be the correct output if the valued of Message/element_[134] are actually empty though, is your input really have those values?

Thanks,
Tomo

> I use the Camel spring XML DSL and am referencing the xsl files from the
> local
>
> <to uri="xslt:file:///home/xsltfiles/ssTestsheet1.xsl"/>
>
> There are a few posts that suggest a number of options including using the
> xalan transformer factory
> <to
> uri="xslt:///home/xsltfiles/ssTestsheet1.xsl?transformerFactory=transformerFactory"/>
>
> or saxon
> <to uri="xslt:///home/xsltfiles/ssTestsheet1.xsl?saxon=true"/>
>
> I added the relevant dependencies in my POM
>         <dependency>
>            <groupId>org.apache.camel</groupId>
>            <artifactId>camel-saxon</artifactId>
>            <version>${camel-version}</version>
>          </dependency>
>
>          <dependency>
>            <groupId>xalan</groupId>
>            <artifactId>xalan</artifactId>
>            <version>2.7.1</version>
>          </dependency>
>
> I have also tried, as suggested by one post, converting the body to
> java.io.InputStream just before the XSLT
> <convertBodyTo type="java.io.InputStream"/>
>
> So I have been at this solidly over the week-end and today... I can't see
> what is wrong
>
> Any help ...please
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-2-15-1-XSLT-returning-only-the-closing-tags-tp5796448.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel 2.15.1 XSLT returning only the closing tags - content type issue (now)

Posted by Boba <bo...@gmail.com>.
OK, so its not the XSLT....

If i use the FILE uri to start the route the xml file is processed correctly
with XSLT URI and all the elements and values are correctly populated and
displayed.

BUT I was receiving the message using servlet and the body is of type
"text/plain"

I have been playing with convertBody - and I'm not having any luck
converting to xml

any ideas   



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-15-1-XSLT-returning-only-the-closing-tags-tp5796448p5796668.html
Sent from the Camel - Users mailing list archive at Nabble.com.