[xsl] Distinguishing the root node of a node-set

Subject: [xsl] Distinguishing the root node of a node-set
From: <sthomas2@xxxxxxx>
Date: Thu, 8 Mar 2007 16:37:16 -0500
This might win a prize for silly questions, but my brain has been
exhausted by it (and I can't locate an answer in the voluminous FAQ).
Apologies in advance.

XSLT 1 (Saxon6.5.5 to be precise)

I have a variable that contains a node-set. (It was populated with via
select). I need to identify the root node of the variable's contents.
For example, the variable var may contain


In other words, test="$var/child" returns true.

I'd like to test whether the variable is indeed a <root1> (instead of,
for example a <root2>).

The closest I've come is

  <xsl:when test="name($var)='root1'">
    <!-- do something -->
  <!-- other options -->

This works when namespaces aren't involved, but once namespaces come
into play there's a problem. If the input document uses a different
namespace prefix than the stylesheet, then the test won't work. (Which
is probably pretty obvious for most folks reading this list.)

Surely there is a really simple, obvious way to construct the test I
need; I'm just too dense to figure it out.



Current Thread