You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Thomas Hiemer <th...@gmx.de> on 2005/07/08 22:13:21 UTC

Re: SQLTransformer with nr2br() functionality

Hello again

Sorry Yves, but your advice doesn't meet my needs. (or perhaps I'm to  
silly to implement this in my xslt correctly)

It tried this:

<xsl:stylesheet version="1.0"  
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="blurb">
   	<p><b>Example 1: Text is normalized</b> <br />
     <xsl:call-template name="replace-text">
       <xsl:with-param name="text" select="info"/>
       <xsl:with-param name="replace" select="'&#10;'"/>
       <xsl:with-param name="by" select="'&lt;br /&gt;'"/>
     </xsl:call-template>
   	</p>
   	<p><b>Example 2: Text is not normalized</b> <br />
   	  <xsl:value-of select="info" />
   	</p>
   </xsl:template>

<!-- template that does a search & replace -->
<xsl:template name="replace-text">
    <xsl:param name="text"/>
    <xsl:param name="replace" />
    <xsl:param name="by"  />

    <xsl:choose>
    <xsl:when test="contains($text, $replace)">
       <xsl:value-of select="substring-before($text, $replace)"/>
       <xsl:value-of select="$by" disable-output-escaping="yes"/>
       <xsl:call-template name="replace-text">
          <xsl:with-param name="text" select="substring-after($text,  
$replace)"/>
          <xsl:with-param name="replace" select="$replace" />
          <xsl:with-param name="by" select="$by" />
       </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
       <xsl:value-of select="$text"/>
    </xsl:otherwise>
    </xsl:choose>

</xsl:template>
</xsl:stylesheet>


(source:  
http://topxml.com/snippetcentral/main.asp?view=viewsnippet&lang=xsl&id=v20010223112713)

It works properly.

But - as you can guess - it is no real solution for this problem.
In my opinion it would be better if the transformer does this work.

Perhaps another developer answers my prayers ;) an give the  
sql-transformer this functionality

bye, thomas





Am Tue, 28 Jun 2005 10:35:03 +0200 schrieb Yves Vindevogel  
<yv...@implements.be>:

> You might want to try something similar to this
>
>         							
> 								<xsl:if test="number($pos mod 4) = 0" >
> 									<xsl:text disable-output-escaping="yes">
> 									<![CDATA[</tr> <tr>]]>
> 									</xsl:text>
>
> 								</xsl:if>
>
>
> On 28 Jun 2005, at 08:32, Thomas Hiemer [nuernberg gay-web.de] wrote:
>
>>
>> Hello all
>>
>> It would be great if the SQLTransformer also transforms "\nr"
>> automatically into "<br/>" in the output file (defined by a property in
>> the sitemap). Similar like the php function nr2br()
>>
>> Actually you get "&#13;" in the output file and have no chance to make
>> it effective in XHTML.
>>
>> Or are there any solutions I didn't thought about?
>>
>> Thanks in advance!
>>
>> best regards,
>> thomas
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
> Met vriendelijke groeten,
> Bien à vous,
> Kind regards,
>
> Yves Vindevogel
> Implements
>



-- 
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/m2/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org