To learn how xsl:sort works, I suggest you use xsl:value-of
right after the statement that should be doing the sorting:
<xsl:sort select="some/Xpath">
<sort-by>
<xsl:value-of select="some/Xpath">
</sort-by>
I get an odd error when I try to do that.
If I have this:
<xsl:for-each select="//menuItem[ancestor-or-self::menuItem/pageID =
$pageID]">
<xsl:sort select="substring(lastUpdate,1,4)"
order="descending" /> <!-- year -->
<xsl:sort select="substring(lastUpdate,6,2)"
order="descending" /> <!-- month -->
<xsl:sort select="substring(lastUpdate,9,2)"
order="descending" /> <!-- day -->
<xsl:if test="position() < $numberOfItemsToList">
<xsl:call-template name="createItem" />
</xsl:if>
</xsl:for-each>
It seems to work. But once I add in a value-of statement:
<xsl:for-each select="//menuItem[ancestor-or-self::menuItem/pageID =
$pageID]">
<xsl:sort select="substring(lastUpdate,1,4)"
order="descending" /> <!-- year -->
<xsl:value-of select="pageID" />
<xsl:sort select="substring(lastUpdate,6,2)"
order="descending" /> <!-- month -->
<xsl:sort select="substring(lastUpdate,9,2)"
order="descending" /> <!-- day -->
<xsl:if test="position() < $numberOfItemsToList">
<xsl:call-template name="createItem" />
</xsl:if>
</xsl:for-each>
I get this error:
XsltException: 'xsl:sort' cannot be a child of 'xsl:for-each' element.
Which is confusing, as it works just fine with xsl:sort being a child of
xsl:for-each UNTIL I add in a value-of statement.
-Darrel
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--