"Nathaniel Alfred" <[EMAIL PROTECTED]> wrote on 30.05.2005
18:09:59:
> 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]}
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
which
> 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><h1>Hello {??username}</h1></tt> is transformed to
> <tt><h1>Hello <xsp:expr>username</xsp:expr>
> </h1></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}
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
all
> 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.
>
Regards,
Jochen