aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-08-27 23:45:13 +0200
committerAdrian Kummerlaender2014-08-27 23:45:13 +0200
commit60720bddb27c763d8dfb95eae9f1b49506b3897f (patch)
treeb13ea9fe1c81c900454c90776be1e03300f6e72a
parent7db86c66b4f187c4d10776428af1ce8817d3459c (diff)
downloadblog.kummerlaender.eu-60720bddb27c763d8dfb95eae9f1b49506b3897f.tar
blog.kummerlaender.eu-60720bddb27c763d8dfb95eae9f1b49506b3897f.tar.gz
blog.kummerlaender.eu-60720bddb27c763d8dfb95eae9f1b49506b3897f.tar.bz2
blog.kummerlaender.eu-60720bddb27c763d8dfb95eae9f1b49506b3897f.tar.lz
blog.kummerlaender.eu-60720bddb27c763d8dfb95eae9f1b49506b3897f.tar.xz
blog.kummerlaender.eu-60720bddb27c763d8dfb95eae9f1b49506b3897f.tar.zst
blog.kummerlaender.eu-60720bddb27c763d8dfb95eae9f1b49506b3897f.zip
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.xsl34
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() &lt;= $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() &lt; $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() &lt;= $boundary]"/>
+ <xsl:variable name="upper_half" select="xalan:nodeset($sorted_pages)/page[position() &gt; $boundary]"/>
+
+ <xsl:for-each select="$lower_half">
<xsl:variable name="index" select="position()"/>
- <xsl:if test="$index &lt;= $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>