xsl-list
[Top] [All Lists]

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

2002-10-16 08:20:25
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



<Prev in Thread] Current Thread [Next in Thread>