Search

Hey,

I have a set of project entries. Each project may or may not contain an image, i.e. it is an optional section field.

I have this code

<xsl:apply-templates select="projects/entry[position() &lt;= 3]" />

which is working fine.

Now I wonder if there’s a way to select the latest 3 entries only from within those records that contain an image node.

Is this possible with XPath?

Thanks for any help!

<xsl:apply-templates select="projects/entry[image != ''][position() &lt;= 3]" />

Hey phoque,

Thank you very very much! Works like a charm.

I didn’t realise you could do two predicates!

You bet!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details