<xsl:apply-templates />和<xsl:apply-templates select ="之间有什么区别." />

joe*_*joe 8 xml xslt xpath

<xsl:apply-templates />和之间有什么区别<xsl:apply-templates select="." />.我认为select="."没有必要,但根据我的使用情况,我会得到不同的结果.

对不起,如果这是重复.我试过搜索这个问题但找不到任何东西.

Dim*_*hev 18

<xsl:apply-templates />和 之间有什么区别 <xsl:apply-templates select="." />

第一条指令:

<xsl:apply-templates />
Run Code Online (Sandbox Code Playgroud)

是一个简写:

<xsl:apply-templates select="child::node()" />
Run Code Online (Sandbox Code Playgroud)

第二条指令:

<xsl:apply-templates select="." />
Run Code Online (Sandbox Code Playgroud)

是一个简写:

<xsl:apply-templates select="self::node()" />
Run Code Online (Sandbox Code Playgroud)

正如我们所看到的,不仅这两个指令是不同的(前者将模板应用于所有子节点,后者将模板应用于当前节点),但后者是危险的,并且通常可能导致无限循环!