我正在将 XML 导入 InDesign,并收到以下消息:
找不到外部实体“blahblah.dtd”。还是继续导入?
然后当我继续导入 XML 时,我收到以下错误消息:
Javascript 错误!
错误号:103237 错误字符串:DOM 转换错误:无效的命名空间。
引擎:会话文件:C:\blahblah\blahblah.jsx 行:259 源:
obj.doc.importXML(File(xmlDoc));
...问题是,我无法访问 DTD,而且无论如何我都不需要它来实现我的目的。
- 那么,有没有一种 Extendscript 方法可以忽略 DTD?
- 如果没有,有没有办法用 XSLT 忽略 DTD?
以下是相关代码:
function importXML(xmlDoc, xslt)
{
with(obj.doc.xmlImportPreferences)
{
importStyle = XMLImportStyles.MERGE_IMPORT; // merges XML elements into the InDesign document, merging with whatever matching content
createLinkToXML = true; // link elements to the XML source, instead of embedding the XML
// defining the XSL transformation settings here
allowTransform = true; // allows XSL transformation
transformFilename = File(xslt); // applying the XSL here
repeatTextElements = true; // repeating text elements inherit the formatting applied to placeholder text, **only when import style is merge!
ignoreWhitespace = true; // gets rid of whitespace-only text-nodes, and NOT whitespace in Strings
ignoreComments = true;
ignoreUnmatchedIncoming = true; // ignores elements that do not match the existing structure, **only when import style is merge!
importCALSTables = true; // imports CALS tables as InDesign tables
importTextIntoTables = true; // imports text into tables if tags match placeholder tables and their cells, **only when import style is merge!
importToSelected = false; // import the XML at the root element
removeUnmatchedExisting = false;
}
obj.doc.importXML(File(xmlDoc) );
obj.doc.mapXMLTagsToStyles(); // automatically match all tags to styles by name (after XSL transformation)
alert("The XML file " + xmlDoc.name + " has been successfully imported!");
} // end of function importXML
...这是基于 p。407(第 18 章)使用 XML 和 Javascript 实现 InDesign CS5 自动化,作者:Grant Gamble