cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ard Schrijvers" <a.schrijv...@hippo.nl>
Subject RE: [Jexl] linebreaks in jexl expressions
Date Wed, 04 Jul 2007 13:20:38 GMT
Hello, 

if all you want is to replace linebreaks to <br/>, perhaps I can make you happy with
this xsl that does the job (to avoid ofcourse is better, because below is certainly not the
way xsl should be (mis-)used), but I suppose it would be equally dirty to trying todo it in
jx....it keeps being dirty string manupilation. For "enters" try '&#13;'.

http://www.tony-franks.co.uk/UTF-8.htm
http://www.i18nguy.com/markup/ncrs.html
http://www.w3schools.com/tags/ref_entities.asp

<xsl:call-template name="linebreaks">
    <xsl:with-param name="string" select="text()"/>
</xsl:call-template>

<xsl:template name="linebreaks">
        <xsl:param name="string"/>
        <xsl:choose>
            <xsl:when test="contains($string, '&#xA;')">
                <xsl:value-of select="substring-before($string, '&#xA;')"/>
                <br/>
                <xsl:text>&#xA;</xsl:text>
                <xsl:call-template name="linebreaks">
                    <xsl:with-param name="string" select="substring-after($string, '&#xA;')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$string"/>
            </xsl:otherwise>
        </xsl:choose>
</xsl:template>

Regards Ard

> 
> hi,
> 
> I tried using the apache-cocoon JX generator (it uses jexl for it's
> expressions within the template) to convert linebreak from strings to
> <br> elements.
> 
> I ran into some problem with searches for linebreaks, like:
> 
> <p>${value.indexOf('\n')}</p>
> 
> or
> 
> <p>${value.indexOf('&#10')}</p>
> 
> The first throws NullPointerException in java reflection classes, the
> second throws a Jexl Lexical Exception in the parser.
> 
> Was anybody successful to get the index of a linebreak within 
> a string?
> Any ideas?
> 
> regards,
> Christoph
> cgaffga@triplemind.com
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

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


Mime
View raw message