• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CDATA line in script stops script from running in toolkit

Community Expert ,
Dec 17, 2010 Dec 17, 2010

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.

TOPICS
Actions and scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Dec 17, 2010 Dec 17, 2010

If you escape the opening and closing <> it works as expected.

var x = '\<![CDATA[]]\>'
alert(x);// alerts <![CDATA[]]>

Votes

Translate

Translate
Adobe
Guru ,
Dec 17, 2010 Dec 17, 2010

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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2010 Dec 17, 2010

Copy link to clipboard

Copied

It is strange.  It also stops working if that line is commented out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 17, 2010 Dec 17, 2010

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 17, 2010 Dec 17, 2010

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2010 Dec 17, 2010

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 17, 2010 Dec 17, 2010

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 17, 2010 Dec 17, 2010

Copy link to clipboard

Copied

If you escape the opening and closing <> it works as expected.

var x = '\<![CDATA[]]\>'
alert(x);// alerts <![CDATA[]]>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2010 Dec 17, 2010

Copy link to clipboard

Copied

That did work and it worked in making an XML var.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines