RE: check if nodes match xpath expression

Subject: RE: check if nodes match xpath expression
From: "Mabry, F. DR EECS" <df6954@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 30 Nov 2000 14:24:40 -0500
I don't believe that you can in standard XSL-T (version 1.0) have a
"variable" reference in your XSL-T template match Xpath expression.  Saxon
has an extension (which will probably/hopefully be included in version 1.1)
that allows use of such a reference in the match of a template.

An alternative is to use XSL-T to construct a transform file that makes the
parameter a constant and do the transform in two steps.  This is similar to
the Schematron XSL-T of RJ.  Let me know if you pursue it and need further
help.  

Check at:
http://users.iclway.co.uk/mhkay/saxon/
or 
http://users.iclway.co.uk/mhkay/saxon/saxon6.0.1/index.html

for information.  

Mike Kay's book "XSLT Programmer's Reference" at page 118 has a complete
explanation of the problems associated with allowing attribute value
templates in Xpath expressions.

Hope this helps. 

Frank

Dr. Frank J. Mabry, Jr.
Dept. of EE&CS
U.S. Military Academy
West Point, NY 10996
Phone: 845-938-2960
Email: df6954@xxxxxxxxxxxxxxx


 -----Original Message-----
From: 	Christian Nentwich [mailto:c.nentwich@xxxxxxxxxxxx] 
Sent:	Thursday, November 30, 2000 12:27 PM
To:	XSL-List@xxxxxxxxxxxxxxxx
Subject:	check if nodes match xpath expression


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


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


Current Thread