You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by rg...@apache.org on 2007/03/03 10:16:22 UTC

svn commit: r514104 - in /forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap: input.xmap resources/stylesheets/descriptorIndex-to-indexByCommon.xsl

Author: rgardler
Date: Sat Mar  3 01:16:20 2007
New Revision: 514104

URL: http://svn.apache.org/viewvc?view=rev&rev=514104
Log:
Use dotdots to calculate relative path to root

Modified:
    forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap/input.xmap
    forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap/resources/stylesheets/descriptorIndex-to-indexByCommon.xsl

Modified: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap/input.xmap
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap/input.xmap?view=diff&rev=514104&r1=514103&r2=514104
==============================================================================
--- forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap/input.xmap (original)
+++ forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap/input.xmap Sat Mar  3 01:16:20 2007
@@ -56,7 +56,9 @@
       
       <map:match pattern="projectDetails/index/by*/siteSnippet.xml">
         <map:generate type="file" src="cocoon:/projectDetails/descriptorIndex.xml" />
-        <map:transform src="{lm:doap.transform.descriptorIndex.siteSnippet_by{1}}"/>
+        <map:transform src="{lm:doap.transform.descriptorIndex.siteSnippet_by{1}}">
+          <map:parameter name="documentPath" value="{0}"/>
+        </map:transform>
         <map:serialize type="xml-document"/>
       </map:match>
       
@@ -103,13 +105,16 @@
       
       <map:match pattern="projectDetails/index/by*.xml">
         <map:generate type="file" src="cocoon:/projectDetails/descriptorIndex.xml" />
-        <map:transform src="{lm:doap.transform.descriptorIndex.indexBy{1}}"/>
+        <map:transform src="{lm:doap.transform.descriptorIndex.indexBy{1}}">
+          <map:parameter name="documentPath" value="{0}"/>
+        </map:transform>
         <map:serialize type="xml-document"/>
       </map:match> 
       
       <map:match pattern="projectDetails/index/by*/*.xml">
         <map:generate type="file" src="cocoon:/projectDetails/descriptorIndex.xml" />
         <map:transform src="{lm:doap.transform.descriptorIndex.indexBy{1}}">
+          <map:parameter name="documentPath" value="{0}"/>
           <map:parameter name="filter" value="{2}"/>
         </map:transform>
         <map:serialize type="xml-document"/>

Modified: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap/resources/stylesheets/descriptorIndex-to-indexByCommon.xsl
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap/resources/stylesheets/descriptorIndex-to-indexByCommon.xsl?view=diff&rev=514104&r1=514103&r2=514104
==============================================================================
--- forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap/resources/stylesheets/descriptorIndex-to-indexByCommon.xsl (original)
+++ forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.doap/resources/stylesheets/descriptorIndex-to-indexByCommon.xsl Sat Mar  3 01:16:20 2007
@@ -21,8 +21,16 @@
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
   xmlns:doap="http://usefulinc.com/ns/doap#">
-  
+    
+  <xsl:param name="documentPath"/>  
+    
   <xsl:template match="descriptor">
+    <xsl:variable name="pathToRoot">
+      <xsl:call-template name="dotdots">
+        <xsl:with-param name="path"><xsl:value-of select="$documentPath"/></xsl:with-param>
+      </xsl:call-template>
+    </xsl:variable>
+    
     <xsl:variable name="name">
       <xsl:choose>
         <xsl:when test="descendant::doap:Project/doap:shortname">
@@ -37,8 +45,7 @@
     <div>
       <p>
         <a>
-          <!-- FIXME: should use the dotdots.xsl to calculate the root -->
-          <xsl:attribute name="href">../../<xsl:value-of select="@href-noext"/>.html</xsl:attribute>
+          <xsl:attribute name="href"><xsl:value-of select="$pathToRoot"/><xsl:value-of select="@href-noext"/>.html</xsl:attribute>
           <xsl:value-of select="$name"/>
         </a>
         <xsl:text> </xsl:text>
@@ -53,5 +60,27 @@
       </p>
     </div>
   </xsl:template>
+  
+  <!-- FIXME: this should come from include of dotdots.xsl in forest core -->
+  <xsl:template name="dotdots">
+    <xsl:param name="path"/>
+    <xsl:variable name="dirs" select="normalize-space(translate(concat($path, 'x'), ' /\', '_  '))"/>
+    <!-- The above does the following:
+       o Adds a trailing character to the path. This prevents us having to deal
+         with the special case of ending with '/'
+       o Translates all directory separators to ' ', and normalize spaces,
+         cunningly eliminating duplicate '//'s. We also translate any real
+         spaces into _ to preserve them.
+    -->
+    <xsl:variable name="remainder" select="substring-after($dirs, ' ')"/>
+    <xsl:if test="$remainder">
+      <xsl:text>../</xsl:text>
+      <xsl:call-template name="dotdots">
+        <xsl:with-param name="path" select="translate($remainder, ' ', '/')"/>
+        <!-- Translate back to /'s because that's what the template expects. -->
+      </xsl:call-template>
+    </xsl:if>
+  </xsl:template>
+  
 </xsl:stylesheet>