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&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 <[email protected]> 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 <[email protected]> > 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: [email protected] > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/ >
