tags:

views:

77

answers:

2

This code selects the nodes, I want to work on...:

<xsl:variable name="rootTextpageNode" 
     select="$currentPage/ancestor-or-self::node [@level = 2 and
             @nodeTypeAlias = 'CWS_Textpage']" />

How can I put a sort/orderby in there, so items with newer createdDate are displayed first?

I'm using the CWS starter kit, and need to change the order of items displayed in SubNavi.xslt

+4  A: 

You can do a sort in the first line after a for-each, like so:

<xsl:for-each select="$rootTextpageNode">
<xsl:sort select="@createDate" order="descending" />
    <xsl:value-of select="@nodeName" />
</xsl:for-each>
sebastiaan
+4  A: 

Not sure if you can add sorting to this variable assignment - typically, you sort either when you apply a template, or when you do a foreach:

<xsl:template match="employees">
    <xsl:apply-templates>
      <xsl:sort select="salary"/>
    </xsl:apply-templates>
  </xsl:template>

or

<xsl:for-each select="catalog/cd">
  <xsl:sort select="artist"/>
  <tr>
    <td><xsl:value-of select="title"/></td>
    <td><xsl:value-of select="artist"/></td>
  </tr>
</xsl:for-each>

See Sorting XSLT and Where to put the Sort information

Marc

marc_s