XML を InDesign にインポートすると、次のメッセージが表示されます。
外部エンティティ 'blahblah.dtd' が見つかりません。このままインポートを続行しますか?
XML のインポートを続行すると、次のエラー メッセージが表示されます。
Javascript エラー!
エラー番号: 103237 エラー文字列: DOM 変換エラー: 名前空間が無効です。
エンジン: セッション ファイル: C:\blahblah\blahblah.jsx 行: 259 ソース:
obj.doc.importXML(File(xmlDoc) );
...問題は、DTD にアクセスできないことです。とにかく、私の目的には必要ありません。
- では、DTD を無視する Extendscript の方法はありますか?
- そうでない場合、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 (Chapter 18) of InDesign CS5 Automation Using XML & Javascript、Grant Gamble 著