This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: formatting problem




Joerg Heinicke wrote:


> Try the following (replacing spaces with non-breaking spaces and linebreaks
> with <br/>):
> 
> <xsl:template match="ARTICLE">
>     <xsl:call-template name="linebreaks">
>         <xsl:with-param name="string" select="translate(., ' ', '&#160;')"/>
>     </xsl:call-template>
> </xsl:template>
> 
> <xsl:template name="linebreaks">
>     <xsl:param name="string"/>
>     <xsl:choose>
>         <xsl:when test="contains($string, '&#10;')">
>             <xsl:value-of select="substring-before($string, '&#10;')"/>
>             <br/>
>             <xsl:call-template name="linebreaks">
>                 <xsl:with-param name="string"
> select="substring-after($string, '&#10;')"/>
>             </xsl:call-template>
>         </xsl:when>
>         <xsl:otherwise>
>             <xsl:value-of select="$string"/>
>         </xsl:otherwise>
>     </xsl:choose>
> </xsl:template>
> 
> This handles only linefeed, maybe you still need to handle carriage return.
> we replaced &#13; with 'nothing', so you have to change the with-param in
> the first template:
> 
>         <xsl:with-param name="string" select="translate(., ' &#13;',
> '&#160;')"/>
> 
> This means: replace ' ' (space) with &#160; (non-breaking space) and &#13;
> (carriage return) with nothing.



or (less sophisticated ;) ):


...
  <xsl:template match="ARTICLE">
    <pre>
      <xsl:value-of select="."/>
    </pre>
  </xsl:template>
...

Markus




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]