select 不匹配的参数值是多少?

What is the value of a parameter with a non-matching select?

比如下面的XSL,用下面的XML调用,'param'的值是多少?

问题是我需要测试不匹配的属性,它显然不是空字符串。

<el></el><!-- has no attribute 'attr' to match -->

<xsl:template match="*">
   <xsl:call-template name="template">
        <xsl:with-param name="param" select="@attr" />
    </xsl:call-template>
</xsl:template>

 <xsl:template name="template">
    <xsl:param name="param" />
    <xsl:value-of select="$param" />
</xsl:template>

该值将是空节点集

你可以看一下规范here

本段末尾的注释也提供了线索:

NOTE:One convenient way to specify the empty node-set as the default value of a parameter is: <xsl:param name="x" select="/.."/>

因为根节点没有父节点,所以这总是return一个空节点。