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]
Other format: [Raw text]

Re: selecting with text nodes


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


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