3 var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
5 ref = require(
'./Utility'), assign = ref.assign, isFunction = ref.isFunction;
7 XMLDocument = require(
'./XMLDocument');
9 XMLDocumentCB = require(
'./XMLDocumentCB');
11 XMLStringWriter = require(
'./XMLStringWriter');
13 XMLStreamWriter = require(
'./XMLStreamWriter');
15 module.exports.create =
function(name, xmldec, doctype, options) {
18 throw new Error(
"Root element needs a name");
20 options = assign({}, xmldec, doctype, options);
21 doc =
new XMLDocument(options);
22 root = doc.element(name);
23 if (!options.headless) {
24 doc.declaration(options);
25 if ((options.pubID != null) || (options.sysID != null)) {
32 module.exports.begin =
function(options, onData, onEnd) {
34 if (isFunction(options)) {
35 ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
39 return new XMLDocumentCB(options, onData, onEnd);
41 return new XMLDocument(options);
45 module.exports.stringWriter =
function(options) {
46 return new XMLStringWriter(options);
49 module.exports.streamWriter =
function(stream, options) {
50 return new XMLStreamWriter(stream, options);