Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi all,
I'm having a bit of trouble here to get the right output from an xslt file.
I have a comma separated string which I want to split into multiple unordered lists. After ever 5th value I want to make a new <ul>
Has anyone done this before? :-) If so, I'd be greatful to get a hint!
I've tried with Chriztians example to split values into rows and columns for a table, but with no luck :-/
Thanks a lot in advance!
Hey Bo,
Here's some XSLT which you should be able to tweak to get working, it's a concept here as I had some other non related stuff going on, but I have it working perfectly.
Hope it helps
<xsl:variable name="maxItems" value="5">
You're the man Rich! :) Worked perfect!
Thanks a lot.
/ Bo
Hi Bo,
Just for the benefit of having a "real" XSLT solution to this :-) - here's a self-contained stylesheet to demonstrate how it's done:
<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" exclude-result-prefixes="umb" > <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:variable name="data" select="'one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve'" /> <xsl:variable name="groupSize" select="5" /> <xsl:template match="/"> <xsl:variable name="values" select="umb:Split($data, ',')//value" /> <xsl:apply-templates select="$values[(position() mod $groupSize) = 1]" mode="group" /> </xsl:template> <xsl:template match="value" mode="group"> <ul> <xsl:apply-templates select=". | following-sibling::*[position() < $groupSize]" mode="item" /> </ul> </xsl:template> <xsl:template match="value" mode="item"> <li> <xsl:value-of select="." /> </li> </xsl:template> </xsl:stylesheet>
/Chriztian
As I was posting I knew that Chriztian would come along with a 'real' solution :)
Nice solution too!
Rich
Mr. XSLT to the rescue! ;) Thanks a lot both of you!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Render comma separated string into several uls
Hi all,
I'm having a bit of trouble here to get the right output from an xslt file.
I have a comma separated string which I want to split into multiple unordered lists. After ever 5th value I want to make a new <ul>
Has anyone done this before? :-) If so, I'd be greatful to get a hint!
I've tried with Chriztians example to split values into rows and columns for a table, but with no luck :-/
Thanks a lot in advance!
Hey Bo,
Here's some XSLT which you should be able to tweak to get working, it's a concept here as I had some other non related stuff going on, but I have it working perfectly.
Hope it helps
<xsl:variable name="maxItems" value="5">
<xsl:template> <ul> <xsl:apply-templates select="$currentPage/ancestor-or-self::*[@level=1]/descendant::Country[@isDoc]"> </xsl:apply-templates> </ul> </xsl:template> <xsl:template match="Country[@isDoc]">You're the man Rich! :) Worked perfect!
Thanks a lot.
/ Bo
Hi Bo,
Just for the benefit of having a "real" XSLT solution to this :-) - here's a self-contained stylesheet to demonstrate how it's done:
/Chriztian
As I was posting I knew that Chriztian would come along with a 'real' solution :)
Nice solution too!
Rich
Mr. XSLT to the rescue! ;) Thanks a lot both of you!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.