Hi You can use xpath to grab the values you want to use in the velocity template, and set them as headers.
<setHeader headerName="foo"><xpath>/foo/text()</xpath></setHeader> Then you can access the ${header.foo} from the velocity template. Mind that when you use xpath and the XML has namespaces, then the xpath expression must use those namespaces as well. It can be a bit tricky to get the xpath expression working. See examples here: http://camel.apache.org/xpath On Fri, Dec 2, 2011 at 7:46 PM, MichaelAtSAG <mebevilac...@gmail.com> wrote: > The Apache Camel example for Velocity using Java code to implement the logic. > Is there an example available that does not use java? > > We are trying to use a Spring XML approach and cannot figure out how to > connect the message properties into the velocity template. > > -Velocity template:- > > Dear Purchaser, > > We have an ${headers.eventtype} situation. We need > ${body.DesiredInventoryLevel} piece(s) for part number ${body.ItemID}. > > Please review this situation. > > > > -Message:- > <?xml version="1.0" encoding="UTF-8"?> > <evt:Event xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:evt="http://namespaces.xyz.com/EDA/Event" > > xmlns:pay="http://namespaces.xyz.com/EDA/WebM/Sample/InventoryMgmt/1.0"> > <evt:Body> > <pay:PartInventoryShortage> > <pay:Part> > <pay:ItemID>ABC123</pay:ItemID> > <pay:ItemName>Widget for thingy</pay:ItemName> > <pay:Model>ACME </pay:Model> > <pay:Color>Grey</pay:Color> > <pay:Shape>Oval</pay:Shape> > </pay:Part> > <pay:InventoryLevel>5</pay:InventoryLevel> > <pay:DesiredInventoryLevel>45</pay:DesiredInventoryLevel> > <pay:SupplierInventoryLevel>28</pay:SupplierInventoryLevel> > </pay:PartInventoryShortage> > </evt:Body> > </evt:Event> > > -Content file - > > <?xml version="1.0" encoding="UTF-8" standalone="no"?> > <beans xmlns="http://www.springframework.org/schema/beans" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > 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"> > > <camelContext xmlns="http://camel.apache.org/schema/spring" id="camel" > xmlns:evt="http://namespaces.xyz.com/EDA/Event"> > > <route id="Announcer" startupOrder="3"> > <from uri="file:src/data?noop=true" /> > <setHeader headerName="eventtype"> > <xpath>/evt:Event/evt:Header/evt:Type</xpath> > </setHeader> > <choice> > <when> > <language language="xpath">$eventtype = > > '{http://namespaces.xyz.com/EDA/WebM/Sample/InventoryMgmt/1.0}PartInventoryShortage' > </language> > <log message="Announce > PartInventoryShortage(b): file - > > jms:InvMgmt" /> > <to > uri="velocity:file:src/main/resources/email.vm" /> > <log message="Announce > PartInventoryShortage(a): file - > email" /> > > <to uri="outputToScreen" /> > </when> > </choice> > </route> > </camelContext> > </beans> > > > How do I connect the message properties with the velocity template? Do I > need to set header properties in the Camel context file? I did this for > routing logic, yet the header element shows like this: > > We have an *com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList@4e39f16f* > situation. > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Velocity-without-java-tp5042886p5042886.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/