diff options
Modified category sort logic to fit 7db86c6
* correct sorting by size requires the "data-type" attribute to be set to "number"
* pages are now first sorted as two halves
** descending / ascending respectively
* the sorted set is then split into actual halves
* the output loop alternates between these halves
* changed test for existance to actual test for existance instead of calculating it by ourselfes
-rw-r--r-- | source/99_result/category/category.xsl | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/source/99_result/category/category.xsl b/source/99_result/category/category.xsl index 1713c84..e69640b 100644 --- a/source/99_result/category/category.xsl +++ b/source/99_result/category/category.xsl @@ -45,24 +45,36 @@ <xsl:variable name="sorted_pages"> <xsl:for-each select="page"> - <xsl:sort select="digest/@size" order="ascending"/> - <xsl:copy-of select="."/> + <xsl:sort select="digest/@size" data-type="number" order="descending"/> + + <xsl:if test="position() <= $boundary"> + <xsl:copy-of select="."/> + </xsl:if> + </xsl:for-each> + + <xsl:for-each select="page"> + <xsl:sort select="digest/@size" data-type="number" order="ascending"/> + + <xsl:if test="position() < $boundary"> + <xsl:copy-of select="."/> + </xsl:if> </xsl:for-each> </xsl:variable> - <xsl:for-each select="xalan:nodeset($sorted_pages)/page"> + <xsl:variable name="lower_half" select="xalan:nodeset($sorted_pages)/page[position() <= $boundary]"/> + <xsl:variable name="upper_half" select="xalan:nodeset($sorted_pages)/page[position() > $boundary]"/> + + <xsl:for-each select="$lower_half"> <xsl:variable name="index" select="position()"/> - <xsl:if test="$index <= $boundary"> + <xsl:call-template name="page_entry"> + <xsl:with-param name="source" select="."/> + </xsl:call-template> + + <xsl:if test="$upper_half[$index]"> <xsl:call-template name="page_entry"> - <xsl:with-param name="source" select="."/> + <xsl:with-param name="source" select="$upper_half[$index]"/> </xsl:call-template> - - <xsl:if test="$ceiling - $index != $index"> - <xsl:call-template name="page_entry"> - <xsl:with-param name="source" select="xalan:nodeset($sorted_pages)/page[$ceiling - $index]"/> - </xsl:call-template> - </xsl:if> </xsl:if> </xsl:for-each> </ul> |