我应该什么时候使用<copy-of>
代替<apply-templates>
?
他们的独特作用是什么?大部分时间都在更换<apply-templates>
with <copy-of>
给出奇怪的输出。这是为什么?
Input:
<a>
<b>asdf</b>
<b title="asdf">asdf</b>
</a>
Xslt 1:
<xsl:stylesheet ... >
<xsl:template match="a">
<xsl:copy-of select="b" />
</xsl:template>
</xsl:stylesheet>
XML输出1:
<b>asdf</b>
<b title="asdf">asdf</b>
Xslt 2:
<xsl:stylesheet ... >
<xsl:template match="a">
<xsl:apply-templates select="b" />
</xsl:template>
<xsl:template match="b" priority="0">
<b><xsl:value-of select="." /></b>
<c><xsl:value-of select="." /></c>
</xsl:template>
<xsl:template match="b[@title='asdf']" priority="1">
<b title="{@title}"><xsl:value-of select="@title" /></b>
</xsl:template>
</xsl:stylesheet>
XML输出2:
<b>asdf</b>
<c>asdf</c>
<b title="asdf">asdf</b>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)