xsl-list
[Top] [All Lists]

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

2007-03-08 14:38:01

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

<root1><child/></root1>

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:choose>
  <xsl:when test="name($var)='root1'">
    <!-- do something -->
  </xsl:when>
  <!-- other options -->
</xsl:choose>

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.

TIA,

Stephen


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