[yelp-xsl] mal-sort.xsl: Fix sorting for groups on mal:links



commit 4280cbf744f12753feed0d487d73e72cf8043796
Author: Shaun McCance <shaunm gnome org>
Date:   Sun Apr 24 20:01:50 2011 -0400

    mal-sort.xsl: Fix sorting for groups on mal:links

 xslt/mallard/common/mal-link.xsl |   14 +++++-----
 xslt/mallard/common/mal-sort.xsl |   51 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 57 insertions(+), 8 deletions(-)
---
diff --git a/xslt/mallard/common/mal-link.xsl b/xslt/mallard/common/mal-link.xsl
index 8b64e43..106bdb1 100644
--- a/xslt/mallard/common/mal-link.xsl
+++ b/xslt/mallard/common/mal-link.xsl
@@ -399,12 +399,7 @@ The output is a result tree fragment.  To use these results, call
 -->
 <xsl:template name="mal.link.topiclinks">
   <xsl:param name="node" select="."/>
-  <xsl:variable name="linkid">
-    <xsl:call-template name="mal.link.linkid">
-      <xsl:with-param name="node" select="$node"/>
-    </xsl:call-template>
-  </xsl:variable>
-  <xsl:variable name="groups">
+  <xsl:param name="groups">
     <xsl:variable name="_groups">
       <xsl:choose>
         <xsl:when test="$node/mal:links[ type = 'topic']">
@@ -436,7 +431,7 @@ The output is a result tree fragment.  To use these results, call
     <xsl:if test="not(contains($_groups, ' #last '))">
       <xsl:text>#last </xsl:text>
     </xsl:if>
-  </xsl:variable>
+  </xsl:param>
   <xsl:variable name="groupslist" select="str:split($groups)"/>
   <xsl:variable name="defaultpos">
     <xsl:for-each select="$groupslist">
@@ -445,6 +440,11 @@ The output is a result tree fragment.  To use these results, call
       </xsl:if>
     </xsl:for-each>
   </xsl:variable>
+  <xsl:variable name="linkid">
+    <xsl:call-template name="mal.link.linkid">
+      <xsl:with-param name="node" select="$node"/>
+    </xsl:call-template>
+  </xsl:variable>
   <xsl:variable name="links">
     <xsl:for-each select="$node/mal:info/mal:link[ type = 'topic']">
       <xsl:variable name="linklinkid">
diff --git a/xslt/mallard/common/mal-sort.xsl b/xslt/mallard/common/mal-sort.xsl
index c9545e0..ef7f772 100644
--- a/xslt/mallard/common/mal-sort.xsl
+++ b/xslt/mallard/common/mal-sort.xsl
@@ -99,14 +99,34 @@ topic or next links.
     </xsl:if>
   </xsl:if>
 
+  <xsl:variable name="page" select="document($node/@cache:href)"/>
+
   <xsl:variable name="topics">
     <xsl:for-each select="$node | $node//mal:section">
+      <xsl:variable name="positionsort" select="position()"/>
+      <xsl:variable name="groups">
+        <xsl:choose>
+          <xsl:when test="self::mal:page">
+            <xsl:call-template name="_mal.sort.getgroups">
+              <xsl:with-param name="node" select="$page/mal:page"/>
+            </xsl:call-template>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:variable name="sectid">
+              <xsl:value-of select="substring-after(@id, '#')"/>
+            </xsl:variable>
+            <xsl:call-template name="_mal.sort.getgroups">
+              <xsl:with-param name="node" select="$page//mal:section[ id = $sectid]"/>
+            </xsl:call-template>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
       <xsl:variable name="subtopics">
         <xsl:call-template name="mal.link.topiclinks">
           <xsl:with-param name="node" select="."/>
+          <xsl:with-param name="groups" select="$groups"/>
         </xsl:call-template>
       </xsl:variable>
-      <xsl:variable name="positionsort" select="position()"/>
       <xsl:for-each select="exsl:node-set($subtopics)/*">
         <xsl:copy>
           <xsl:attribute name="positionsort">
@@ -153,5 +173,34 @@ topic or next links.
   </xsl:for-each>
 </xsl:template>
 
+<xsl:template name="_mal.sort.getgroups">
+  <xsl:param name="node" select="."/>
+  <xsl:variable name="groups">
+    <xsl:text> </xsl:text>
+    <xsl:choose>
+      <xsl:when test="$node/mal:links[ type = 'topic']">
+        <xsl:for-each select="$node/mal:links[ type = 'topic']">
+          <xsl:text> </xsl:text>
+          <xsl:value-of select="@groups"/>
+        </xsl:for-each>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$node/@groups"/>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:text> </xsl:text>
+  </xsl:variable>
+  <xsl:if test="not(contains($groups, ' #first '))">
+    <xsl:text> #first </xsl:text>
+  </xsl:if>
+  <xsl:value-of select="$groups"/>
+  <xsl:if test="not(contains($groups, ' #default '))">
+    <xsl:text> #default </xsl:text>
+  </xsl:if>
+  <xsl:if test="not(contains($groups, ' #last '))">
+    <xsl:text> #last </xsl:text>
+  </xsl:if>
+</xsl:template>
+
 </xsl:stylesheet>
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]