sorting and conditionals
This is an open discussion with 2 replies, filed under XSLT.
Search
Hi fawx, there might be another way you can write this. Here’s my attempt, although not entirely sure it does exactly what you need (I might have missed something subtle):
My code might not work out of the box — you may need to use EXSLT to cast $entries
into a nodeset for it to work:
exsl:node-set($entries)
(After importing the EXSLT common
namespace.)
Might put you in a different direction…
thanks, nick. that actually is a huge help. i had forgotten about the ability to store a node set in a variable.
edit: i’ve completely missed out on the potential that storing node sets in variables offers in a lot of my projects. this is game-changing for me. thanks again.
Create an account or sign in to comment.
Hey ninjas -
I’m creating a page on a site that is going to use several sorting and search options. Rather than create a separate data source for every single sorting option, which can also be combined with a url parameter to sort under a specific criteria, I’m using some conditionals with xsl:sort. Unfortunately, as I found out and most of you probably know, you’re not allowed to use xsl:sort as a child of xsl:if. This requires a lot of repetitive coding.
I was hoping perhaps someone had a better suggestion? A bit of googling made it appear that going against DRY was probably the only way. This is my first experience with a functional language, so don’t judge too harshly :)
pastebin