camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henrique Viecili <henri...@myreks.com>
Subject Re: Split with xpath loses root element namespaces
Date Tue, 06 Nov 2012 12:04:01 GMT
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 <claus.ibsen@gmail.com> 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 <henrique@myreks.com>
> 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: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message