Re: [xsl] wildcards in xpath?

Subject: Re: [xsl] wildcards in xpath?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 24 Jul 2002 14:33:05 +0100
Hi Markus,

> I have a short question to xpath. Is it possible to select all nodes
> which begin with "dino"? I want to do something like this:
> <xsl:for-each select="dino*">

You can select all nodes that are children of the current node with:

  node()

Then you can filter them with a predicate, which is a boolean
expression held in square brackets -- if the expression evaluates as
true for the node then the node is retained, if it evaluates as false,
then the node is ignored:

  node()[...]

Then you can test whether the context node's value starts with a
particular string using the starts-with() function, which takes two
arguments -- the string that you want to test, and the string that it
should start with. You can use the shorthand . to indicate "the value
of the node I'm looking at". So try:

  node()[starts-with(., 'dino')]

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread