InDesign CS5 Script: How can I ignore the DTD when importing XML?

后端 未结 3 501
渐次进展
渐次进展 2020-12-22 11:37



I am importing XML into InDesign, and I get this message:

The external entity \'blahblah.dtd\' cannot be found. Continue to import anyw

3条回答
  •  臣服心动
    2020-12-22 12:11

    I think zanegray gave you the main concept although I think you overcomplicate stuff. Why not just getting xml file content, remove teh dtd declaration with a regexp and then output a new XML File that will be used for input ?

    //Open and retrieve original xml file content
    var originalXMLFile = File (Folder.desktop+"/foo.xml" );
    originalXMLFile.open('r');
    var content = originalXMLFile.read();
    //Looks for a DOCTYPE declaration and remove it
    content = content.replace ( /\n/g , "" );
    originalXMLFile.close();
    //Creates a new file without any DTD declaration
    var outputFile = new File ( Folder.desktop+"/bar.xml" );
    outputFile.open('w');
    outputFile.write(content);
    outputFile.close();
    

    You can then use this filtered xml for your import.

提交回复
热议问题