Non-repeating / Conditional code within template
This is an open discussion with 3 replies, filed under XSLT.
Search
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 li
s.
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.
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?