xsl-list
[Top] [All Lists]

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

2010-11-08 06:04:36
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


--~------------------------------------------------------------------
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>
--~--

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