|
Subject: Re: [xsl] Determining if an optional attribute is present From: Evan Lenz <evan@xxxxxxxxxxxx> Date: Wed, 18 Oct 2006 05:37:36 -0700 |
<xsl:template mode="default-attributes" match="Method | Cal | Blank"> <xsl:attribute name="revision">0</xsl:attribute> </xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates mode="default-attributes" select="."/>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template> <!-- By default, don't add any default attributes -->
<xsl:template mode="default-attributes" match="*"/> <!-- Identity rule for child nodes -->
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates mode="default-attributes" select="."/>
<xsl:apply-templates mode="attributes" select="."/>
<xsl:apply-templates mode="content" select="."/>
</xsl:copy>
</xsl:template> <!-- By default, don't add default attributes -->
<xsl:template mode="default-attributes match="*"/> <!-- By default, process all of the element's attributes -->
<xsl:template mode="attributes" match="*">
<xsl:apply-templates select="@*"/>
</xsl:template> <!-- By default, process the element's children -->
<xsl:template mode="content" match="*">
<xsl:apply-templates/>
</xsl:template>
<!-- Identity rule for attributes --> <xsl:template match="@*"> <xsl:attribute name="{name()}" namespace="{namespace-uri()}"> <xsl:apply-templates mode="attribute-value" select="."/> </xsl:attribute> </xsl:template>
<!-- By default, use the given value of the attribute -->
<xsl:template mode="attribute-value" match="@*">
<xsl:value-of select="."/>
</xsl:template>"How XSLT Works" http://www.oreilly.com/catalog/xsltpr/chapter/index.html
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Determining if an optiona, David Carlisle | Thread | [xsl] Can axis specifiers be used i, ms |
| Re: [xsl] Challenge: create xPath 2, Abel Braaksma | Date | [xsl] FW: 2 XML Files, 1 XSLt Outpu, McDonald, Shaun |
| Month |