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:

 <camel:route>
        <from uri="file:in/xml?fileName=Customers.xml&amp;noop=true" />
        <camel:loop copy="true">
                <camel:xpath
resultType="java.lang.Integer">count(/PricePlans/Body/customer)</camel:xpath>   
        
                <camel:setHeader headerName="loopIndex">
                        <camel:property>CamelLoopIndex</camel:property>         
        
                </camel:setHeader>
                <camel:setHeader headerName="custIndex">
                        <camel:simple>${header.loopIndex}++</camel:simple>
                </camel:setHeader>
                                
                <camel:to uri="xslt:file:in/xslt/Customer.xsl" />
                <camel:to uri="direct:output" />                
        </camel:loop>
 </camel:route>

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". 

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:param name="custIndex" />

                        <xsl:template match="/">
                                <customer>
                                        <header>
                                                <meta-data>
                                                        <xsl:value-of 
select="PricePlans/Header/meta-data" />
                                                </meta-data>
                                                <date>
                                                        <xsl:value-of 
select="PricePlans/Header/date" />
                                                </date>
                                        </header>
                                        <body>
                                                <customer>
                                                        <id>
                                                                <xsl:value-of 
select="PricePlans/Body/customer[$custIndex]/id" />
                                                        </id>
                                                        <name>
                                                                <xsl:value-of 
select="PricePlans/Body/customer[$custIndex]/name" />
                                                        </name>
                                                </customer>
                                        </body>
                                </customer>
                        </xsl:template>                 
</xsl:stylesheet>


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.

Reply via email to