Re: check if nodes match xpath expression

Subject: Re: check if nodes match xpath expression
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 30 Nov 2000 11:03:48 -0800 (PST)

The application you're describing is called the XPath Visualiser and
has been publicly announced 3 months ago. You can download it at

Besides its major function to hilight in the source xml documents all
nodes satisfying a given XPath expression and help the user navigate
through them, the XPath Visualiser displays also the results of scalar
XPath expressions, remembers all the XPath expressions entered for a
particular file and re-instates the appropriate list of expressions
when another XML file is re-loaded.

The collapsible/expandable syntax-coloured outline view also displays
in a special way "container nodes" that are collapsed and "hide" some
occurrence(s) of the result node-set elements.

And there are at least three new major features still to come in the
nearest future...

You can immediately find the answers to your questions in the source
code of this tool, as many other developers have already done. 

During these three months it has gained some popularity and now some
major sites including,,, (and of course :o)) ) have links and
brief descriptions of the XPath Visualiser.

I'd greatly appreciate receiving any comments reflecting your
experience with the XPath Visualiser.

Do enjoy,

Dimitre Novatchev.
P.S. Your original question can be stated more precisely in the
following way: 

What is the XPath expression that evaluates whether the current node
belongs to a given node-set.

<xsl:if test="count(. | $SelectedNodes) = count($SelectedNodes) ">

Christian Nentwich wrote:

Dear all,

we have produced a simple stylesheet that transforms an XML document
into a simple HTML document, with tags in colours, etc. (like the IE5
default stylesheet).

We also have a parameter containing an xpath expression that can be
applied to the XML file. We want to highlight nodes in the translated
HTML page that match the xpath expression, e.g. the stylesheet looks
like this:

<xsl:param name="xpath"/>
<xsl:template match="node()">

This problem seems to appear in different forms in the FAQ but I
couldn't find a proper solution. I know that

<xsl:template match="$xpath">..</..>

won't work. Similarly,

<xsl:template match="node()">
     <xsl:when test="somefunc(.,$xpath)"/>

to check whether the current node matches the xpath, since there is no
such function.

Has anyone had a similar problem?


Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.

 XSL-List info and archive:

Current Thread