Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有这样的 XML:
<xsl:template match="assessment | section "> . . . </xsl:template>
我这样做是因为我主要想以相同的方式对待assessment和section节点。但是,我确实想以不同的方式对待它们。我如何判断比赛是 forassessment还是 for section?
assessment
section
做这样的事情:
<xsl:if test="name()='section'"> </xsl:if>
您可以测试:
self::assessment
这比使用该name()功能更有效。
name()
但是在这种情况下,我会将公共代码放在另一个模板中(命名或命名模式),并将像这样实例化公共处理:
<xsl:apply-templates select="." mode="common"/>