Jochen Kuhnle wrote:
Vadim Gritsenko <[EMAIL PROTECTED]> wrote on 06.06.2005 16:19:44:

Jochen Kuhnle wrote:

I noticed that XSPMarkupLanguage.characters wraps text in xsp:text elements. Is there a reason for this? At least my XSPs work without this...

This logic has been there since beginnings of Cocoon2 XSP implementation [1] (line 134), and I'd suggest leaving it there as logicsheets might be dependent on this.


I just found one other thing: I'm implementing the cache control logic sheets for XSPs [1], and there, the <xsp:text> wrapping actually makes things more complicated. What we wanted was something like this:

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

XML above - it is XML. It has two character events. XSP MUST process these character events, and it MUST NOT ignore those character events, as XSP is 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.


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 not for the <xsp:text> wrapping... Because this actually wraps the white space between <key:key> and <xsp-request:get-parameter> in <xsp:text>, making 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 still processes all xsp:text elements, and we trim afterwards.


PS Definition of 'MUST' above is same as in RFCs.

Vadim


<xsl:for-each select="*[namespace-uri() != 'http://apache.org/xsp' or local-name() != 'text'">

I guess original idea was that text() nodes can be safely ignored, while xsp:text nodes are meaningful. It might be still true, haven't digged deeper...

Vadim

[1] http://cvs.apache.org/viewcvs.
cgi/cocoon-1/src/org/apache/cocoon/components/language/markup/xsp/XSPMarkupLanguage.
java?rev=1.1.2.1&only_with_tag=xml-cocoon2&view=markup


Regards,
Jochen

[1] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=111693513631888&w=2

Reply via email to