camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Help with message enrichment
Date Sat, 25 Jan 2014 19:24:18 GMT
Hi

Welcome to the community.

On Fri, Jan 24, 2014 at 8:05 PM, joeuser <tim@undisclosedlocation.net> wrote:
> All,
>
> Greetings. I recently inherited a project built using the Camel framework
> and now have to extend it. My experience is almost zero with Camel but I am
> learning and reading as fast and hard as I can.
>
> I have seen other posts that mention my situation but dont provide the
> information I am looking for ( or I dont understand enough yet ) so here
> goes.
>
> In a nutshell, I need to build a list of product ID's from the xml response
> of an external webservice and then query a Solr instance for description
> info about each product ( could be 0 to several hundred individual items ).
> Once I have those, I need to push the original message thru XSLT to remap it
> to a different tagging structure and insert the product description from the
> Solr call into each node group associated with that product ID.
>
> This is a snippet of the xml doc. Most of them are huge and contain nested,
> nests of nastiness that will be corrected once it hits the XSLT transform
> later on down stream.
>
> Original xml: ( has a node for the description, but does not contain the
> data in that system)
>
> <order>
>   <item>
>     <id>12345</id>
>     <desc></desc>
>   </item>
> </order>
>
> Final xml:
>
> <group>
>     <team>
>       <sales>
>         <sku>
>           <slotnum>12345</slotnum>
>           <productdesc>This is a fuzzy widget</productdesc>
>         </sku>
>       </sales>
>     </team>
> </group>
>
> I have no problems constructing the routes as restlets, working fine. Also
> passing the docs to XSLT for remapping is working. Having a huge problem
> injecting the descriptions from Solr into the original xml prior to passing
> to XSLT.
>
> Can someone show me some code that would most likely run as part of an
> aggregation strategy or perhaps a Processor that takes the Solr msg,
> extracts the desc using XPath and injects it into the description node?
>
> I looked at JAXB or XStream as possible approaches, but modeling the full
> document as an object when I only need to effect one small portion of it
> seems like the wrong approach.
>
> Doing my best to figure this out on my own ( very, very small shop ) but
> sometimes you just need a little nudge in the right direction.
>

You can do xpath using the java xpath api.
Or there is also a XstlBuilder in camel-core you can use for xpath evaluations
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/builder/xml/XsltBuilder.html

Then you can use that from your aggregation strategy.


> Thank any and all for their time and expertise.
>
> Zippy
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Help-with-message-enrichment-tp5746459.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Mime
View raw message