cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Rocha <rica...@apache.org>
Subject Re: logic
Date Wed, 09 Aug 2000 17:49:08 GMT
Robin Green wrote:
> Maris wrote:
> >Any error in this code.  Cocoon gives me error.
> >
> >  <xsp:logic>
> >
> >   String data="<xsl:value-of select="text()" />";
> 
> That would work fine if the node you were inserting were all one line, e.g.
> 
>   <mynode>I am inserting this text</mynode>
> 
> However it seems that the node you are inserting has a new line character in
> it, e.g.
> 
>   <mynode>
>     I am inserting this text
>   </mynode>
> 
> String literals in Java cannot have newline characters. Strings can have
> them, but not string literals. To solve your problem either

I agree with Robin that including lots of literals in XSP is bad
practice.

XPath (or XSLT without extensions for that matter) don't provide a
simple way to substitute strings, so that (for example) newlines
or double quotes could be escaped (\n, \")

There's a limited way to translate newlines to spaces. It accounts
only for replacing embedded newlines by blanks:

  . . .
  <xsp:logic>
    String data =
     "<xsl:value-of select="translate(string(text()), '&#10;', ' ')"/>";
  </xsp:logic>
  . . .

Mime
View raw message