Thanks Claus, I will try this solution... As a second thought, could this behaviour be added as an enhancement to the Type Converters or maybe camel-xpath itself?
On Tue, Nov 6, 2012 at 5:17 AM, Claus Ibsen <[email protected]> wrote: > Hi > > You are under the mercy of XPath and what XPathExpression can do. > As it returns a NodeList which has Node elements, you may be able to > go from Node -> Document (or whatever the parent type is), and then > grab any namespaces. You would then need to use the DOM API from the > JDK for that. > > And do this before you do the <convertBodyTo type="String"/> > > > On Mon, Nov 5, 2012 at 9:44 PM, Henrique Viecili <[email protected]> > wrote: > > Is there a way to tell the splitter-xpath to copy all parent namespaces > to > > the splitted element? > > > > This is what I am trying to do: > > > > I am trying to split an XML message with XPath, this message has a schema > > defining an element containing a sequence of xsi:anySimpleType. Creating > > such message gives me something like: > > > > <alpha:root xmlns:alpha="http://test.com/Alpha" xmlns:beta=" > > http://test.com/Beta"> > > <alpha:collection> > > <alpha:item xsi:type="beta:BetaItem" xmlns:xsi=" > > http://www.w3.org/2001/XMLSchema-instance"> > > <beta:name>Foo</beta:name> > > </alpha:item> > > <alpha:item xsi:type="beta:BetaItem" xmlns:xsi=" > > http://www.w3.org/2001/XMLSchema-instance"> > > <beta:name>Bar</beta:name> > > </alpha:item> > > </alpha:collection> > > </alpha:root> > > > > > > my camel route is: > > > > <camelContext xmlns:alpha="http://test.com/Alpha" xmlns:beta=" > > http://test.com/Beta" > > > <route> > > <from uri="..."/> > > <split> > > <xpath>//alpha:item</xpath> > > <convertBodyTo type="java.lang.String"/> > > <to uri="log:output-missing-beta-namespace"/> > > </split> > > </route> > > </camelContext> > > > > > > feeding this route with the previous XML gives me 2 pieces of invalid XML > > messages without the 'beta' namespace defined in the root element: > > > > <alpha:item xmlns:alpha="http://test.com/Alpha" xsi:type="beta:BetaItem" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > > <beta:name>Foo</beta:name> > > </alpha:item> > > > > So, Is there a way to tell the splitter-xpath to copy the 'beta' > namespace > > from 'root' declaration into the splitted 'alpha:item' element? > > > > > > Thanks > > *Henrique Viecili* > > > > -- > Claus Ibsen > ----------------- > Red Hat, Inc. > FuseSource is now part of Red Hat > Email: [email protected] > Web: http://fusesource.com > Twitter: davsclaus > Blog: http://davsclaus.com > Author of Camel in Action: http://www.manning.com/ibsen >
