check if nodes match xpath expression

Subject: check if nodes match xpath expression
From: Christian Nentwich <c.nentwich@xxxxxxxxxxxx>
Date: Thu, 30 Nov 2000 17:26:59 +0000
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()">
  ..
</xsl:template>

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:choose>
     <xsl:when test="somefunc(.,$xpath)"/>
  </xsl:choose>
</xsl:template>

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

Has anyone had a similar problem?

Thanks,
Christian


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


Current Thread