This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: check if nodes match xpath expression


Christian,

The application you're describing is called the XPath Visualiser and
has been publicly announced 3 months ago. You can download it at
http://www.vbxml.com/xpathvisualizer

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 www.w3c.org, www.xslt.com, www.xmlinfo.com,
www.xmlsoftware.com (and of course www.vbxml.com :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.

Answer: 
<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()">
  ..
</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



__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]