On 09/01/2008, jpcook <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have a simple routebuilder configured to read an xml message from a JMS
> and then split the message:
>
> from("seda:horseRacingResults_all_finished_ceefax")
> .splitter(xpath("/myXml")).convertBodyTo(String.class)
> .setBody(groovy("'<myNewXml>'+request.body+'</myNewXml>'"))
> .to("mock:afterSplit");
>
> It seems that the groovy component doesn't like xml bodies so I have
> converted it to a String. However in the source xml message there are
> escaped characters such as: ΒΌ fraction 1/4 ¼ ¼ which I need to
> preserve. I wondered if convertBodyTo(String.class) should escape
> characters?
You probably need to XML-encode the request.body in the Groovy
expression when making some XML (as the convertTo(String.class) could
generate some valid XML).
You could always write a little helper method to do the conversion in
Java if you like...
from("seda:horseRacingResults_all_finished_ceefax")
.splitter(xpath("/myXml")).beanRef("myBean").
.to("mock:afterSplit");
where you register "myBean" as...
public class MyBean {
public String toXml(String body) {
return "'<myNewXml>" + someEncodeMethod(body) + "</myNewXml>'";
}
}
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com