I am developing an application were I need to transform XML documents that look like this:
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE words SYSTEM "words.dtd">
<words>
<word id="word_1">Alfa</word>
<word id="word_2">Beta</word>
<word id="word_3">Gamma</word>
<word id="word_4">Delta</word>
<word id="word_5">Zeta</word>
</words>
Using a XSLT stylesheet. I would like the result of the transformation to be (in this case) Delta and this is the XSL I am using:
<?xml version='1.0' encoding='ISO-8859-1'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="Hurrengo_Hitza">word_4</xsl:param>
<xsl:template match="word/[@id = Hurrengo_Hitza]">
<html>
<body>
<tr>
<td><xsl:value-of select="text()"/></td>
</tr>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
It shows no result, what do I have to change in the XSLT? Something wrong in the XPath expression?
The param in XSLT needs to be preceded by a dolar sign ($)
So try:
UPDATE:
I think you are only allowed
variableson the match attribute on XSLT 2.But here is how you could do it: