forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cross...@apache.org
Subject svn commit: r149339 - forrest/trunk/main/webapp/resources/stylesheets/search/book2cinclude-lucene.xsl
Date Tue, 01 Feb 2005 01:04:49 GMT
Author: crossley
Date: Mon Jan 31 17:04:49 2005
New Revision: 149339

URL: http://svn.apache.org/viewcvs?view=rev&rev=149339
Log:
Correctly handle filenames (relative URLs) with multiple dots.
Submitted by: Florian G. Haas
Issue: FOR-246

Modified:
    forrest/trunk/main/webapp/resources/stylesheets/search/book2cinclude-lucene.xsl

Modified: forrest/trunk/main/webapp/resources/stylesheets/search/book2cinclude-lucene.xsl
URL: http://svn.apache.org/viewcvs/forrest/trunk/main/webapp/resources/stylesheets/search/book2cinclude-lucene.xsl?view=diff&r1=149338&r2=149339
==============================================================================
--- forrest/trunk/main/webapp/resources/stylesheets/search/book2cinclude-lucene.xsl (original)
+++ forrest/trunk/main/webapp/resources/stylesheets/search/book2cinclude-lucene.xsl Mon Jan
31 17:04:49 2005
@@ -40,7 +40,7 @@
   <xsl:param name="merge-factor"/>  
 
   <!-- The extension of the lucene index fragments. -->
-  <xsl:param name="extension" select="'.lucene'"/>
+  <xsl:param name="extension" select="'lucene'"/>
 
 
   <!-- Creates the lucene:index root element from the Forrest
@@ -64,15 +64,41 @@
   <xsl:template match="menu-item[starts-with(@href, 'http:')]"/>  <!-- Ignore absolute
http urls -->
   <xsl:template match="menu-item[starts-with(@href, 'https:')]"/>  <!-- Ignore absolute
https urls -->
 
+  <!-- For entries whose @href ends in "/", refer to @href/index.lucene -->
+  <xsl:template match="menu-item[substring(@href, string-length(@href) - string-length('/')
+ 1) = '/']">
+    <cinclude:include>
+      <xsl:attribute name="src">
+        <xsl:text>cocoon://</xsl:text>
+        <xsl:value-of select="concat(@href, 'index.', $extension)"/>
+      </xsl:attribute>
+    </cinclude:include>
+  </xsl:template>
+
   <!-- Inserts a cinclude:include element for document referenced by
   menu item. -->
   <xsl:template match="menu-item">
     <cinclude:include>
       <xsl:attribute name="src">
         <xsl:text>cocoon://</xsl:text>
-        <xsl:value-of select="concat(substring-before(@href, '.'), $extension)"/>
+        <xsl:call-template name="strip-extension">
+          <xsl:with-param name="the-string" select="@href"/>
+        </xsl:call-template>
+        <xsl:value-of select="$extension"/>
       </xsl:attribute>
     </cinclude:include>
+  </xsl:template>
+
+  <!-- Strips the extension from a filename. Works for filenames with
+  multiple dots. -->
+  <xsl:template name="strip-extension">
+    <xsl:param name="the-string"/>
+    <xsl:value-of select="substring-before($the-string, '.')"/>
+    <xsl:if test="substring-after($the-string, '.') != ''">
+      <xsl:text>.</xsl:text>
+      <xsl:call-template name="strip-extension">
+        <xsl:with-param name="the-string" select="substring-after($the-string, '.')"/>
+      </xsl:call-template>
+    </xsl:if>
   </xsl:template>
 
 </xsl:stylesheet>



Mime
View raw message