For whatever reason, we've kind of sold ourselves on the idea that an
LZX source file is valid XML, so we can't change that and still say an
LZX file is complying with the XML spec.
If we punt on needing LZX to be valid XML, we could have a
preprocessor to massage script blocks into CDATA regions before
sending it
to the LZX parser. One of the SAX-like parsers or XMLPull could do
that I think, if you can get access to the raw text before XML
character entities have been expanded.
(Or we could work on some script-only
extensions, like a syntax for constraints, to allow people to bypass
XML if they want to, and write their apps basically in Javascript...)
On 5/2/07, Max Carlson <[EMAIL PROTECTED]> wrote:
Is there a reason we don't automatically wrap JavaScript expressions
with a CDATA tag in the tag compiler? ACurrently, LZX JavaScript
expressions have to look like this:
<method name="foo">
if (narg < 1 && bar == foo) blarg;
</method>
Adding a CDATA tag makes for much more readable source:
<method name="bar"><![CDATA[
if (narg < 1 && bar == foo) blarg;
]]></method>
Both of these methods currently end up compiling to:
if (narg < 1 && bar == foo) blarg;
We could add the CDATA tag automatically if it's missing. Adding
missing CDATA tags in LZX has a huge quality of life benefit of escaping
< and & in LZX methods.
Making this change would also resolve encoding issues, like
http://jira.openlaszlo.org/jira/browse/LPP-1948. This bug shows a
difference in swf and DHTML rendering would be fixed with this change.
Here's some simplified LZX from the bug report:
<canvas>
<method name="foo">
canvas.boo.setText('herring < bobby');
</method>
<method name="bar"><![CDATA[
canvas.boo.setText('herring < bobby');
]]></method>
</canvas>
Running 'lzc -runtime=swf7 --script' produces this javascript
(simplified again):
#file cdata_text_testcase.lzx
#line 6
canvas.boo.setText('herring < bobby');
#endContent
...
#file cdata_text_testcase.lzx
#line 2
canvas.boo.setText('herring < bobby');
#endContent
Wrapping expressions in CDATA tags if they don't already have one It
seems like a fairly straightforward XML transformation. What are your
thoughts?
--
Regards,
Max Carlson
OpenLaszlo.org
--
Henry Minsky
Software Architect
[EMAIL PROTECTED]