cocoon-users mailing list archives

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

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 keeps being dirty string manupilation. For "enters" try '&#13;'.

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

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

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
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message