cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Painter-Wakefield <>
Subject Re: XSP/ESQL escaping
Date Wed, 05 Nov 2003 01:11:42 GMT
Yes, it is a pain, isn't it?  XML just doesn't care to know about or deal 
with whitespace, and that really is a pain when whitespace IS content!

To answer your question, it depends.  If you just have a string (no XML 
markup in the database), then something like this is the easiest:

        String instring = <esql:get-string column="body"/>;
        java.util.StringTokenizer st = new java.util.StringTokenizer(instring, 
"\n", true);
        while (st.hasMoreTokens()) {
                String token = st.nextToken();
                if ("\n".equals(token)) {
                } else {

If what is in your database contains XML markup, you'll need to do 
something more like this (mostly lifted from the ESQL logicsheet):

        String instring = <esql:get-string column="body"/>;
        instring.replaceAll("\n", "&gt;br/>");
        org.apache.cocoon.components.parser.Parser newParser = null;
        try {
                newParser = (org.apache.cocoon.components.parser.Parser)

                InputSource __is = new InputSource(new 
                XSPUtil.include(__is, this.contentHandler, newParser);
        } catch (Exception e) {
                getLogger().error("Could not include page", e);
        } finally {
                if (newParser != null) this.manager.release((Component) 


Anders Forsgren <>
11/04/2003 05:55 PM
Please respond to users

        Subject:        Re: XSP/ESQL escaping

Sigh :(

Feels like a lot of work to make a linebreak a <br/> tag...If I rephrase 
the question: What would be the simplest way
of  displaying the database strings with correct linebreaks in html 
(except using <pre> in the xsl)?



View raw message