camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@fusesource.com>
Subject Re: How do I use xpath functions in Camel?
Date Fri, 09 Dec 2011 12:28:15 GMT
Currently the XPath Spring DSL element doesn't allow specifying Saxon or a
different factory.
The only option now is to use a system property, as per the last section in
[1].

Alternatively, if you only have a few headers to set using XPath 2.0, you
can use the XQuery language in Camel which automatically defaults to Saxon,
making all of XPath 2.0's goodness available to you as a side effect ;)

-- Raúl.

[1] http://camel.apache.org/xpath.html.

On 9 December 2011 11:57, Raul Kripalani <raul@fusesource.com> wrote:

> Hi,
>
> You need Saxon to run XPath 2.0 functions. The JDK default for JAXP is
> Xalan I believe, which only supports XPath 1.0.
> XPath 1.0 included several functions [1] but nowhere near as powerful and
> useful as XPath 2.0 [2].
>
> The string function exists in XPath 1.0 and it is available to use within
> Camel without Saxon in the classpath - I just tested it with the following
> config:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="
> http://www.springframework.org/schema/util"
>  xsi:schemaLocation="
>            http://www.springframework.org/schema/beans
>            http://www.springframework.org/schema/beans/spring-beans.xsd
>            http://camel.apache.org/schema/spring
>            http://camel.apache.org/schema/spring/camel-spring.xsd
>            http://www.springframework.org/schema/util
>            http://www.springframework.org/schema/util/spring-util.xsd">
>
>    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>  <route id="timer">
>   <from uri="timer:test?fixedRate=true&amp;period=10000" />
>     <setBody><constant><![CDATA[<hello />]]></constant></setBody>
>     <setHeader headerName="test">
>        <xpath resultType="java.lang.String">string('313')</xpath>
>     </setHeader>
> <to uri="log:StartTest?showAll=true" />
>  </route>
>  </camelContext>
>
> </beans>
> Regards,
> Raúl.
>
> [1] http://www.w3.org/TR/xpath/#corelib
> [2] http://www.w3.org/TR/xpath-functions/
>
> On 9 December 2011 11:39, Claus Ibsen <claus.ibsen@gmail.com> wrote:
>
>> You may have luck by just included camel-saxon, and thus saxon on the
>> classpath, which may let the JDK use Saxon as its XPath engine.
>>
>>
>> On Thu, Dec 8, 2011 at 5:51 PM, MichaelAtSAG <mebevilacqua@gmail.com>
>> wrote:
>> > Ok, I am hearing that I need to use Saxon to run xpath functions versus
>> the
>> > default camel-core component. Correct? To do this, I have added this to
>> the
>> > pom.xml:
>> >
>> >        <dependency>
>> >                <groupId>org.apache.camel</groupId>
>> >                <artifactId>camel-saxon</artifactId>
>> >        </dependency>
>> >
>> > The examples in the Apache Camel: Xpath page show the use of Java code
>> to
>> > use Saxon. It is possible to use Saxon in Spring XML versus Java
>> methods?
>> >
>> > --
>> > View this message in context:
>> http://camel.465427.n5.nabble.com/How-do-I-use-xpath-functions-in-Camel-tp5056913p5059406.html
>> > Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message