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
I've created a list displaying child nodes and wondered if it were possible to sort the list alphabetically by the second word in the node name?
Hi JV
Hmm, that's a good question...I guess it should be possible to do a substring on the string you want the nodes to be sorted by and then instruct it to start by the 2. character....like this
<xsl:sort select="substring(title,2)" />
This will make it start from the 2. character. Have a look at this reference if in doubt http://zvon.org/xxl/XSLTreference/Output/function_substring.html
I'm a bit unsure if you can use it directly in the select of sort...perhaps you need to assign it to a variable and use that in the sort select...
Hope this helps.
/Jan
Hi JV,
You can do that with the substring-after() function:
<xsl:sort select="substring-after(@nodeName, ' ')" data-type="text" order="ascending" />
and you can even add a second sort instruction to subsequently sort by the first word, if desired:
<xsl:sort select="substring-after(@nodeName, ' ')" data-type="text" order="ascending" /> <xsl:sort select="substring-before(@nodeName, ' ')" data-type="text" order="ascending" />
/Chriztian
Thanks Chriztian!
That's a very handy piece of code, especially in my case as I am sorting a list of staff members by surname.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Alphabetical sort by second word in the node name
I've created a list displaying child nodes and wondered if it were possible to sort the list alphabetically by the second word in the node name?
Hi JV
Hmm, that's a good question...I guess it should be possible to do a substring on the string you want the nodes to be sorted by and then instruct it to start by the 2. character....like this
<xsl:sort select="substring(title,2)" />
This will make it start from the 2. character. Have a look at this reference if in doubt http://zvon.org/xxl/XSLTreference/Output/function_substring.html
I'm a bit unsure if you can use it directly in the select of sort...perhaps you need to assign it to a variable and use that in the sort select...
Hope this helps.
/Jan
Hi JV,
You can do that with the substring-after() function:
and you can even add a second sort instruction to subsequently sort by the first word, if desired:
/Chriztian
Thanks Chriztian!
That's a very handy piece of code, especially in my case as I am sorting a list of staff members by surname.
is working on a reply...