3 Replies Latest reply on Dec 10, 2010 11:21 AM by Chris Smith

    Using XQuery with a Splitter

    Chris Smith Newbie

      I currently have a splitter within one of my Camel flows that uses an xpath expression to split message, but I would like to change this to use xquery. However, when I attempt to use an xquery expression within a splitter I get the following error:

       

      org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.

       

      According to the documentation for the xquery component, this error can appear if a result type for the xquery expression is not specified, but I'm not sure what the correct result type would be for a splitter.

       

      Any help is appreciated; I can also post a simple example of the expression I'm using if necessary. Thanks in advance.

        • 1. Re: Using XQuery with a Splitter
          Claus Ibsen Master

          Try setting the type to a String as shown in the documentation

          http://camel.apache.org/xquery

          • 2. Re: Using XQuery with a Splitter
            Chris Smith Newbie

            Doesn't work. What happens is that instead of getting multiple messages, I get one big message (the original input message) in which all of the XML tags have been stripped out. I see the same behavior if I explicitly set a result type of String on an xpath query, by the way.

             

            Here's some more information, in case I'm simply doing something wrong with the expression. My messages basically look like this:

             

            component, but I need to switch to xquery to do some more complex processing.

            • 3. Re: Using XQuery with a Splitter
              Chris Smith Newbie

              So according to the splitter component documentation, a method that is used as the expression in a splitter should return an iterable value such as java.util.Collection. If I try setting the return type of my xquery expression to java.util.Collection, I do get the correct number of messages coming out of the splitter, but they appear to be empty and the following error is printed for each one:

               

              ERROR:  'Source object passed to '''' has no contents.'