Morning all. Long time no see
I'm back to working on another project - using the ActionFileToXML.jsx file as an example I've tried to read an atn file in an dump it to an XML using :
Code: Select allvar actFile = new ActionFile();
actFile.read(form.InputFile);
var xml = actFile.toXML(actFile.file.name);
// xml = xml.toXMLString(); <- this throws an error?
Stdlib.writeToFile(pOutputFolder + "/Original.xml", xml, 'UTF-8', 'unix');
If I leave the xml.toXMLString() commented out, all appears to work fine except the XML is stripped of all the id and key attributes that are present if I convert it with the original ActionFileToXML script.
If I uncomment that line, it throws an error that toXMLString is not a function. Given the code above is almost identical to that found in the process section of ActionFileToXML I'm at a loss as to what I've managed to muck up. Any idea what I'm doing wrong?
Regards,
Anna
Atn to XML
-
xbytor
Atn to XML
Here is the canonical way to do what you want using the more recent versions of xtools and PS (probably CS3+).
Code: Select all//
//@show include
//
app;
//
//@includepath "/c/Program Files/Adobe/xtools;/Developer/xtools"
//
//@include "xlib/PSConstants.js"
//@include "xlib/Stream.js"
//@include "xlib/stdlib.js"
//@include "xlib/GenericUI.jsx"
//@include "xlib/Action.js"
//@include "xlib/xml/atn2bin.jsx"
//@include "xlib/xml/action2xml.jsx"
//
//@include "xlib/ActionStream.js"
//@include "xlib/ieee754.js"
//
function main() {
var file = File("~/work/xtools/etc/XToolkit.atn");
var actFile = new ActionFile();
actFile.read(file);
var xml = actFile.toXML();
Stdlib.writeXMLFile("~/Desktop/Output.xml", xml);
};
main();
// EOF
The important bit is that action2xml.jsx is used instead of atn2xml.jsx. atn2xml implements a early version of ActionFile for versions of PS that did not have the XML object implemented. action2xml does create a proper XML object so toXMLString() will work.
Code: Select all//
//@show include
//
app;
//
//@includepath "/c/Program Files/Adobe/xtools;/Developer/xtools"
//
//@include "xlib/PSConstants.js"
//@include "xlib/Stream.js"
//@include "xlib/stdlib.js"
//@include "xlib/GenericUI.jsx"
//@include "xlib/Action.js"
//@include "xlib/xml/atn2bin.jsx"
//@include "xlib/xml/action2xml.jsx"
//
//@include "xlib/ActionStream.js"
//@include "xlib/ieee754.js"
//
function main() {
var file = File("~/work/xtools/etc/XToolkit.atn");
var actFile = new ActionFile();
actFile.read(file);
var xml = actFile.toXML();
Stdlib.writeXMLFile("~/Desktop/Output.xml", xml);
};
main();
// EOF
The important bit is that action2xml.jsx is used instead of atn2xml.jsx. atn2xml implements a early version of ActionFile for versions of PS that did not have the XML object implemented. action2xml does create a proper XML object so toXMLString() will work.