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 2004/09/15 08:34:48 UTC

svn commit: rev 46087 - forrest/trunk/src/core/context/resources/chaperon/stylesheets

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>

Re: svn commit: rev 46087 - forrest/trunk/src/core/context/resources/chaperon/stylesheets

Posted by Dave Brondsema <da...@brondsema.net>.
Fabio Rinaldi wrote:
> Dave Brondsema writes:
>  > Quoting David Crossley <cr...@apache.org>:
>  > 
>  > > Ah, okay. Thanks for watching diffs closely.
>  > > As far as i can see, that functionality still remains.
>  > > I gather that the logic was duplicated and Fabio's patch
>  > > moves it into a called template.
>  > 
>  > You're right.  I just looked at the diff an saw the removal of the logic without
>  > a corresponding addition.  But looking at the whole file now I see it must've
>  > been duplicated earlier.
> 
> Yes, it was a perfect duplicate (the only difference being the name of
> a parameter). I checked it very carefully before replacing it. The new
> template "convertLinks" just avoids redundancy, but it is otherwise
> equivalent. 
> 
> The only real difference is the following:
> 
>  > +    <xsl:variable name="href">
>  > +      <xsl:value-of
>  > +	select="normalize-space($href0)"/>
>  > +    </xsl:variable>
> 
> which has the purpose of removing spaces to the left or the right of
> the "href", e.g. if $href==" http://www.xxx.yy/ ", it will be changed
> to $href=="http://www.xxx.yy/". 
> 
> This has the possibly undesired side-effect that also spaces internal
> to the URL are 'normalized', i.e. multiple spaces are collapsed to a
> single space, e.g. "http://www.xxx.yy/   something" becomes 
> "http://www.xxx.yy/ something". 
> 
> I assume that a sequence of multiple spaces in a URL is very
> unlikely. However, if this effect is undesidered, then you should
> change the function "normalize-space" with something more suitable,
> which removes spaces either side of the URL, but does not otherwise
> modify the URL. I used "normalize-space" because I could not find a
> better way to do it.
> 
> Best,
> Fabio
> 

Thanks for that explanation.  I think it'll be fine.

If I have time sometime I'll test the good jspwiki changes that have 
been happening against the files we have at work.

-- 
Dave Brondsema : dave@brondsema.net
http://www.splike.com : programming
http://csx.calvin.edu : student org
http://www.brondsema.net : personal

issue explanations (Was: svn commit: rev 46087)

Posted by David Crossley <cr...@apache.org>.
Fabio Rinaldi wrote:
> 
> Yes, it was a perfect duplicate (the only difference being the name of
> a parameter). I checked it very carefully before replacing it. The new
> template "convertLinks" just avoids redundancy, but it is otherwise
> equivalent. 

Thanks for following up Fabio. A good example of open source
development. I know that it takes time to explain things.
The effort is worthwhile, because everyone that reads it
learns something.

It is good to provide a bit more explanation when making the
issue report. That speeds the job of committers. We can explain
the changes better in our commit log messages. It is then easier
for all committers and developers to review the emailed diffs.
Of course there is a trade-off with verbosity.

Anyway, thanks again for your effort.

-- 
David Crossley


Re: svn commit: rev 46087 - forrest/trunk/src/core/context/resources/chaperon/stylesheets

Posted by Fabio Rinaldi <ri...@ifi.unizh.ch>.
Dave Brondsema writes:
 > Quoting David Crossley <cr...@apache.org>:
 > 
 > > Ah, okay. Thanks for watching diffs closely.
 > > As far as i can see, that functionality still remains.
 > > I gather that the logic was duplicated and Fabio's patch
 > > moves it into a called template.
 > 
 > You're right.  I just looked at the diff an saw the removal of the logic without
 > a corresponding addition.  But looking at the whole file now I see it must've
 > been duplicated earlier.

Yes, it was a perfect duplicate (the only difference being the name of
a parameter). I checked it very carefully before replacing it. The new
template "convertLinks" just avoids redundancy, but it is otherwise
equivalent. 

The only real difference is the following:

 > +    <xsl:variable name="href">
 > +      <xsl:value-of
 > +	select="normalize-space($href0)"/>
 > +    </xsl:variable>

which has the purpose of removing spaces to the left or the right of
the "href", e.g. if $href==" http://www.xxx.yy/ ", it will be changed
to $href=="http://www.xxx.yy/". 

This has the possibly undesired side-effect that also spaces internal
to the URL are 'normalized', i.e. multiple spaces are collapsed to a
single space, e.g. "http://www.xxx.yy/   something" becomes 
"http://www.xxx.yy/ something". 

I assume that a sequence of multiple spaces in a URL is very
unlikely. However, if this effect is undesidered, then you should
change the function "normalize-space" with something more suitable,
which removes spaces either side of the URL, but does not otherwise
modify the URL. I used "normalize-space" because I could not find a
better way to do it.

Best,
Fabio


 > 
 > > 
 > > We will need to be really careful when we merge this
 > > back to Cocoon. There have been lots of changes and
 > > yes it seems that there is something specific to the
 > > Cocoon demo webapp.
 > > 
 > > --David
 > > 
 > > Dave Brondsema wrote:
 > > > We need to preserve this logic:
 > > > 
 > > >  > -      <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>
 > > > 
 > > > I don't know why, but when submitting this file back to cocoon, they 
 > > > requested that the default href of links be view.do?page=  But of course 
 > > > that doesn't make any sense in forrest.  So the $spaceless-filenames 
 > > > parameter is used.
 > > >
 > > > > 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>
 > > > 
 > > 
 > > 
 > 
 > 
 > -- 
 > Dave Brondsema : dave@brondsema.net 
 > http://www.brondsema.net : personal 
 > http://www.splike.com : programming 
 > http://csx.calvin.edu : student org 

Re: svn commit: rev 46087 - forrest/trunk/src/core/context/resources/chaperon/stylesheets

Posted by Dave Brondsema <da...@brondsema.net>.
Quoting David Crossley <cr...@apache.org>:

> Ah, okay. Thanks for watching diffs closely.
> As far as i can see, that functionality still remains.
> I gather that the logic was duplicated and Fabio's patch
> moves it into a called template.

You're right.  I just looked at the diff an saw the removal of the logic without
a corresponding addition.  But looking at the whole file now I see it must've
been duplicated earlier.

> 
> We will need to be really careful when we merge this
> back to Cocoon. There have been lots of changes and
> yes it seems that there is something specific to the
> Cocoon demo webapp.
> 
> --David
> 
> Dave Brondsema wrote:
> > We need to preserve this logic:
> > 
> >  > -      <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>
> > 
> > I don't know why, but when submitting this file back to cocoon, they 
> > requested that the default href of links be view.do?page=  But of course 
> > that doesn't make any sense in forrest.  So the $spaceless-filenames 
> > parameter is used.
> >
> > > 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>
> > 
> 
> 


-- 
Dave Brondsema : dave@brondsema.net 
http://www.brondsema.net : personal 
http://www.splike.com : programming 
http://csx.calvin.edu : student org 

Re: svn commit: rev 46087 - forrest/trunk/src/core/context/resources/chaperon/stylesheets

Posted by David Crossley <cr...@apache.org>.
Ah, okay. Thanks for watching diffs closely.
As far as i can see, that functionality still remains.
I gather that the logic was duplicated and Fabio's patch
moves it into a called template.

We will need to be really careful when we merge this
back to Cocoon. There have been lots of changes and
yes it seems that there is something specific to the
Cocoon demo webapp.

--David

Dave Brondsema wrote:
> We need to preserve this logic:
> 
>  > -      <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>
> 
> I don't know why, but when submitting this file back to cocoon, they 
> requested that the default href of links be view.do?page=  But of course 
> that doesn't make any sense in forrest.  So the $spaceless-filenames 
> parameter is used.
>
> > 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>
> 


Re: svn commit: rev 46087 - forrest/trunk/src/core/context/resources/chaperon/stylesheets

Posted by Dave Brondsema <da...@brondsema.net>.
We need to preserve this logic:

 > -      <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>

I don't know why, but when submitting this file back to cocoon, they 
requested that the default href of links be view.do?page=  But of course 
that doesn't make any sense in forrest.  So the $spaceless-filenames 
parameter is used.


crossley@apache.org wrote:
> 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>


-- 
Dave Brondsema : dave@brondsema.net
http://www.splike.com : programming
http://csx.calvin.edu : student org
http://www.brondsema.net : personal