我收到警告
模糊规则匹配
来自模板copyReference和身份转换的处理器。
<xsl:template name="processChildNodes">
<xsl:param name="El"/>
<xsl:for-each select="$El/node()">
<xsl:choose>
<xsl:when test="@sameas">
<xsl:apply-templates mode="copyReference" select="id(substring-after(@sameas, '#'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template match="*" mode="copyReference" name="copyReference">
<xsl:copy>
<xsl:apply-templates select="@* except (@stem.dir, @stem.sameas)"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node() | @*" mode="#all">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
这是一个 xml 片段:
<layer>
<note oct="3" pname="b" stem.dir="up" stem.sameas="#note_17544b" xml:id="note_17544"/>
</layer>
<layer>
<note oct="4" pname="d" xml:id="note_17592"/>
<note sameas="#note_17544" xml:id="note_17544b"/>
</layer>
我想要做的只是复制从@sameas-attribute 引用的节点,而没有@stem.dir 和@stem.sameas。可能有不同的节点 local-names() 将应用于。所以我宁愿不在copyReference模板的@match-attribute 中指定节点名称。我想如果我通过@select-attribute 传递我需要的节点并添加@mode,它将只匹配我需要的。实际上它有效,但是当我收到警告时,应该是错误的。