xslt1.0变量问题
我有以下模板:xslt1.0变量问题,xslt,Xslt,我有以下模板: <xsl:template name="theday"> <xsl:param name="thisday" /> <xsl:variable name='holiday' select='foo'/><!-- made this static for testing --> <td class="{$holiday}"> <!-- no value is inserted in cla
<xsl:template name="theday">
<xsl:param name="thisday" />
<xsl:variable name='holiday' select='foo'/><!-- made this static for testing -->
<td class="{$holiday}"> <!-- no value is inserted in class -->
<a>
<xsl:attribute name='href'><xsl:value-of
select="concat('?date=',$thisday)" /></xsl:attribute>
<xsl:value-of select="date:day-in-month($thisday)" />
</a>
</td>
</xsl:template>
我希望得到类似以下内容的HTML:
<td class="foo">
<a href="?date=2009-11-02">2</a>
</td>
不幸的是,我得到:
<td class="">
<a href="?date=2009-11-02">2</a>
</td>
我缺少什么?试试这个:
<xsl:variable name='holiday'>foo</xsl:variable>
foo
或
工作原理:select
属性要求计算表达式;由于上下文中可能没有foo
元素,因此它被解析为空字符串。请尝试以下操作:
<xsl:variable name='holiday'>foo</xsl:variable>
foo
或
工作原理:
select
属性要求计算表达式;由于上下文中可能没有foo
元素,因此将其解析为空字符串。问题在于
选择节点列表“foo”(为空)而不是字符串foo。如果您有xml
<a>
<foo>B</foo>
</a>
问题是
选择节点列表“foo”(为空)而不是字符串foo。如果您有xml
<a>
<foo>B</foo>
</a>