forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cross...@apache.org
Subject svn commit: rev 46087 - forrest/trunk/src/core/context/resources/chaperon/stylesheets
Date Wed, 15 Sep 2004 06:34:48 GMT
Author: crossley
Date: Tue Sep 14 23:34:47 2004
New Revision: 46087

Modified:
   forrest/trunk/src/core/context/resources/chaperon/stylesheets/wiki2xdoc.xsl
Log:
A link in a JSPWiki document is expressed by the syntax [XXX|YYY]
where YYY is the "href" value of the link. If YYY contains spaces to
either side (e.g. [ XXX | YYY ]) the link might not be rendered
correctly. This patch corrects this problem by "normalizing" whitespace.
Also it partly simplifies the template for processing wiki links, using
a new template "convertLinks". 
Submitted by: Fabio Rinaldi
Issue: FOR-291


Modified: forrest/trunk/src/core/context/resources/chaperon/stylesheets/wiki2xdoc.xsl
==============================================================================
--- forrest/trunk/src/core/context/resources/chaperon/stylesheets/wiki2xdoc.xsl	(original)
+++ forrest/trunk/src/core/context/resources/chaperon/stylesheets/wiki2xdoc.xsl	Tue Sep 14
23:34:47 2004
@@ -183,53 +183,46 @@
     <xsl:variable name="href" select="substring-before(substring-after(.,'|'),']')"/>
     <xsl:variable name="text" select="substring-after(substring-before(.,'|'),'[')"/>
 
-    <xsl:choose>
-     <xsl:when test="string(number($href)) != 'NaN'">
-      <link href="#{$href}">
-       <xsl:value-of select="$text"/>
-      </link>
-     </xsl:when>
-     <xsl:when test="contains($href,'.png') or contains($href,'.jpg') or contains($href,'.gif')">
-      <img src="{$href}" alt="{$text}"/>
-     </xsl:when>
-     <xsl:when test="contains($href,':') or contains($href,'.')">
-      <link href="{$href}">
-       <xsl:value-of select="$text"/>
-      </link>
-     </xsl:when>
-     <xsl:otherwise>
-      <link>
-       <xsl:attribute name="href">
-      <xsl:choose>
-       <xsl:when test="$spaceless-filenames">
-          <xsl:value-of select="concat(translate($href,' ',''),'.html')"/>
-       </xsl:when>
-       <xsl:otherwise>
-          <xsl:value-of select="concat('view.do?page=',$href)"/>
-       </xsl:otherwise>
-      </xsl:choose>
-       </xsl:attribute>
-       <xsl:value-of select="$text"/>
-      </link>
-     </xsl:otherwise>
-    </xsl:choose>
+	<xsl:call-template name="convertLink">
+	  <xsl:with-param name="href0" select="$href"/>
+	  <xsl:with-param name="text" select="$text"/>
+	</xsl:call-template>
 
    </xsl:when>
    <xsl:otherwise>
     <xsl:variable name="href" select="substring(.,2,string-length(.)-2)"/>
     
+	<xsl:call-template name="convertLink">
+	  <xsl:with-param name="href0" select="$href"/>
+	  <xsl:with-param name="text" select="$href"/>
+	</xsl:call-template>
+
+   </xsl:otherwise>
+  </xsl:choose>
+ </xsl:template>
+
+
+  <xsl:template name="convertLink" >
+    <xsl:param name="href0"/>
+    <xsl:param name="text"/>
+    
+    <xsl:variable name="href">
+      <xsl:value-of
+	select="normalize-space($href0)"/>
+    </xsl:variable>
+
     <xsl:choose>
      <xsl:when test="string(number($href)) != 'NaN'">
       <link href="#{$href}">
-       [<xsl:value-of select="$href"/>]
+       <xsl:value-of select="$text"/>   <!-- $href -->
       </link>
      </xsl:when>
      <xsl:when test="contains($href,'.png') or contains($href,'.jpg') or contains($href,'.gif')">
-      <img src="{$href}" alt="{$href}"/>
+      <img src="{$href}" alt="{$text}"/> <!-- $href -->
      </xsl:when>
      <xsl:when test="contains($href,':') or contains($href,'.')">
       <link href="{$href}">
-       <xsl:value-of select="$href"/>
+       <xsl:value-of select="$text"/> <!-- $href -->
       </link>
      </xsl:when>
      <xsl:otherwise>
@@ -244,14 +237,12 @@
        </xsl:otherwise>
       </xsl:choose>
        </xsl:attribute>
-       <xsl:value-of select="$href"/>
+       <xsl:value-of select="$text"/> <!-- $href -->
       </link>
      </xsl:otherwise>
     </xsl:choose>
+  </xsl:template>
 
-   </xsl:otherwise>
-  </xsl:choose>
- </xsl:template>
 
  <xsl:template match="st:anchor" >
   <p>

Mime
View raw message