The only thing is that that could lead to LZX source files that are invalid XML files.

I have my editor set up to automatically insert CDATA tags inside of <methods/> I'm not opposed to doing this, but feel a bit uneasy about allowing the creation of LZX file sthat are invalid XML. Maybe it would be okay to auto-insert CDATA tags if necessary but emit a warning to the browser if the text bodies of tags include unescaped & < or >s.
-e

On Wed, May 2, 2007 at  3:12 PM, Max Carlson 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 &lt; 1 &amp;&amp; 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 &lt; bobby');
     </method>

     <method name="bar"><![CDATA[
         canvas.boo.setText('herring &lt; bobby');
     ]]></method>
</canvas>

Running 'lzc -runtime=swf7 --script' produces this javascript (simplified again):

#file cdata_text_testcase.lzx
#line 6

                canvas.boo.setText('herring &lt; 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



---=---===-------
Elliot Winard
Sr. Software Engineer
Laszlo Studios
---=---===-------

Reply via email to