xsl-list
[Top] [All Lists]

RE: [xsl] Problem getting position of node

2006-03-21 02:22:23
<xsl:template match="@*">
<xsl:attribute name="{name(.)}">
<xsl:value-of select="."/>
<xsl:number count="*"/>
</xsl:attribute>
</xsl:template>


As you can see, the context node is an attribute node and Iam 
getting the
error,
 Attribute nodes cannot be numbered.

Whichever processor is telling you that attributes cannot be numbered is
wrong. It doesn't make much sense to number them, but it's perfectly
permissible to do it, and the result is well defined.

However, if you're positioned on an attribute and you want the number of the
parent element, in XSLT 2.0 you can do

<xsl:number select=".." count="*"/>

or in XSLT 1.0

<xsl:for-each select="..">
  <xsl:number count="*"/>
</xsl:for-each>


Michael Kay
http://www.saxonica.com/



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--