Hi Claus,
Actually I looked into that doc on XSLT and also browsed google, but was not
able to find the way.
>From the doc, and based on the experiments i did, looks like we can set only
constant within <constant></constant> under setParameter (i guess lives more
life than header) or setHeader element.
Although i changed the approach, rather then reading the properties file
(the purpose of which in this case is to hold Mapping), to this one:
1. in camel context:
call <camel:to uri="xslt:transfomer.xsl"/>
2. then later in the transformer.xsl file, load the mapping.xml (XML file
now instead of properties file)
<xsl:variable name="mapping-file" select="'mapping.xml'"/>
<xsl:variable name="locations-mapping"
select="document($mapping-file)/LocationsMappings" />
so then wherever I want the translation of location code,
<xsl:variable name="locTranslated">
<xsl:call-template name="location-mapping">
<xsl:with-param name="locAbbr"
select="$loc" />
</xsl:call-template>
</xsl:variable>
and have the template defined in the xsl itself:
<xsl:template name="location-mapping">
<xsl:param name="locAbbr" />
<xsl:for-each select="$locations-mapping/Mapping/Location">
<xsl:if test="@name = $locAbbr">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:template>
3. mapping.xml:
<LocationsMappings>
<Mapping>
<Location name="IL">Illinois</Location>
<Location name="NY">New York</Location>
</Mapping>
</LocationsMappings>
Boom, right on target, solves the issue.
I'm not sure if above is the neat solution or if there could be other choice
like loading from DB or anyother.
Any way I'll keep trying.
Thanks for your time.
Vikas
Claus Ibsen-2 wrote:
>
> Hi
>
> Have you checked the Camel documentation?
> http://camel.apache.org/xslt.html
>
> There is a section titled - Getting Parameters into the XSLT to work with
>
>
> On Thu, May 13, 2010 at 6:57 PM, Vikas Kumar Arora
> <[email protected]> wrote:
>>
>> Hi,
>> Is there a way to pass Map as a param to XSLT component?
>> Camel 1.6.2 (As we run on Jdk1.4, no other choice)
>>
>> Requirement: I've location maps(Properties file) M1, M2 etc from Partners
>> P1, P2. And before forwarding the request to WS, I have to apply the XSL
>> Transforamtion to convert P1, P2 etc format to our WS format. But in this
>> process I've to apply Location Code transformation as well.
>>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:ws="http://ws.xxxxxx.com"
>>
>> xmlns:spml="urn:oasis:names:tc:SPML:2:0"
>>
>> xmlns:udc="urn:xxxxx:enterprise:domain:identity:1.0"
>>
>> xmlns:xalan="http://xml.apache.org/xalan"
>> xmlns:map="java:java.util.Map"
>> exclude-result-prefixes="xalan
>> spml ws soapenv"
>> version="2.0">
>>
>> <xsl:output method="xml" omit-xml-declaration="yes"/>
>> <!--xsl:param name="title"/-->
>> <xsl:param name="map"/>
>>
>> <xsl:template match="@* | node()">
>> <xsl:copy>
>> <xsl:apply-templates select="@* | node()" />
>> </xsl:copy>
>> </xsl:template>
>>
>> <xsl:template match="udc:UDCIdentity">
>> <!--xsl:value-of select="$title"/-->
>> <xsl:value-of select="map:get($map,
>> 'locationCode')"/>
>> <xsl:copy>
>> <xsl:apply-templates select="@* | node()" />
>> </xsl:copy>
>>
>> </xsl:template>
>>
>> </xsl:stylesheet>
>>
>>
>> Sample Camel Config that I'm experimenting for now:
>>
>> <camel:route>
>>
>> <camel:from uri="jetty:http://localhost:8081/AuthN/esb"/>
>>
>> <camel:setHeader
>> headerName="myParam1"><camel:constant>1</camel:constant></camel:setHeader>
>> <camel:setHeader
>> headerName="myParam2"><camel:constant>2</camel:constant></camel:setHeader>
>> <camel:setHeader
>> headerName="myParam3"><camel:constant>3</camel:constant></camel:setHeader>
>> <camel:setHeader
>> headerName="myParam4"><camel:constant>4</camel:constant></camel:setHeader>
>> <camel:setProperty propertyName="routeId">
>> <camel:header>1</camel:header>
>> </camel:setProperty>
>>
>> <camel:to uri="xslt:transfomer.xsl"/>
>> <camel:to uri="bean:someBean"/>
>> <camel:to
>> uri="http://login.dev2.XXXX.edu/AuthN/services/Service"/>
>>
>> <!-- camel:filter>
>> <camel:mvel>request.headers.foo == 'bar'</camel:mvel>
>> <camel:to
>> uri="http://login.dev2.XXXX.edu/AuthN/services/Service"/>
>> </camel:filter-->
>> </camel:route>
>>
>> </camel:camelContext>
>>
>>
>> Some Spring Util config:
>>
>> <util:properties id="P1" location="classpath:LocationCodes.properties"/>
>> (I'm not sure how could i inject into Camel SetProperty somewhere).
>>
>> Any suggestions would help.
>>
>> Thanks,
>> Vikas
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Camel-XSLT%2C-how-to-pass-a-Map-param-to-XSL-tp28550003p28550003.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
>
--
View this message in context:
http://old.nabble.com/Camel-XSLT%2C-how-to-pass-a-Map-param-to-XSL-tp28550003p28560609.html
Sent from the Camel - Users mailing list archive at Nabble.com.