Ah, spoke too soon! I assumed that the "preceding-sibling" would be based on the sort order, however it appears to be based on the original order of the nodes in the database / CMS.
The actual xsl:sort IS working.
How do I make it check the preceding sibling in the search results?!
In the end, I took a different approach! I first did a for-next loop of the category nodes that I wanted to group by, then I did an inner loop which searched for each type.
Trying to Group By with XSLT
Based on other posts and Internet searching, I have ended up with the following attempt to group the output of a xsl:for-each loop.
Sort the nodes based on the template used:
Then detect if the template changes
Unfortunately, the xsl:if is not working ... it always thinks the value of @template is different.
Where have I gone / what have I done wrong?
Hi Gordon,
The test fails because it's actually asking for the <preceding-sibling> childnode's template attribute, which, of course, doesn't exist.
Try this:
- that should get some better results...
/Chriztian
Hi. Try to replace 'preceding-sibling' with 'preceding-sibling::*[1]'.
Thanks all, this is what I have now and seems to work ...
I needed the position() = 1 because otherwise the first template name failed to output.
Ah, spoke too soon! I assumed that the "preceding-sibling" would be based on the sort order, however it appears to be based on the original order of the nodes in the database / CMS.
The actual xsl:sort IS working.
How do I make it check the preceding sibling in the search results?!
In the end, I took a different approach! I first did a for-next loop of the category nodes that I wanted to group by, then I did an inner loop which searched for each type.
It seems to work so I'll go with it ;-)
is working on a reply...