forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabio Rinaldi" <rina...@ifi.unizh.ch>
Subject Re: svn commit: rev 46087 - forrest/trunk/src/core/context/resources/chaperon/stylesheets
Date Fri, 17 Sep 2004 14:04:14 GMT

Dave Brondsema writes:
 > Quoting David Crossley <crossley@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 

Mime
View raw message