/ cloudformation-templates / node_modules / aws-cdk / node_modules / xmlbuilder / lib / XMLDocument.js
XMLDocument.js
1 // Generated by CoffeeScript 1.12.7 2 (function() { 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; 6 7 isPlainObject = require('./Utility').isPlainObject; 8 9 XMLNode = require('./XMLNode'); 10 11 XMLStringifier = require('./XMLStringifier'); 12 13 XMLStringWriter = require('./XMLStringWriter'); 14 15 module.exports = XMLDocument = (function(superClass) { 16 extend(XMLDocument, superClass); 17 18 function XMLDocument(options) { 19 XMLDocument.__super__.constructor.call(this, null); 20 options || (options = {}); 21 if (!options.writer) { 22 options.writer = new XMLStringWriter(); 23 } 24 this.options = options; 25 this.stringify = new XMLStringifier(options); 26 this.isDocument = true; 27 } 28 29 XMLDocument.prototype.end = function(writer) { 30 var writerOptions; 31 if (!writer) { 32 writer = this.options.writer; 33 } else if (isPlainObject(writer)) { 34 writerOptions = writer; 35 writer = this.options.writer.set(writerOptions); 36 } 37 return writer.document(this); 38 }; 39 40 XMLDocument.prototype.toString = function(options) { 41 return this.options.writer.set(options).document(this); 42 }; 43 44 return XMLDocument; 45 46 })(XMLNode); 47 48 }).call(this);