Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rich Green 2246 posts 4008 karma points
    Apr 16, 2010 @ 09:01
    Rich Green
    0

    Sorting nodes alphabetically from a comma separated node list

    Hi,

    I have some XSLT which works out all the node ID's I need to display, for example my code returns 3459,3567,3486

    I then split these and loop through them to show details of the 3 nodes.

    3459 - A Product 

    3567 - Z Product

    3486 - S Product

    However I would like to display these alphabetically?

    Using the XSLT sort function won't work as I'm grabbing each record individually, would appreciate any ideas.

    Many thanks

    Rich

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Apr 16, 2010 @ 09:14
    Chriztian Steinmeier
    3

    Hi Rich,

    There's a good old trick that'll put those into the same node set:

       <xsl:variable name="$nodeIDs" select="1200,1203,3489,2309" />
    
        <xsl:variable name="root" select="$currentPage/ancestor-or-self::root" />
    
        <xsl:template match="/">
            <xsl:for-each select="$root//node[contains(concat(',', $nodeIDs, ','), concat(',', @id, ','))]">
                <xsl:sort select="@nodeName" />
    
                ...
    
            </xsl:for-each>
        </xsl:template>
    

    /Chriztian

  • Rich Green 2246 posts 4008 karma points
    Apr 16, 2010 @ 09:55
    Rich Green
    0

    Chriztian,

    Thanks so much! Perfect!

    :)

     

    Rich

Please Sign in or register to post replies

Write your reply to:

Draft