cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Kuhnle <>
Subject RE: [RFE] Some enhancements to XSP
Date Tue, 31 May 2005 12:06:43 GMT
"Nathaniel Alfred" <> wrote on 30.05.2005 

> 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 
> the correct line number count for XSLT error messages from the 
> 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]}

Because of this, I would prefer an expression syntax where the 
preprocessor needs not understand the syntax of the XSP language. This 
would be usable independant of the XSP language, and much easier to 
implement. All we need is an escape mechanism for the closing sequence.

Also, do we want the code to be movable between XSP and logic sheet? If 
yes, curlies are not an option, because they need to be duplicated in XSL 
stylesheets. If no, I'm fine with using them.

> If the closing brace is missing, the preprocessor shall generate XSPcode 
> leads to a compilation error:
>     <h1>Hello {?username}</h1>
> ==> <h1>Hello <xsp:expr>(username)+""}</xsp:expr></h1>

Would it be ok to throw an Exception, too? This way, an error page with a 
meaningful error message can be displayed ("Missing '}' in XSP expression 
at line ## column ##").

> The replacement can be suppressed, by duplication the "?":
>     <tt>&lt;h1&gt;Hello {??username}&lt;/h1&gt;</tt> is transformed
>     <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 
> beginning of an expression at least for CSS, HTML, Java, Javascript, 
> and XSLT.  That excludes
>     + " * % & ` @ ' ^ ~ ! [ $ - . ( /
> but leaves as sensible alternatives
>     {#expr}
>     {=expr}
>     {:expr}
>     {?expr}

If we use "?{" instead of "{?", we don't collide with the syntax of the 
XSP language.

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

I agree with the expression syntax being the same in all contexts. I still 
don't think it should be enabled by default, because it may break existing 
XSPs. Therefor I suggest making it configurable in the xconf and/or page 
itself, so it can be enabled/disabled as needed by the users (This would 
be somewhat similar to JSP 2.0, where the expression syntax can be 
enabled/disabled, too). The decision what the default behavior will be can 
be made by the xconf delivered with the distribution.

> Any preferrences which character to use?

Out of purely unrational affection, I prefer "#{" and "}". The fact that I 
have implemented the prototype using this syntax really has nothing to do 
with this ;). "}" is quoted by "#}", "#" by "##" and "#x" results in an 
error if x != '}' and x != '#'.

> Cheers, Alfred.


View raw message