cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Kuhnle <>
Subject Re: Why does XSPMarkupLanguage wrap text in xsp:text?
Date Tue, 07 Jun 2005 16:04:28 GMT
Vadim Gritsenko <> wrote on 07.06.2005 14:34:36:

> Jochen Kuhnle wrote:
> > Vadim Gritsenko <> wrote on 06.06.2005 16:19:44:
> > 
> >>Jochen Kuhnle wrote:
> >>
> > 
> > <key:key>
> >         <xsp-request:get-parameter name="key"/>
> > </key:key>
> XML above - it is XML. It has two character events. XSP MUST process 
> character events, and it MUST NOT ignore those character events, as XSP 
> operating on the XML and character events are part of XML.
> It means, generally speaking, that the caching key above MUST be set
> to the value:
>    "\n        " + request.getParameter("key") + "\n".
> Anything else is invalid behaviour which MUST be fixed.

XSLT whitespace stripping removes whitespace only text() nodes in 
templates, except if configured otherwise [1].

> > where the key template would append all child elements to the cache 
key. A 
> > simple <xsl:for-each select="*"/> in the logic sheer would suffice. If 
> > for the <xsp:text> wrapping... Because this actually wraps the white 
> > between <key:key> and <xsp-request:get-parameter> in <xsp:text>,

> > things in the logic sheet more complicated. Not very straight forward:
> See above - for correct behavior you must add xsp:text elements to 
> the caching 
> key. It is identical to:
>    <key:key>aaa<xsp-request:get-parameter name="key"/>bbb</key:key>
> And I guess you won't dispute the fact that 'aaa' and 'bbb' must be 
> part of the key.
> Now, for efficiency reasons, one might argue that leading and trailing 
> whitespaces should be trimmed, so that if clueless user uses the 
> logicsheet he 
> doesn't end up with large mostly whitespace keys. Here, I might 
> agree with it, 
> so one can trim the key, and key as generated from the snippet right
> above becomes:
>    String.valueOf("aaa" + request.getParameter("key") + "bbb").trim()
> as long as it is crystal clear from logicsheet documentation that this 
> particular logicsheet DOES NOT respect whitespaces. Notice: it 
> all xsp:text elements, and we trim afterwards.

What I would prefer would be a whitespace handling similar to XSLT's:

   <xsp-request:get-parameter name="key"/>

leads to ("\n    aaa\n    " + request.getParameter("key") + "\n    bbb")

   <xsp-request:get-parameter name="key"/>

leads to ("aaa" + request.getParameter() + "bbb")

   <xsp-request:get-parameter name="key"/>

leads to (request.getParameter())

If we don't do automagic wrapping by PreProcessFilter, the XSP author can 
decide. It would also have another advantage: PreProcessFilter wraps 
everything, including whitespace only text() nodes. This leads to loads of 
unnecessary this.characters("\n________"); ('_' = space) in the XSPs. I 
guess that most whitespaces between elements are in there for code 
formatting purposes, and people don't need all of them ending up in the 
internet. Might be nice to count needlessly sent whitespace bytes sometime 

In the distribution xsp:text mostly occurs in utility templates 
("get-nested-content") that unwrap the automagically wrapped text. The 
only occurence that I've found that does something different is in xsp.xsl 
itself. The only occurence to quote text is in ViewOrder.xsp. Therefor I 
don't think this change would have any impact on existing XSPs. But it 
would make the code simpler and text handling more "standard like".



View raw message