logo       
Google Custom Search
    AddThis Social Bookmark Button

svn commit: r448204 - /lenya/trunk/src/modules/sitetree/xslt/navigation/sit: msg#00109

Subject: svn commit: r448204 - /lenya/trunk/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl
Author: josias
Date: Wed Sep 20 06:57:04 2006
New Revision: 448204

URL: http://svn.apache.org/viewvc?view=rev&rev=448204
Log:
[minor] code formatting

Modified:
    lenya/trunk/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl

Modified: lenya/trunk/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl
URL: 
http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl?view=diff&rev=448204&r1=448203&r2=448204
==============================================================================
--- lenya/trunk/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl (original)
+++ lenya/trunk/src/modules/sitetree/xslt/navigation/sitetree2nav.xsl Wed Sep 
20 06:57:04 2006
@@ -22,210 +22,224 @@
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
     xmlns:tree="http://apache.org/cocoon/lenya/sitetree/1.0";
     xmlns:nav="http://apache.org/cocoon/lenya/navigation/1.0";
-    exclude-result-prefixes="tree"
-    >
+    exclude-result-prefixes="tree">
 
-<xsl:param name="url"/> <!-- the links will be relative to this url (must 
start with slash)-->
-<xsl:param name="chosenlanguage"/>
-<xsl:param name="defaultlanguage"/>
-
-<xsl:variable name="relative">
-  <xsl:choose>
-    <xsl:when test="$url != '' and starts-with($url, '/')">true</xsl:when>
-    <xsl:otherwise>false</xsl:otherwise>
-  </xsl:choose>
-</xsl:variable>
-
-<xsl:variable name="root">
-  <xsl:if test="$relative = 'true'">
-    <xsl:call-template name="create-path-to-context">
-      <xsl:with-param name="local-url" select="substring-after($url, '/')"/>
-    </xsl:call-template>
-  </xsl:if>
-</xsl:variable>
-
-<xsl:template name="create-path-to-context">
-  <xsl:param name="local-url"/>
-  <xsl:if test="contains($local-url, '/')">
-    <xsl:variable name="tail" select="substring-after($local-url, '/')"/>
-    <xsl:text>..</xsl:text>
-    <xsl:if test="contains($tail, '/')"><xsl:text>/</xsl:text></xsl:if>
-    <xsl:call-template name="create-path-to-context">
-      <xsl:with-param name="local-url" select="$tail"/>
-    </xsl:call-template>
-  </xsl:if>
-</xsl:template>
-
-<xsl:template match="tree:fragment">
-  <nav:fragment>
-    <xsl:copy-of select="@*"/> 
+  <xsl:param name="url"/> <!-- the links will be relative to this url (must 
start with slash)-->
+  <xsl:param name="chosenlanguage"/>
+  <xsl:param name="defaultlanguage"/>
+
+  <xsl:variable name="relative">
     <xsl:choose>
-      <xsl:when test="@base">
-         <xsl:apply-templates>
-          <xsl:with-param name="previous-url" select="@base"/>
-        </xsl:apply-templates>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:apply-templates/>
-      </xsl:otherwise>
+      <xsl:when test="$url != '' and starts-with($url, '/')">true</xsl:when>
+      <xsl:otherwise>false</xsl:otherwise>
     </xsl:choose>
-  </nav:fragment>
-</xsl:template>
+  </xsl:variable>
+
+  <xsl:variable name="root">
+    <xsl:if test="$relative = 'true'">
+      <xsl:call-template name="create-path-to-context">
+        <xsl:with-param name="local-url" select="substring-after($url, '/')"/>
+      </xsl:call-template>
+    </xsl:if>
+  </xsl:variable>
+
+  <xsl:template name="create-path-to-context">
+    <xsl:param name="local-url"/>
+    <xsl:if test="contains($local-url, '/')">
+      <xsl:variable name="tail" select="substring-after($local-url, '/')"/>
+      <xsl:text>..</xsl:text>
+      <xsl:if test="contains($tail, '/')">
+        <xsl:text>/</xsl:text>
+      </xsl:if>
+      <xsl:call-template name="create-path-to-context">
+        <xsl:with-param name="local-url" select="$tail"/>
+      </xsl:call-template>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="tree:fragment">
+    <nav:fragment>
+      <xsl:copy-of select="@*"/>
+      <xsl:choose>
+        <xsl:when test="@base">
+          <xsl:apply-templates>
+            <xsl:with-param name="previous-url" select="@base"/>
+          </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </nav:fragment>
+  </xsl:template>
 
 
-<xsl:template match="tree:site">
+  <xsl:template match="tree:site">
 
-  <nav:site url="{$root}{$url}" request-url="{$url}">
-    <xsl:copy-of select="@*"/> 
-    <xsl:apply-templates/>
-  </nav:site>
+    <nav:site url="{$root}{$url}" request-url="{$url}">
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </nav:site>
 
-</xsl:template>
+  </xsl:template>
 
 
 <!--
 Resolves the existing language of a node, preferrably
 the default language.
 -->
-<xsl:template name="resolve-existing-language">
-  <xsl:choose>
-    <xsl:when test="tree:label[lang($chosenlanguage)]"><xsl:value-of 
select="$chosenlanguage"/></xsl:when>
-    <xsl:when test="tree:label[lang($defaultlanguage)]"><xsl:value-of 
select="$defaultlanguage"/></xsl:when>
-    <xsl:otherwise><xsl:value-of 
select="tree:label/@xml:lang"/></xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
+  <xsl:template name="resolve-existing-language">
+    <xsl:choose>
+      <xsl:when test="tree:label[lang($chosenlanguage)]">
+        <xsl:value-of select="$chosenlanguage"/>
+      </xsl:when>
+      <xsl:when test="tree:label[lang($defaultlanguage)]">
+        <xsl:value-of select="$defaultlanguage"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="tree:label/@xml:lang"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
 
 
 <!--
 Apply nodes recursively
 -->
-<xsl:template match="tree:node[not(@visible = 'false')]">
+  <xsl:template match="tree:node[not(@visible = 'false')]">
 
   <!-- basic url of parent node -->
-  <xsl:param name="previous-url" select="''"/>
-  
-  <xsl:variable name="existinglanguage">
-    <xsl:call-template name="resolve-existing-language"/>
-  </xsl:variable>
-  
-  <nav:node>
-  
-    <xsl:copy-of select="@id"/>
-    <xsl:copy-of select="@visibleinnav"/>
-    <xsl:copy-of select="@protected"/>
-    <xsl:copy-of select="@folder"/>
-    <xsl:copy-of select="@uuid"/>
-  
-    <!-- basic url - for all nodes -->
-  
-    <xsl:variable name="basic-url">
-      <xsl:text/>
-      <xsl:choose>
-        <xsl:when test="@href">
-          <xsl:value-of select="@href"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:value-of select="concat($previous-url, '/', @id)"/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:variable>  
-    
-    <xsl:variable name="language-suffix">
-      <xsl:text>_</xsl:text><xsl:value-of select="$existinglanguage"/>
-    </xsl:variable>
-    
-    <xsl:variable name="canonical-language-suffix">
-      <xsl:choose>
-        <xsl:when test="$existinglanguage != '' and $defaultlanguage != 
$existinglanguage">
-          <xsl:value-of select="$language-suffix"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <!-- no suffix for default language -->
-        </xsl:otherwise>
-      </xsl:choose>
+    <xsl:param name="previous-url" select="''"/>
+
+    <xsl:variable name="existinglanguage">
+      <xsl:call-template name="resolve-existing-language"/>
     </xsl:variable>
-    
+
+    <nav:node>
+
+      <xsl:copy-of select="@id"/>
+      <xsl:copy-of select="@visibleinnav"/>
+      <xsl:copy-of select="@protected"/>
+      <xsl:copy-of select="@folder"/>
+      <xsl:copy-of select="@uuid"/>
+
+    <!-- basic url - for all nodes -->
+
+      <xsl:variable name="basic-url">
+        <xsl:text/>
+        <xsl:choose>
+          <xsl:when test="@href">
+            <xsl:value-of select="@href"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="concat($previous-url, '/', @id)"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+
+      <xsl:variable name="language-suffix">
+        <xsl:text>_</xsl:text>
+        <xsl:value-of select="$existinglanguage"/>
+      </xsl:variable>
+
+      <xsl:variable name="canonical-language-suffix">
+        <xsl:choose>
+          <xsl:when test="$existinglanguage != '' and $defaultlanguage != 
$existinglanguage">
+            <xsl:value-of select="$language-suffix"/>
+          </xsl:when>
+          <xsl:otherwise>
+          <!-- no suffix for default language --></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+
     <!-- suffix - only when @href is not present -->
-    
-    <xsl:variable name="suffix">
-      <xsl:if test="not(@href)">
-        <xsl:text>.</xsl:text>
+
+      <xsl:variable name="suffix">
+        <xsl:if test="not(@href)">
+          <xsl:text>.</xsl:text>
+          <xsl:choose>
+            <xsl:when test="@suffix">
+              <xsl:value-of select="@suffix"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:text>html</xsl:text>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:if>
+      </xsl:variable>
+
+      <xsl:attribute name="suffix">
+        <xsl:value-of select="$suffix"/>
+      </xsl:attribute>
+      <xsl:attribute name="basic-url">
+        <xsl:value-of select="concat($previous-url, '/', @id)"/>
+      </xsl:attribute>
+      <xsl:attribute name="language-suffix">
+        <xsl:value-of select="$canonical-language-suffix"/>
+      </xsl:attribute>
+
+      <xsl:variable name="canonical-url">
+        <xsl:value-of select="concat($basic-url, $canonical-language-suffix, 
$suffix)"/>
+      </xsl:variable>
+
+      <xsl:variable name="non-canonical-url">
+        <xsl:value-of select="concat($basic-url, $language-suffix, $suffix)"/>
+      </xsl:variable>
+
+      <xsl:if test="$url = $canonical-url or $url = $non-canonical-url">
+        <xsl:attribute name="current">true</xsl:attribute>
+      </xsl:if>
+
+      <xsl:attribute name="href">
         <xsl:choose>
-          <xsl:when test="@suffix">
-            <xsl:value-of select="@suffix"/>
+          <xsl:when test="@href">
+            <xsl:value-of select="@href"/>
+          </xsl:when>
+          <xsl:when test="$relative = 'true' and $root = ''">
+            <xsl:value-of select="substring-after($canonical-url, '/')"/>
           </xsl:when>
           <xsl:otherwise>
-            <xsl:text>html</xsl:text>
+            <xsl:value-of select="concat($root, $canonical-url)"/>
           </xsl:otherwise>
         </xsl:choose>
+      </xsl:attribute>
+
+      <xsl:if test="@mimetype">
+        <xsl:attribute name="mimetype">
+          <xsl:value-of select="@mimetype"/>
+        </xsl:attribute>
       </xsl:if>
-    </xsl:variable>
-    
-    <xsl:attribute name="suffix"><xsl:value-of 
select="$suffix"/></xsl:attribute>
-    <xsl:attribute name="basic-url"><xsl:value-of 
select="concat($previous-url, '/', @id)"/></xsl:attribute>
-    <xsl:attribute name="language-suffix"><xsl:value-of 
select="$canonical-language-suffix"/></xsl:attribute>
-    
-    <xsl:variable name="canonical-url">
-      <xsl:value-of select="concat($basic-url, $canonical-language-suffix, 
$suffix)"/>
-    </xsl:variable>
-    
-    <xsl:variable name="non-canonical-url">
-      <xsl:value-of select="concat($basic-url, $language-suffix, $suffix)"/>
-    </xsl:variable>
-    
-    <xsl:if test="$url = $canonical-url or $url = $non-canonical-url">
-      <xsl:attribute name="current">true</xsl:attribute>
-    </xsl:if>
-    
-    <xsl:attribute name="href">
+
       <xsl:choose>
-        <xsl:when test="@href">
-          <xsl:value-of select="@href"/>
-        </xsl:when>
-        <xsl:when test="$relative = 'true' and $root = ''">
-          <xsl:value-of select="substring-after($canonical-url, '/')"/>
+        <xsl:when test="tree:label[lang($existinglanguage)]">
+          <xsl:apply-templates select="tree:label[lang($existinglanguage)]"/>
         </xsl:when>
         <xsl:otherwise>
-          <xsl:value-of select="concat($root, $canonical-url)"/>
+          <xsl:apply-templates select="tree:label[1]"/>
         </xsl:otherwise>
       </xsl:choose>
-    </xsl:attribute>
-       
-       <xsl:if test="@mimetype">
-         <xsl:attribute name="mimetype"><xsl:value-of 
select="@mimetype"/></xsl:attribute>
-       </xsl:if>
-  
-    <xsl:choose>
-      <xsl:when test="tree:label[lang($existinglanguage)]">
-        <xsl:apply-templates select="tree:label[lang($existinglanguage)]"/>
-      </xsl:when>
-      <xsl:otherwise>
-       <xsl:apply-templates select="tree:label[1]"/>
-      </xsl:otherwise>
-    </xsl:choose>
-         
-    <xsl:apply-templates select="tree:node">
-      <xsl:with-param name="previous-url" select="$basic-url"/>
-    </xsl:apply-templates>
-    
-  </nav:node>
-</xsl:template>
-
-
-<xsl:template match="tree:label">
-  <nav:label>
-       <xsl:copy-of select="@*"/>
-    <xsl:apply-templates/>
-  </nav:label>
-</xsl:template>
-
-
-<xsl:template match="@*|node()" priority="-1">
-  <xsl:copy>
-    <xsl:apply-templates select="@*|node()"/>
-  </xsl:copy>
-</xsl:template>
+
+      <xsl:apply-templates select="tree:node">
+        <xsl:with-param name="previous-url" select="$basic-url"/>
+      </xsl:apply-templates>
+
+    </nav:node>
+  </xsl:template>
+
+
+  <xsl:template match="tree:label">
+    <nav:label>
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </nav:label>
+  </xsl:template>
+
+
+  <xsl:template match="@*|node()" priority="-1">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()"/>
+    </xsl:copy>
+  </xsl:template>
 
 
-</xsl:stylesheet> 
+</xsl:stylesheet>


<Prev in Thread] Current Thread [Next in Thread>