How to read XML Payload

2015-11-03 Thread calyan.bandi
Hi, 

Could someone please provide me the syntax for reading the XML payload with
only the relevant tags. My input XML contains data as below:



 ...


 
 
 
 
 
 
 
 
 



I need to split the input XML and do custom processing for each individual
customer. The XML after splitting should look as below i.e., from the entire
XML i should split only the 'customer' tags contained in the Body and the
non-body tags should remain untouched and added to the output XML. 



 ...


 
 
 




Any thoughts, please share.

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-read-XML-Payload-tp5773337.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to read XML Payload

2015-11-03 Thread Henryk Konsek
Hi,

Have you taken a look at the XPath splitter by any chance?

Cheers!

wt., 3.11.2015 o 12:31 użytkownik calyan.bandi 
napisał:

> Hi,
>
> Could someone please provide me the syntax for reading the XML payload with
> only the relevant tags. My input XML contains data as below:
>
> 
> 
>  ...
> 
> 
>  
>  
>  
>  
>  
>  
>  
>  
>  
> 
> 
>
> I need to split the input XML and do custom processing for each individual
> customer. The XML after splitting should look as below i.e., from the
> entire
> XML i should split only the 'customer' tags contained in the Body and the
> non-body tags should remain untouched and added to the output XML.
>
> 
> 
>  ...
> 
> 
>  
>  
>  
> 
> 
>
>
> Any thoughts, please share.
>
> Thanks,
> Kalyan
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-read-XML-Payload-tp5773337.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
-- 
Henryk Konsek
http://about.me/hekonsek


Re: How to read XML Payload

2015-11-04 Thread calyan.bandi
Hi Henry,

I tried both the options XPath and tokenize. But they didn't give me the
desired results. The route is defined as below:




 /PricePlans/Body/customer
 



The output that i receive from the XPath split is only the customer tag as
shown below. 


...


I need the meta-data information in the original XML file to be passed on in
the output XML. I even tried with the  as shown below but no
luck.



Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-read-XML-Payload-tp5773337p5773368.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: How to read XML Payload

2015-11-04 Thread Vanshul . Chawla
A way achieve this is with xslt.
Have the header part saved in Camel header and attach that to each split 
message using xslt.

-Original Message-
From: calyan.bandi [mailto:calyan.ba...@gmail.com] 
Sent: Wednesday, November 04, 2015 2:38 PM
To: users@camel.apache.org
Subject: Re: How to read XML Payload

Hi Henry,

I tried both the options XPath and tokenize. But they didn't give me the 
desired results. The route is defined as below:




 /PricePlans/Body/customer
 



The output that i receive from the XPath split is only the customer tag as 
shown below. 


...


I need the meta-data information in the original XML file to be passed on in 
the output XML. I even tried with the  as shown below but no luck.



Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-read-XML-Payload-tp5773337p5773368.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to read XML Payload

2015-11-06 Thread SopwithInOut
I assume that by now, you will have already solved this. But in any case, I
would approach this with some kind of "/ Message Translator
<http://bit.ly/MTEIP>  /" solution in mind. 

I'm very, very new to Camel. But I have a couple years experience using a
big-name proprietary ESB. I've done similar transformations using that ESB's 
"/ Message Translator <http://bit.ly/MTEIP>  /" support. The low-level
details are different. But at a high-level...

I would start off with some kind of reference to a single empty
"/PricePlans/Body/" node (/call it $mtBody, for short/). Then for each
 I come across, I'd squirt each one in turn into my
previously-prepared /$mtBody/ node. In pseudo-code...



Or assuming each of my // elements have some unique identifier —
maybe a "/custId/" attribute, say — it should be possible to forego a
looping approach. Instead, I could envisage some kind of  "/ Message
Translator <http://bit.ly/MTEIP>  /" that used XPath to somehow reference
each // by its /custID/ attribute.

How did you eventually solve it, by the way?





--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-read-XML-Payload-tp5773337p5773427.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to read XML Payload

2015-11-06 Thread calyan.bandi
Hi,

Thanks everyone for giving their suggestions. I was able to solve this using
xslt component in a camel-loop . I am giving the route here just for your
reference:

 


count(/PricePlans/Body/customer)   


CamelLoopIndex 



${header.loopIndex}++





 

In my XSLT, i am making use of the header "custIndex" to reach out to each
customer node. The XSLT looks as below. I was able to achieve this with the
feature provided in XSLT component which is "all headers are added as
parameters which are available in the XSLT". 

http://www.w3.org/1999/XSL/Transform";>
























 



What bothers me here is the use of header values twice in the route. This is
because the camel's loop property 'CamelLoopIndex' starts with zero and i
cannot pass this directly into the XSLT file. The alternative way of doing
this via message translator looks good but i haven't tried it. Any ways, the
code is working now :)

Regards,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-read-XML-Payload-tp5773337p5773431.html
Sent from the Camel - Users mailing list archive at Nabble.com.