Re: [xsl] self::-equivalent for attributes

Subject: Re: [xsl] self::-equivalent for attributes
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 08 Nov 2010 12:04:23 +0000
On 08/11/2010 11:48, Christian Roth wrote:
Hi,

to test if the context node is (e.g.) an ns:par element you usually write:

test="self::ns:par"

What's the equivalent for attributes, that is how do you test if the
context node is an ns:attr attribute? Is there a similar concise expression?


In 2.0:

test=". instance of attribute(ns:par)"

In 1.0:

test="count(. | ../@ns:par) = 1"

But in many cases it might be better to do <xsl:apply-templates select="." mode="x"/> with one template rule for match="@ns:par" and another for everything else.

Michael Kay
Saxonica

Current Thread