if you want to override a template and change its attribute , you can do this. Here in this example, you are changing @weight value to '2'.
###xml
<xsl:template match="/">
<xsl:apply-templates select="*" mode="copy" />
</xsl:template>
<xsl:template match="content[@name='xxx']" mode="copy">
<xsl:copy>
<xsl:copy-of select="@*" /> <!--copy @* here -->
<xsl:attribute name="name">attachment</xsl:attribute> <!-- override here-->
<xsl:attribute name="weight">2</xsl:attribute>
<xsl:apply-templates select="* | text() | comment()" mode="copy" /> <!-- don't copy @* here, it will reuse input @ -->
</xsl:copy>
</xsl:template>
<xsl:template match="@* | text() | comment()" mode="copy">
<xsl:copy />
</xsl:template>
<!-- Default action, keep recursing and copying -->
<xsl:template match="*" mode="copy">
<xsl:copy>
<xsl:apply-templates select="@* | * | text() | comment()" mode="copy" />
</xsl:copy>
</xsl:template>
'IT > XSL' 카테고리의 다른 글
xsl에서 입력노드를 정확히 카피해서 출력하는 경우 (0) | 2011.11.23 |
---|---|
xpath to filter a specific 'value' of the node (0) | 2011.11.23 |