Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
xslt1.0变量问题_Xslt - Fatal编程技术网

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>