3 var XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
4 extend =
function(child, parent) {
for (var key in parent) {
if (hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype =
new ctor(); child.__super__ = parent.prototype;
return child; },
5 hasProp = {}.hasOwnProperty;
7 isPlainObject = require(
'./Utility').isPlainObject;
9 XMLNode = require(
'./XMLNode');
11 XMLStringifier = require(
'./XMLStringifier');
13 XMLStringWriter = require(
'./XMLStringWriter');
15 module.exports = XMLDocument = (
function(superClass) {
16 extend(XMLDocument, superClass);
18 function XMLDocument(options) {
19 XMLDocument.__super__.constructor.call(
this, null);
20 options || (options = {});
21 if (!options.writer) {
22 options.writer =
new XMLStringWriter();
24 this.options = options;
25 this.stringify =
new XMLStringifier(options);
26 this.isDocument =
true;
29 XMLDocument.prototype.end =
function(writer) {
32 writer = this.options.writer;
33 }
else if (isPlainObject(writer)) {
34 writerOptions = writer;
35 writer = this.options.writer.set(writerOptions);
37 return writer.document(
this);
40 XMLDocument.prototype.toString =
function(options) {
41 return this.options.writer.set(options).document(
this);