You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Iacopo ROZZO <ia...@amadeus.com> on 2015/10/06 16:11:08 UTC

CXF transformation feature to change namespace to element and all its children.

Hi all,

I'm using cxf 3.0.2 and I have a question regarding the CXF transformation feature<http://cxf.apache.org/docs/transformationfeature.html>. I have the following scenario:

Input: All elements belong to namespace "ns.a"

<sales xmlns:"http://ns.a">
<book>
  <title>CXF ...</title>
  <price>38.68</price>
</book>
</sales>

Expected output: Elements book, title and price should belong to namespace "ns.b"
<sales xmlns:"http://ns.a">
<book xmlns:"http://ns.b">
  <title>CXF ...</title>
  <price>38.68</price>
</book>
</sales>

If I only add this entry "{http://ns.a}book => {http://ns.b}book" to the transformation map the namespace is only changed to book element (as normal). Is there any way of qualifying book and all its child elements without putting explicitly an entry for all book children elements?

Thanks,
Iacopo


Re: CXF transformation feature to change namespace to element and all its children.

Posted by Sergey Beryozkin <sb...@gmail.com>.
In this case - yes, but in your simpler example it was possible :-)
I guess we may need something similar for the in/out namespace transform 
to what we have in the 'drop' mode, where only a specific element and 
all of children can be dropped

Cheers, Sergey
On 06/10/15 17:11, Iacopo ROZZO wrote:
> Thx for the prompt reply, but I think I oversimplified the example, my fault. In the actual scenario I want to handle there are several elements belonging to the default namespace, and I want to change namespace only to one particular element (including its children elements):
>
> Input:
> <sales xmlns:"http://ns.a">
> <dvd>
>    <title>CXF ...</title>
>    <price>38.68</price>
> </dvd>
> <cd>
>    <title>CXF ...</title>
>    <price>38.68</price>
> </cd>
> ...
> <book>
>    <title>CXF ...</title>
>    <price>38.68</price>
> </book>
> </sales>
>
> Expected:
> <sales xmlns:"http://ns.a">
> <dvd>
>    <title>CXF ...</title>
>    <price>38.68</price>
> </dvd>
> <cd>
>    <title>CXF ...</title>
>    <price>38.68</price>
> </cd>
> ...
> <book xmlns:"http://ns.b">
>    <title>CXF ...</title>
>    <price>38.68</price>
> </book>
> </sales>
>
> I looked to the code and I think that it is not possible to achieve that without specifying all children elements explicitly in the map. Am I correct?
>
> Iacopo
>
>
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: 06 October 2015 16:42
> To: users@cxf.apache.org
> Subject: Re: CXF transformation feature to change namespace to element and all its children.
>
> Hi
>
> Can you try setting these two entries:
>
> "{http://ns.a}sales => {http://ns.a}sales"
> "{http://ns.a}* => {http://ns.b}*"
>
> Cheers, Sergey
> On 06/10/15 15:11, Iacopo ROZZO wrote:
>> Hi all,
>>
>> I'm using cxf 3.0.2 and I have a question regarding the CXF transformation feature<http://cxf.apache.org/docs/transformationfeature.html>. I have the following scenario:
>>
>> Input: All elements belong to namespace "ns.a"
>>
>> <sales xmlns:"http://ns.a">
>> <book>
>>     <title>CXF ...</title>
>>     <price>38.68</price>
>> </book>
>> </sales>
>>
>> Expected output: Elements book, title and price should belong to namespace "ns.b"
>> <sales xmlns:"http://ns.a">
>> <book xmlns:"http://ns.b">
>>     <title>CXF ...</title>
>>     <price>38.68</price>
>> </book>
>> </sales>
>>
>> If I only add this entry "{http://ns.a}book => {http://ns.b}book" to the transformation map the namespace is only changed to book element (as normal). Is there any way of qualifying book and all its child elements without putting explicitly an entry for all book children elements?
>>
>> Thanks,
>> Iacopo
>>
>>
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

RE: CXF transformation feature to change namespace to element and all its children.

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

Btw you can evaluate XSLT Feature http://cxf.apache.org/docs/xslt-feature.html .
It was designed for advanced use cases, where simple transformation is not enough.
XSLT Feature applies custom XSL transformations to inbound and/or outbound messages.

Regards,
Andrei.

> -----Original Message-----
> From: Iacopo ROZZO [mailto:iacopo.rozzo@amadeus.com]
> Sent: Dienstag, 6. Oktober 2015 18:12
> To: users@cxf.apache.org
> Subject: RE: CXF transformation feature to change namespace to element and
> all its children.
> 
> Thx for the prompt reply, but I think I oversimplified the example, my fault. In
> the actual scenario I want to handle there are several elements belonging to
> the default namespace, and I want to change namespace only to one particular
> element (including its children elements):
> 
> Input:
> <sales xmlns:"http://ns.a">
> <dvd>
>   <title>CXF ...</title>
>   <price>38.68</price>
> </dvd>
> <cd>
>   <title>CXF ...</title>
>   <price>38.68</price>
> </cd>
> ...
> <book>
>   <title>CXF ...</title>
>   <price>38.68</price>
> </book>
> </sales>
> 
> Expected:
> <sales xmlns:"http://ns.a">
> <dvd>
>   <title>CXF ...</title>
>   <price>38.68</price>
> </dvd>
> <cd>
>   <title>CXF ...</title>
>   <price>38.68</price>
> </cd>
> ...
> <book xmlns:"http://ns.b">
>   <title>CXF ...</title>
>   <price>38.68</price>
> </book>
> </sales>
> 
> I looked to the code and I think that it is not possible to achieve that without
> specifying all children elements explicitly in the map. Am I correct?
> 
> Iacopo
> 
> 
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: 06 October 2015 16:42
> To: users@cxf.apache.org
> Subject: Re: CXF transformation feature to change namespace to element and
> all its children.
> 
> Hi
> 
> Can you try setting these two entries:
> 
> "{http://ns.a}sales => {http://ns.a}sales"
> "{http://ns.a}* => {http://ns.b}*"
> 
> Cheers, Sergey
> On 06/10/15 15:11, Iacopo ROZZO wrote:
> > Hi all,
> >
> > I'm using cxf 3.0.2 and I have a question regarding the CXF transformation
> feature<http://cxf.apache.org/docs/transformationfeature.html>. I have the
> following scenario:
> >
> > Input: All elements belong to namespace "ns.a"
> >
> > <sales xmlns:"http://ns.a">
> > <book>
> >    <title>CXF ...</title>
> >    <price>38.68</price>
> > </book>
> > </sales>
> >
> > Expected output: Elements book, title and price should belong to namespace
> "ns.b"
> > <sales xmlns:"http://ns.a">
> > <book xmlns:"http://ns.b">
> >    <title>CXF ...</title>
> >    <price>38.68</price>
> > </book>
> > </sales>
> >
> > If I only add this entry "{http://ns.a}book => {http://ns.b}book" to the
> transformation map the namespace is only changed to book element (as
> normal). Is there any way of qualifying book and all its child elements without
> putting explicitly an entry for all book children elements?
> >
> > Thanks,
> > Iacopo
> >
> >
> 
> 
> --
> Sergey Beryozkin
> 
> Talend Community Coders
> http://coders.talend.com/

RE: CXF transformation feature to change namespace to element and all its children.

Posted by Iacopo ROZZO <ia...@amadeus.com>.
Thx for the prompt reply, but I think I oversimplified the example, my fault. In the actual scenario I want to handle there are several elements belonging to the default namespace, and I want to change namespace only to one particular element (including its children elements):

Input:
<sales xmlns:"http://ns.a">
<dvd>
  <title>CXF ...</title>
  <price>38.68</price>
</dvd>
<cd>
  <title>CXF ...</title>
  <price>38.68</price>
</cd>
...
<book>
  <title>CXF ...</title>
  <price>38.68</price>
</book>
</sales>

Expected:
<sales xmlns:"http://ns.a">
<dvd>
  <title>CXF ...</title>
  <price>38.68</price>
</dvd>
<cd>
  <title>CXF ...</title>
  <price>38.68</price>
</cd>
...
<book xmlns:"http://ns.b">
  <title>CXF ...</title>
  <price>38.68</price>
</book>
</sales>

I looked to the code and I think that it is not possible to achieve that without specifying all children elements explicitly in the map. Am I correct?

Iacopo


-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Sent: 06 October 2015 16:42
To: users@cxf.apache.org
Subject: Re: CXF transformation feature to change namespace to element and all its children.

Hi

Can you try setting these two entries:

"{http://ns.a}sales => {http://ns.a}sales"
"{http://ns.a}* => {http://ns.b}*"

Cheers, Sergey
On 06/10/15 15:11, Iacopo ROZZO wrote:
> Hi all,
>
> I'm using cxf 3.0.2 and I have a question regarding the CXF transformation feature<http://cxf.apache.org/docs/transformationfeature.html>. I have the following scenario:
>
> Input: All elements belong to namespace "ns.a"
>
> <sales xmlns:"http://ns.a">
> <book>
>    <title>CXF ...</title>
>    <price>38.68</price>
> </book>
> </sales>
>
> Expected output: Elements book, title and price should belong to namespace "ns.b"
> <sales xmlns:"http://ns.a">
> <book xmlns:"http://ns.b">
>    <title>CXF ...</title>
>    <price>38.68</price>
> </book>
> </sales>
>
> If I only add this entry "{http://ns.a}book => {http://ns.b}book" to the transformation map the namespace is only changed to book element (as normal). Is there any way of qualifying book and all its child elements without putting explicitly an entry for all book children elements?
>
> Thanks,
> Iacopo
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Re: CXF transformation feature to change namespace to element and all its children.

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

Can you try setting these two entries:

"{http://ns.a}sales => {http://ns.a}sales"
"{http://ns.a}* => {http://ns.b}*"

Cheers, Sergey
On 06/10/15 15:11, Iacopo ROZZO wrote:
> Hi all,
>
> I'm using cxf 3.0.2 and I have a question regarding the CXF transformation feature<http://cxf.apache.org/docs/transformationfeature.html>. I have the following scenario:
>
> Input: All elements belong to namespace "ns.a"
>
> <sales xmlns:"http://ns.a">
> <book>
>    <title>CXF ...</title>
>    <price>38.68</price>
> </book>
> </sales>
>
> Expected output: Elements book, title and price should belong to namespace "ns.b"
> <sales xmlns:"http://ns.a">
> <book xmlns:"http://ns.b">
>    <title>CXF ...</title>
>    <price>38.68</price>
> </book>
> </sales>
>
> If I only add this entry "{http://ns.a}book => {http://ns.b}book" to the transformation map the namespace is only changed to book element (as normal). Is there any way of qualifying book and all its child elements without putting explicitly an entry for all book children elements?
>
> Thanks,
> Iacopo
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/