RE: [xsl] Checking node value against splitted string/list?

Subject: RE: [xsl] Checking node value against splitted string/list?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 14 Aug 2006 11:47:13 +0100
>   Mmh, you meant the name of the element.  So use instead:
> 
>     .[self::firstname or self::lastname or self::email]
> 
>   Regards,
> 

Actually you can't write .[...] in XPath 1.0 (a peculiar accident of the
syntax rules). But you can just write:

<xsl:if test="self::firstname or self::lastname or self::email">

or if you prefer

<xsl:if test="self::firstname|self::lastname|self::email">

Note that the self::xxx form is a better way of testing the element name
than name()='xxx', because (a) it's namespace-aware, and (b) it's easier to
optimize. The two reasons are related - the only reason that the test
name()='xxx' can't be rewritten as self::xxx is that the former expression
has to check the prefix rather than the namespace URI. Implementations are
likely to be optimized for checking the URI, because that's what happens
most of the time - there are very few operations in XPath that require
access to the prefix.

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

Current Thread