0
請原諒我的初學者問題。xslt遞歸基礎知識
我已經看過很多次這樣的xsl模板,我不知道它實際上做了什麼。有人可以解釋一下嗎?謝謝!
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
請原諒我的初學者問題。xslt遞歸基礎知識
我已經看過很多次這樣的xsl模板,我不知道它實際上做了什麼。有人可以解釋一下嗎?謝謝!
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
該模板的身份轉換模板,它匹配與文檔節點和命名空間節點之外的任何節點並執行節點的淺表副本,然後處理自己的屬性和子節點(至於那些存在)。
該模板通常是想要更改,刪除和/或添加某些節點的轉換的起點,因爲您可以使用例如「
<xsl:template match="foo">
<bar>
<xsl:apply-templates select="@* | node()"/>
</bar>
</xsl:template>
轉化foo
元素bar
元素,例如
<xsl:template match="baz"/>
刪除baz
元件和用例如,
<xsl:template match="foobar">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<whatever>...</whatever>
</xsl:copy>
</xsl:template>
到whatever
元素添加到foobar
元件。
再次感謝我回答所有問題! –