00001
00002 (function() {
00003 var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
00004
00005 ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
00006
00007 XMLDocument = require('./XMLDocument');
00008
00009 XMLDocumentCB = require('./XMLDocumentCB');
00010
00011 XMLStringWriter = require('./XMLStringWriter');
00012
00013 XMLStreamWriter = require('./XMLStreamWriter');
00014
00015 module.exports.create = function(name, xmldec, doctype, options) {
00016 var doc, root;
00017 if (name == null) {
00018 throw new Error("Root element needs a name");
00019 }
00020 options = assign({}, xmldec, doctype, options);
00021 doc = new XMLDocument(options);
00022 root = doc.element(name);
00023 if (!options.headless) {
00024 doc.declaration(options);
00025 if ((options.pubID != null) || (options.sysID != null)) {
00026 doc.doctype(options);
00027 }
00028 }
00029 return root;
00030 };
00031
00032 module.exports.begin = function(options, onData, onEnd) {
00033 var ref1;
00034 if (isFunction(options)) {
00035 ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
00036 options = {};
00037 }
00038 if (onData) {
00039 return new XMLDocumentCB(options, onData, onEnd);
00040 } else {
00041 return new XMLDocument(options);
00042 }
00043 };
00044
00045 module.exports.stringWriter = function(options) {
00046 return new XMLStringWriter(options);
00047 };
00048
00049 module.exports.streamWriter = function(stream, options) {
00050 return new XMLStreamWriter(stream, options);
00051 };
00052
00053 }).call(this);