Search

<xsl:template match="homepage-slideshow/entry">

          <ul class="slides">
                <li> 
                    <img src="{$root}/workspace/{slide-image}" />
            </li>
          </ul>

</xsl:template>

As you can see in the code above I would like to format my XML as an Unordered list. Obviously though, the way I have coded this is incorrect and the result is multiple lists, rather than a single list with many list items.

What is the best way to achieve the desired result with XSLT?

Something like

<xsl:template match="homepage-slideshow">
    <ul class="slides">
        <xsl:apply-templates select="entry"/>
    </ul>
</xsl:template>

<xsl:template match="homepage-slideshow/entry">
    <li>
        <img src="{$workspace}/{slide-image}" />
    </li>
</xsl:template>

should do it. You have on template there that matches the parent homepage-slideshow element that creates the ul and apply the templates for each of its child entry elements which create the lis.

Have a look at this snippet on xpathr.

That worked, slightly different method to what I expected but it makes perfect sense. Thanks!

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