You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by cr...@apache.org on 2005/02/01 02:42:28 UTC

svn commit: r149356 - forrest/branches/forrest_06_branch/src/core/context/resources/stylesheets/search/book2cinclude-lucene.xsl

Author: crossley
Date: Mon Jan 31 17:42:27 2005
New Revision: 149356

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

Modified:
    forrest/branches/forrest_06_branch/src/core/context/resources/stylesheets/search/book2cinclude-lucene.xsl

Modified: forrest/branches/forrest_06_branch/src/core/context/resources/stylesheets/search/book2cinclude-lucene.xsl
URL: http://svn.apache.org/viewcvs/forrest/branches/forrest_06_branch/src/core/context/resources/stylesheets/search/book2cinclude-lucene.xsl?view=diff&r1=149355&r2=149356
==============================================================================
--- forrest/branches/forrest_06_branch/src/core/context/resources/stylesheets/search/book2cinclude-lucene.xsl (original)
+++ forrest/branches/forrest_06_branch/src/core/context/resources/stylesheets/search/book2cinclude-lucene.xsl Mon Jan 31 17:42:27 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>