RE: [xsl] Fwd: Built-in *@ vs. node()

Subject: RE: [xsl] Fwd: Built-in *@ vs. node()
From: Jarno.Elovirta@xxxxxxxxx
Date: Wed, 16 Oct 2002 18:20:25 +0300
Hi,

> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet
>  version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>  <xsl:output method="xml" encoding="iso-8859-1" indent="yes"/>
> 
> <xsl:template match="node()">
>    <xsl:copy>
>       <xsl:apply-templates select="@*"/>
>       <xsl:apply-templates/>
>    </xsl:copy>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> It doesnt copy attribute nodes and i dont know why it doesnt. It
> matches the default attribute template which i thought would be
> overriden by <xsl:template match="node()">

Nope, because "node()" pattern uses the child axis, and while attributes are nodes, they are accessible only using the "attribute" axis or abbreviation "@" . Thus use

  <xsl:template match="@*|node()">
    ...

Cheers,

Jarno

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread