我導入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