Wednesday, 23 May 2007

XPath based splitter in one line of Java code

This came up in a recent thread & thought I'd mention it here for those not on the list. If you want to implement the Splitter Pattern from the Enterprise Integration Patterns using XPath then you can use the following line of Java code...

Pretty neat eh. Use any language you like for the expression such as XQuery, SQL, Groovy, Ruby etc.
It sure beats programming in XML :)


Guillaume Laforge said...

Would be fun without parentheses and semi-colons in Groovy, and with additional magic to avoid chaining all those method calls:

from "activemq:my.queue"
splitter xpath("/invoice/lineItem")
to "file://some/directory"

James Strachan said...

Definitely! :). We really should get around to doing a Groovy DSL for Camel...