添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

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

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,

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

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

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

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

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

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.

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