我导入XML到InDesign,我得到这个消息:InDesign CS5脚本:如何在导入XML时忽略DTD?
The external entity 'blahblah.dtd' cannot be found. Continue to import anyway?
当我再继续导入XML,我得到这个错误信息:
Javascript Error!
Error Number: 103237 Error String: DOM transformation error: Invalid namespace.
Engine: session File: C:\blahblah\blahblah.jsx Line: 259 Source:
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
...这是基于页。 407(第18章)InDesign CS5 Automation Using XML & Javascript,Grant Gamble
您是否尝试过使用xslt修改xml以删除对dtd的引用? – zanegray 2012-07-31 19:10:09
谢谢@zanegray,这似乎是最好的方法...我正在尝试''with' ',但它显示出这个错误:'Token'!'没有被识别。“# –
2012-07-31 19:15:42
......我也试图实施在http://www.stylusstudio.com/xsllist/200104/post90620.html找到的解决方案,但是也没有工作。 – 2012-07-31 19:25:06