我们需要修改/更新 .idms 文件的 xml 属性。使用动作脚本。我正在使用以下方法来做到这一点。
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
var file:File = File.desktopDirectory.resolvePath('myInputFile.xml');
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);// doesn't read processing instrunction
var xml:XML = new XML(fileStream.readUTFBytes(fileStream.bytesAvailable));
fileStream.close();
var writeStream:FileStream = new FileStream();
writeStream.open(file, FileMode.WRITE);
for each(var node:XML in xml.descendants("*"))
{
if(node.localName() == "Link")
{
var linkfile:String=node.@LinkResourceURI = "file:/Shared/Logos/Bk.ai";
}
}
writeStream.writeUTFBytes(String(xml));
writeStream.close();
}
上面的代码问题是它没有读取 xml 文件顶部的处理指令。结果在写入 xml 文件后,它将不再将该文件作为 InDesign 片段文件读取。处理指令为:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
谁能帮我弄清楚如何在新文件中读取处理指令?
感谢您的快速回复,但即使我将此属性设置为 flase,它仍然会忽略处理指令。
var file:File = File.desktopDirectory.resolvePath('031413115849909.idms');
var fileStream:FileStream = new FileStream();
XML.ignoreProcessingInstructions = false; //newly added
fileStream.open(file, FileMode.READ);
var xml:XML = new XML(fileStream.readUTFBytes(fileStream.bytesAvailable));
fileStream.close();