i am a beginner in xsl, so perhaps its a very easy question. i have a xsl file where i want to find a specific value thats is defined in a param-object:
<xsl:param name="locales">
<label name="testname"><locale name="de">german text</locale><locale name="en">english text</locale></label>
</xsl:param>
<xsl:template match="foo">
<topLevelElement xmlns="http://foo.bar.org">
<xsl:value-of select="ext:node-set($locales)/label[@name='testname']/locale[@name='en']"/>
</topLevelElement>
</xsl:template>
I expected to get the value 'english text' because i want to find in the param locales
a label
with the name testname
. There I want to find a locale
with the name en
. But it doesn't work.
When I replace the name of the specific elements (label and locale) by a star, then it works:
<xsl:param name="locales">
<label name="testname"><locale name="de">german text</locale><locale name="en">english text</locale></label>
</xsl:param>
<xsl:template match="foo">
<topLevelElement xmlns="http://foo.bar.org">
<xsl:value-of select="ext:node-set($locales)/*[@name='testname']/*[@name='en']"/>
</topLevelElement>
</xsl:template>
Can anyone tell me why I can't find the childs by its name? Thanks a lot!
Edit: The code doesn't show the namespace (its interpreted by the browser i guess). It is without the brackets at the bginning and the end:
xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://foo.bar.org" xmlns:ext="http://exslt.org/common" version="1.0" xsl:output method="xml" version="1.0" encoding="UTF-8"/
xmlns="..."
default namespace defined in your XSLT file. – Tomalak