Copy link to clipboard
Copied
This script hangs:
var xml = []
var Question = "Foo"
xml[xml.length] = """<text><![CDATA[<p>"""+Question+"""<br></p>]]></text>"""
I was able to get the script to work with the following work around:
var xml = []
var questionText = "Foo"
var left = "<![CDATA[<p>"
var right = "<br></p>]]"
var right2 = ">"
xml[xml.length] = """<text>"""+left+questionText+right+right2+"""</text>"""
Is there a less 'hacked' way to be able to have the script application pass the CDATA as a string?
If I comment out the CDATA tag for testing the script would hang. If I split it into two parts (<![CDATA[<p>,<br></p>]]>) it also hangs. I wonder why concatenating the closing portion of the tag as two string variables is allowed?
Thanks for your time and thoughts spent on this,
Kurtis
Copy link to clipboard
Copied
works fine on my end, but that is one very very very weird code snippet:
1) why are you using triple quotes? this is not python?
2) why use that weird construct xml[xml.length] instead of xml[0] ?
3) why use an array instead of a native XML object?
Copy link to clipboard
Copied
1. I don't want to escape special characters so it was easier to just compose with triple quotes than escape quotes. ie. <generalfeedback format="html"> 2. My understanding is there is two ways to add objects to an array. arr.append(obj) OR arr[arr.length] = obj. As far as I know it's not an obscure style, and if I remember correctly the second method is fractionally quicker. 3. I'm writing the XML to a File at the end of the script. *shrugs* Is there an advantage to writing as a "native XML object"?
What does 'works fine on your end' mean? The first snippet, second snippet? If the first snippet works on your end then are you using CC 2014? I've tried both ExtendScriptToolkit and InDesign as targets and both hang.
Thanks for the gander,
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I get the script hang when using CDATA with E4X as well, Loic. My solution is to run the script from another script.
Copy link to clipboard
Copied
KuddRoww‌,
this seems to be a bug with CDATA (IMHO since CS5)
Try:
var xml = [];
var Question = "Foo";
xml[xml.length] = "<text><![CDATA[<p>"+Question+"<br></p>]]\></text>";
This should do the job.
Have fun
![]()
Copy link to clipboard
Copied
FWIW — it's maybe related, maybe it's not: I also had some problems with the ESTK, InDesign CS5 and a ![CDATA-error.
If I ran a script on an InDesign Table object and tried to read out or to assign its contents value the ESTK always throws an error: "![CDATA"
However if I ran the script from InDesign CS5, no error was thrown. That specific error went away with the CS6 version of the ESTK.
Uwe
Copy link to clipboard
Copied
ESTK passes the script to Indesign (using BridgeTalk) as a xml object, with the actual javascript code embedded in a CDATA, so it seems that is he root of the problem (the "inner", script embedded CDATA tag is not escaped).
However, i just tested again the code using ESTK CC, and both original snippets seem to work just fine.
Copy link to clipboard
Copied
Various CDATA problems were fixed in the ESTK I think in CS6 (maybe CS5.5).
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more