Re: [xsl] selecting with text nodes

Subject: Re: [xsl] selecting with text nodes
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 2 May 2002 15:22:16 +0100
Hi Ian,

> I want to select only the major recommendations that are not
> completed

First select all the recommendations:

  recommendation

Then filter that node set with a predicate. The predicate needs to be
true if the section element child of the recommendation has the value
'major':

  section = 'major'

and the completed element child of the recommendation has the value
'yes':

  completed = 'yes'

to give:

  recommendation[section = 'major' and completed = 'yes']

It looks as though you want to filter the content of the
recommendation a bit, to remove the completed child element, so you
could simply apply templates to the recommendation elements:

  <xsl:apply-templates
    select="recommendation[section = 'major' and
                           completed = 'yes']" />

and have a template that does what you want with them:

<xsl:template match="recommendation">
  <recommendation>
    <xsl:copy-of select="section | para" />
  </recommendation>
</xsl:template>

> All the examples I can find are based on attributes.

Selecting child elements is just like selecting attributes, except
that you use the child axis rather than the attribute axis (leave off
the '@'). The value of an element is its textual content.

Cheers,

Jeni

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


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


Current Thread