I am working with an xslt file for styling. I am showing some content in tabular format. I need to dynamically populate one column from pre defined key value pair. Please look at below example
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Sample Transformation</h2>
<table border="1">
<xyz>msgprop</xyz>
<tr bgcolor="#9acd32">
<th>Id</th>
<th>Name</th>
<th>City</th>
</tr>
<xsl:for-each select="en:MyEvent">
<tr>
<td><xsl:value-of select="en:id"/></td>
<td><xsl:value-of select="en:name"/></td>
<td><xsl:value-of select="en:country"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The problem is that i am receiving country name in place of city and i want to populate the city column with correct city and for that i need to map country and its city. Is there any way to predefined country and its city in key value pair and when received the country name, it will be replaced by city name(if not present it will display country name). Is there any function to do it?. It will be helpfull if you provide a snippet.
Edit: Here is the xml
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<id>Empire Burlesque</id>
<Name>Bob Dylan</Name>
<country>USA</country>
</cd>
<cd>
<id>Hide your heart</id>
<name>Bonnie Tyler</name>
<country>UK</country>
</cd>
<cd>
<id>Greatest Hits</id>
<name>Dolly Parton</name>
<country>USA</country>
</cd>
<cd>
<id>Still got the blues</id>
<name>Gary Moore</name>
<country>UK</country>
</cd>
</catalog>
I need a mapping such that whenever country name is UK it will be replaced with its capital London same with other countries. Is there somew way that i define UK as a key and London as a value so that whenever i received key as UK it will be replaced with its value. Please help.
Consider the following example:
XML
XSLT 1.0
Result (rendered):