I have the need to lookup values based on a given code within my mapping. I am trying to use custom XSLT and have not been able to get any of the examples I have found on this technique to work. I would like to create an external xml file to hold my lookup values and refer to it from my map. Here is what I have:
Source Schema:
-Root
-Flower
-Name
-ColorCode
Destination Schema:
-Root
-Flower
-Name
-Color
I want to look up the color code in an external xml that looks like this:
<colors>
<color><code>1</code><name>red</name></color>
<color><code>2</code><name>yellow</name></color>
</colors>
My map (without the lookup functionality I need) looks like this:
<xsl:template match="/">
<xsl:apply-templates select="/s0:Root" />
</xsl:template>
<xsl:template match="/s0:Root">
<ns0:Root>
<xsl:for-each select="Flower">
<Flower>
<Name>
<xsl:value-of select="Name" />
</Name>
<Color>
<xsl:value-of select="ColorCode" />
</Color>
</Flower>
</xsl:for-each>
</ns0:Root>
</xsl:template>
</xsl:stylesheet>
And I would like the output to get the color value and produce this:
<ns0:Root ...>
<Flower>
<Name>Rose</Name>
<Color>Red</Color>
</Flower>
<Flower>
<Name>Tulip</Name>
<Color>Yellow</Color>
</Flower>
</ns0:Root>
What is the best way to do this? Thanks for any help with this. An example on how to accomplish would be great given my lack of success.
Thanks SO much.
Source Schema:
-Root
-Flower
-Name
-ColorCode
Destination Schema:
-Root
-Flower
-Name
-Color
I want to look up the color code in an external xml that looks like this:
<colors>
<color><code>1</code><name>red</name></color>
<color><code>2</code><name>yellow</name></color>
</colors>
My map (without the lookup functionality I need) looks like this:
<xsl:template match="/">
<xsl:apply-templates select="/s0:Root" />
</xsl:template>
<xsl:template match="/s0:Root">
<ns0:Root>
<xsl:for-each select="Flower">
<Flower>
<Name>
<xsl:value-of select="Name" />
</Name>
<Color>
<xsl:value-of select="ColorCode" />
</Color>
</Flower>
</xsl:for-each>
</ns0:Root>
</xsl:template>
</xsl:stylesheet>
And I would like the output to get the color value and produce this:
<ns0:Root ...>
<Flower>
<Name>Rose</Name>
<Color>Red</Color>
</Flower>
<Flower>
<Name>Tulip</Name>
<Color>Yellow</Color>
</Flower>
</ns0:Root>
What is the best way to do this? Thanks for any help with this. An example on how to accomplish would be great given my lack of success.
Thanks SO much.