Alphabetically sorting nodes Options
timgaunt
Posted: Monday, January 07, 2008 11:29:11 AM

Rank: Aficionado

Joined: 10/31/2007
Posts: 111
Location: Birmingham (UK)
Morning,

Another day, another issue.

I have the following XML:

Code:

<node>
  <product>
    <manual title="c" />
  </product>
  <product>
    <manual title="a" />
  </product>
  <product>
    <manual title="b" />
  </product>
</node>


Now I would like to output a list of all documents for a downlaods area in alphabetical order however I think my XSLT is wrong as I beleive it will be ordering on the <product> node, not <manual>, any pointers?:

Code:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="msxml umbraco.library">
    
    <xsl:output method="html"/>
    
    <xsl:param name="currentPage"/>
       
    <xsl:template match="/">
        <ul>
        <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/descendant-or-self::node[string(./data [@alias='umbracoNaviHide']) != '1' and @nodeTypeAlias = 'manual']">
        <xsl:sort select="title" order="ascending" data-type="text" />

            <li>
                    <xsl:value-of select="data [@alias = 'title']" />
            </li>
                
        </xsl:for-each>
        
        </ul>
    </xsl:template>

</xsl:stylesheet>


TIA

Tim

Managing Director at The Site Doctor Ltd - My personal blog is here - Umbraco Newbie ;)
kenny
Posted: Monday, January 07, 2008 11:40:14 AM

Rank: Aficionado

Joined: 8/12/2006
Posts: 136
Location: Norway
Code:

<xsl:sort select="data [@alias = 'title']" order="ascending" />


Kenneth Solberg - xeed* - core dev - level 2 cert pro - my blog
timgaunt
Posted: Monday, January 07, 2008 11:43:10 AM

Rank: Aficionado

Joined: 10/31/2007
Posts: 111
Location: Birmingham (UK)
Sorry, I was being a numpty, for others having the same issue you need to use the following sort:

Code:

<xsl:sort
    select="data [@alias = 'title']"
    order="ascending"
    data-type="text" />


Tim

Managing Director at The Site Doctor Ltd - My personal blog is here - Umbraco Newbie ;)
timgaunt
Posted: Monday, January 07, 2008 4:07:01 PM

Rank: Aficionado

Joined: 10/31/2007
Posts: 111
Location: Birmingham (UK)
Yeah thanks Kennith, replied at the same time ;)

Managing Director at The Site Doctor Ltd - My personal blog is here - Umbraco Newbie ;)
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.