Just a little tip. Be careful with concurrency as DOM is not thread-safe.

So if you've got multiple XPath expressions or XSLT transformations running
in parallel (e.g. multicast EIP), you might get errors.

Regards,
Raúl.

On Tue, Jul 30, 2013 at 10:16 AM, Jan Matèrne (jhm) <[email protected]>wrote:

> Thanks, I will try ...
>
> Jan
>
> > -----Ursprüngliche Nachricht-----
> > Von: Claus Ibsen [mailto:[email protected]]
> > Gesendet: Dienstag, 30. Juli 2013 11:09
> > An: [email protected]
> > Betreff: Re: XPath + DOM-reuse
> >
> > Hi
> >
> > You can convert the body to DOM first
> >
> > from
> > .convertBodyTo(Document.class)
> > choice
> >
> >
> >
> >
> > Also you can add camel-saxon to the classpath to use saxon as the xpath
> > engine. Its faster than what comes out of the box in the JDK.
> >
> >
> > You can use vtd-xml for an xpath language that can work with streamed
> > data types http://camel.apache.org/vtd-xml
> >
> > On Tue, Jul 30, 2013 at 10:57 AM, Jan Matèrne (jhm) <[email protected]>
> > wrote:
> > > I have a route dispatching an exchange according to a XPath
> > evaluation
> > > to different targets.
> > >
> > > Sadly it doesnt perform very well. I think that the DOM is built for
> > > every XPath evalutation.
> > >
> > > Is it true? Can we configure Camel to reuse the DOM?
> > >
> > >
> > >
> > > I think in this Route Camel builds the same DOM 4 times.
> > >
> > >
> > >
> > > public class MyRouter extends RouteBuilder {
> > >
> > >     @Override
> > >
> > >     public void configure() throws Exception {
> > >
> > >         Namespaces v1 = new Namespaces("v1", "...");
> > >
> > >         Namespaces v2 = new Namespaces("v2", "...");
> > >
> > >
> > >
> > >         from("direct:dispatcher")
> > >
> > >             .id("dispatcher")
> > >
> > >             .choice()
> > >
> > >                 .when().xpath("/v1:TypeA",
> > > v1).to("bean:beanA?method=execute")
> > >
> > >                 .when().xpath("/v1:TypeB",
> > > v1).to("bean:beanB?method=execute")
> > >
> > >                 .when().xpath("/v2:TypeA",
> > > v2).to("bean:beanC?method=execute")
> > >
> > >                 .when().xpath("/v2:TypeB",
> > > v2).to("bean:beanD?method=execute")
> > >
> > >                 // many more when().xpath().to() statements
> > >
> > >             .end();
> > >
> > >     }
> > >
> > > }
> > >
> > >
> > >
> > >
> > >
> > > Jan
> > >
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > Red Hat, Inc.
> > Email: [email protected]
> > Twitter: davsclaus
> > Blog: http://davsclaus.com
> > Author of Camel in Action: http://www.manning.com/ibsen
>
>

Reply via email to