我是xsl的初学者,所以也许这是一个非常简单的问题。我有一个xsl文件,我想在其中找到在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>
我希望获得值“英语文本”,因为我想在参数locales
a中找到label
名称testname
。我想在那儿找到一个locale
名字en
。但这是行不通的。当我用星号替换特定元素的名称(标签和语言环境)时,它可以工作:
<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>
谁能告诉我为什么找不到我的孩子的名字?非常感谢!
编辑:代码不显示名称空间(我猜它是由浏览器解释的)。它的开头和结尾都没有括号:
xsl:stylesheet xmlns:xsl =“ http://www.w3.org/1999/XSL/Transform” xmlns =“ http://foo.bar.org” xmlns:ext =“ http://exslt.org/通用” version =“ 1.0” xsl:输出方法=“ xml” version =“ 1.0” encoding =“ UTF-8” /
在不更改XPath的情况下进行修复的一种方法是更改
<xsl:param name="locales">
<label name="testname"><locale name="de">german text</locale><locale name="en">english text</locale></label>
</xsl:param>
至
<xsl:param name="locales" xmlns="">
<label name="testname"><locale name="de">german text</locale><locale name="en">english text</locale></label>
</xsl:param>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句