Listing unique values from a set of listcheckboxes
I have a list of subpages that each have a checkboxlist (0-10) to indicate what floor an appartement is on. Appartments can be on multiple floors (duplexes)
I need to get all the pages and their "floor" property, and list all the floors where there are appartments available...once...
You may need to do this in an extension method as there is no way to create an incremental variable in XSLT, Let us know if you need an example on that. Sorry about cluttering your post/question.
Instead of an array, build a sorted node-set of the values ('token' elements) and then pick only the ones that arent' immediately followed by an identical value...
Listing unique values from a set of listcheckboxes
I have a list of subpages that each have a checkboxlist (0-10) to indicate what floor an appartement is on. Appartments can be on multiple floors (duplexes)
I need to get all the pages and their "floor" property, and list all the floors where there are appartments available...once...
$unfiltered returns: 0,0,1,1,1,2,2,3,4,5,5,6,5,6,6,6
$sortedunfiltered returns: 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 5, 6, 6, 6,
Can anyone help me reduce this serie to a distinct list ?
Hi there, I would take a look at using the umbraco.library.Split() function for this. Here's an example.
Then use this to loop over the list...
HTH,
Nik
Ooops, read your question wrong I think...gimme a sec. Sorry.
You may need to do this in an extension method as there is no way to create an incremental variable in XSLT, Let us know if you need an example on that. Sorry about cluttering your post/question.
Thanks,
Nik
Hi Rik,
You can do something like this:
<xsl:variable name="unfilteredtokens"> <tokens> <xsl:for-each select="Exslt.ExsltStrings:tokenize($unfiltered, ',')"> <xsl:sort select="." order="ascending"/> <xsl:copy-of select="." /> </xsl:for-each> </tokens> </xsl:variable> <xsl:variable name="unfilteredset" select="msxml:node-set($unfilteredtokens)/tokens" /> <ul> <xsl:for-each select="$unfilteredtokens[not(. = following-sibling::*[1])]"> <li><xsl:value-of select="." /></li> </xsl:for-each> </ul>
/Chriztian
Nice! That is a great solution. Never thought to use node-set for this sort of thing.
Thanks a lot!
resulting xml:
is working on a reply...