cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathaniel Alfred" <Alfred.Nathan...@swx.com>
Subject RE: [RFE] Some enhancements to XSP
Date Mon, 30 May 2005 16:09:59 GMT
> -----Original Message-----
> From: Jochen Kuhnle [mailto:lists@kuhnle.net]
> Sent: Freitag, 27. Mai 2005 15:02
> To: dev@cocoon.apache.org
> Subject: RE: [RFE] Some enhancements to XSP
 
> If we filter the logic sheets, too, we can still move code back and forth 
> between XSP and logic sheet. There is one problem, though: since XSL uses 
> curlies, too, you have to escape them even more, and "if(expr) 
> {{{{code}}}}" really starts to look bad. In this case, would rather go 
> for a new syntax. Something like "~{expression}~" or more esoteric quotes, 
> like the single characters << and >>, or ` and ยด. Any suggestions 
> welcome...

XSP attribute interpolation makes on sense for Java expressions.  Therefore
"if(expr){code}" is not really an issue.

I would suggest a syntax as "{?expr}" which must be transformed by a preprocessor
applied to XSPs and logicsheets:

    <img src="{?logo}.gif"/>
==> <img><xsp:attribute name="src"><xsp:expr>(logo)+""</xsp:expr>.gif<xsp:attribute></img>

    <h1>Hello {?username}</h1>
==> <h1>Hello <xsp:expr>(username)+""</xsp:expr></h1>

The prepocessor should not introduce any new line breaks in order to preserve
the correct line number count for XSLT error messages from the logicsheet.

The preprocessor must understand string and character constants and nested braces.
Here are a few valid non-trivial expressions:

    {?foo.indexOf('}')}
    {?foo.indexOf("}")}
    {?new String[]{"foo","bar"}[index]}

If the closing brace is missing, the preprocessor shall generate XSP code which
leads to a compilation error:

    <h1>Hello {?username}</h1>
==> <h1>Hello <xsp:expr>(username)+""}</xsp:expr></h1>

The replacement can be suppressed, by duplication the "?":

    <tt>&lt;h1&gt;Hello {??username}&lt;/h1&gt;</tt> is transformed
to
    <tt>&lt;h1&gt;Hello &lt;xsp:expr&gt;username&lt;/xsp:expr&gt;&lt;/h1&gt;</tt>

Instead of "?" one could also use another character provided it is sufficiently
unlikely that the sequence curly-char appears in XSP-embedded content or where 
XSP can be embedded (XSL).  The special character should not be valid at the
beginning of an expression at least for CSS, HTML, Java, Javascript, Perl, 
and XSLT.  That excludes

    + " * % & ` @ ' ^ ~ ! [ $ - . ( /

but leaves as sensible alternatives

    {#expr}
    {=expr}
    {:expr}
    {?expr}

Whatever special character we agree on, it should be always the same in all
contexts and always enabled.

Any preferrences which character to use?

Cheers, Alfred.
 
 
This message is for the named person's use only. It may contain confidential, proprietary
or legally privileged information. No confidentiality or privilege is waived or lost by any
mistransmission. If you receive this message in error, please notify the sender urgently and
then immediately delete the message and any copies of it from your system. Please also immediately
destroy any hardcopies of the message. You must not, directly or indirectly, use, disclose,
distribute, print, or copy any part of this message if you are not the intended recipient.
The sender's company reserves the right to monitor all e-mail communications through their
networks. Any views expressed in this message are those of the individual sender, except where
the message states otherwise and the sender is authorised to state them to be the views of
the sender's company.

Mime
View raw message