This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: XSL to generate XPaths


Hi Michael,

> Here I needed to check if the current node is an element:
>
>   count(.|../*)=count(../*) and count(../*[name()=name(current())]) > 1"
>
> If anyone wants the new version of the whole thing, please let me know.

The easiest way to test whether the current node is an element is
with:

  self::*

This selects the current node if it is an element (with any name); if
a node is selected through this path, then the resultant node set
evaluates as boolean true.
  
(Similarly, you can check whether the current node is a comment with
self::comment(), a text node with self::text() and a processing
instruction with self::processing-instruction().  It's only with
attributes and namespace nodes that you can't use the self:: axis
because they're only accessible through the attribute:: and
namespace:: axes.)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]