I am trying to figure out the best way to perform a nested for-each & sort. For example my XSLT below performs the following:
Selects a node set.
Sorts by Date attribute.
Performs position() to pull 4 nodes.
Now, the next part is what I am trying to figure out. After step 3 I need to sort by the Date attribute again, but this time in asceding order...now that the data set is narrowed down to 4 nodes. Suggestions? Thanks for the help!!
XSLT:
<xsl:template name="AdmissionsNewsList">
<ul class="stories-list">
<xsl:for-each select="AdmissionsSectionFront/TaxonomyNavigation[@Name='AdmissionsNewsList']/Category/Pages/Page">
<xsl:sort select="@Date" order="descending" />
<xsl:if test="position() < 5">
<!-- NOW THAT THE NODES HAVE BEEN SELECTED, SORTED, AND POSTION LIMIT SET
I NEED TO PERFORM ANOTHER SORT BY DATE (ASCENDING ORDER) HERE ON THE NARROWED DOWN DATA SET -->
<li>
<xsl:choose>
<xsl:when test="normalize-space(@ThumbnailImage)">
<img alt="{@LocalAlternateText}" src="images/{@ThumbnailImage}" />
</xsl:when>
<xsl:otherwise>
<img alt="{@LocalAlternateText}" src="images/News%20Photos/Default.jpg"/>
</xsl:otherwise>
</xsl:choose>
<div>
<h5>
<xsl:value-of select="@Title"/>
</h5>
<br/>
<xsl:apply-templates select="@Abstract"/>
<br/><br/>
<a href="{@URL}" class="full-story">
<xsl:apply-templates select="Page[@Name='Link']/@Target"/>Full Story
</a>
</div>
</li>
</xsl:if>
</xsl:for-each>
</ul>
</xsl:template>
NOTE: This had to be in XSLT 1.0 & is using MSXML 4.0 Parser. Thanks in advance!