Splitting and aggregating is designed for routing and orchestration purposes,
rather than low-level data processing.

You are better off using XSLT for this use case.

Take a look at this example [1] for an XSL template that does grouping and
counting.

Use an XSLT endpoint [2] in Camel with camel-saxon for XSLT 2.0
compatibility.

Hope that helps.

[1]
http://www.java2s.com/Code/XML/XSLT-stylesheet/Usecountandcurrentgrouptocountgroups.htm
[2] http://camel.apache.org/xslt.html

*Raúl Kripalani*
*Principal Consultant | FuseSource Corp.
r...@fusesource.com | fusesource.com <http://www.fusesource.com/>
skype: raul.fuse | twitter: @raulvk <http://twitter.com/raulvk>,
@fusenews<http://twitter.com/fusenews>
*
blog: F3 - Flashes From the
Field<http://blog.raulkr.net/?utm_source=fusesourceemail&utm_medium=email&utm_campaign=fusesourcemail>
|
aboutme: http://about.me/raulkripalani

<http://twitter.com/fusenews>

On 9 August 2012 20:14, Deepthi <deepthi...@gmail.com> wrote:

> Hi,
>
> i am trying to group xml's with same id and count the number of items in
> each group. I am using camel 2.8.0
>
> For Eg:
> Input xml:
> <order>
>    <item>
>        <id>1</id>
>        <description>test item 1</description>
>     </item>
>     <item>
>        <id>2</id>
>        <description>test item 1</description>
>     </item>
>     <item>
>        <id>1</id>
>        <description>test item 1</description>
>     </item>
>     <item>
>        <id>3</id>
>        <description>test item 1</description>
>     </item>
> </order>
>
> I am trying to achieve it in the following manner:
> <from uri="file://[source folder]" />
> <split>
>               <xpath>/order/item</xpath>
>               <setHeader headerName="asnid">
>                     <xpath>/item/id/text()</xpath>
>                </setHeader>
>                 <setHeader headerName="itemCount">
>                         <xpath
> resultType="java.lang.String">count(/item)</xpath>
>                  </setHeader>
> </split>
>  The above approach is not working. Can I use aggregator, if so how?
>
> Thanks,
> Deepthi
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Grouping-of-xml-and-count-of-each-tp5717086.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to