Copy link to clipboard
Copied
I was trying to create an XML variable in a script and just discovered that if I add a CDATA block the script will not run from withing CS5 ExtendScript Toolkit.
Here's a sample of what will not run:
#target photoshop
var x = '<![CDATA[]]>'
alert(x)
This seems to be a bug.
If you escape the opening and closing <> it works as expected.
var x = '\<![CDATA[]]\>'
alert(x);// alerts <![CDATA[]]>
Copy link to clipboard
Copied
Strange it seems to be the double [[]] that triggers the bug. Even if you break them up.
var x = "<[[";
x = x + "]]>";
alert(x);
Copy link to clipboard
Copied
It is strange. It also stops working if that line is commented out.
Copy link to clipboard
Copied
The fact it still triggers the bug when commented out doesn't really surprise me. If you look at the Photoshop startup script you will see that XML ( @@@START_XML@@@ ) can be part of the preprocessor directives or whatever they are calling things like <javascriptresource>
Copy link to clipboard
Copied
I have code that looks like this that works in CS4 and CS5.
var literal = new XML('<literal><![CDATA[' + item.literal + ']]></literal>');
The is much of the XML that causes me problems, especially with very large XML files (28000) which makes interactive debugging painful or impossible with ESTK.
Copy link to clipboard
Copied
Have you started the code from within ESTK CS5? I have a script that uses the CDATA line that works in both CS4 and CS5, but will not run if started within ESTK. So far my XML files are pretty small. I just use them to create user preference files and XML files for Flash galleries. With the XML files, I can create a for loop that will go through my UI and assign all the variables to an XML file. That way I don't have to update the assignment part if I change the UI, which I had to do when I used a csv file.
Copy link to clipboard
Copied
The project that I'm on has a dozen or more scripts in it. Easily half of them cannot be run from ESTK but only one of the scripts has that line in it. However, some have CDATA lines in their comments. Perhaps that's why they won't run. I'll check on it over the weekend and let you know what I find.
Copy link to clipboard
Copied
If you escape the opening and closing <> it works as expected.
var x = '\<![CDATA[]]\>'
alert(x);// alerts <![CDATA[]]>
Copy link to clipboard
Copied
That did work and it worked in making an XML var.