diff options
| author | Florian Dold <florian.dold@gmail.com> | 2017-05-03 15:35:00 +0200 | 
|---|---|---|
| committer | Florian Dold <florian.dold@gmail.com> | 2017-05-03 15:35:00 +0200 | 
| commit | de98e0b232509d5f40c135d540a70e415272ff85 (patch) | |
| tree | a79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/xmlbuilder/lib | |
| parent | e0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff) | |
node_modules
Diffstat (limited to 'node_modules/xmlbuilder/lib')
| -rw-r--r-- | node_modules/xmlbuilder/lib/XMLBuilder.js | 69 | 
1 files changed, 69 insertions, 0 deletions
| diff --git a/node_modules/xmlbuilder/lib/XMLBuilder.js b/node_modules/xmlbuilder/lib/XMLBuilder.js new file mode 100644 index 000000000..42828338e --- /dev/null +++ b/node_modules/xmlbuilder/lib/XMLBuilder.js @@ -0,0 +1,69 @@ +// Generated by CoffeeScript 1.9.1 +(function() { +  var XMLBuilder, XMLDeclaration, XMLDocType, XMLElement, XMLStringifier; + +  XMLStringifier = require('./XMLStringifier'); + +  XMLDeclaration = require('./XMLDeclaration'); + +  XMLDocType = require('./XMLDocType'); + +  XMLElement = require('./XMLElement'); + +  module.exports = XMLBuilder = (function() { +    function XMLBuilder(name, options) { +      var root, temp; +      if (name == null) { +        throw new Error("Root element needs a name"); +      } +      if (options == null) { +        options = {}; +      } +      this.options = options; +      this.stringify = new XMLStringifier(options); +      temp = new XMLElement(this, 'doc'); +      root = temp.element(name); +      root.isRoot = true; +      root.documentObject = this; +      this.rootObject = root; +      if (!options.headless) { +        root.declaration(options); +        if ((options.pubID != null) || (options.sysID != null)) { +          root.doctype(options); +        } +      } +    } + +    XMLBuilder.prototype.root = function() { +      return this.rootObject; +    }; + +    XMLBuilder.prototype.end = function(options) { +      return this.toString(options); +    }; + +    XMLBuilder.prototype.toString = function(options) { +      var indent, newline, offset, pretty, r, ref, ref1, ref2; +      pretty = (options != null ? options.pretty : void 0) || false; +      indent = (ref = options != null ? options.indent : void 0) != null ? ref : '  '; +      offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; +      newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; +      r = ''; +      if (this.xmldec != null) { +        r += this.xmldec.toString(options); +      } +      if (this.doctype != null) { +        r += this.doctype.toString(options); +      } +      r += this.rootObject.toString(options); +      if (pretty && r.slice(-newline.length) === newline) { +        r = r.slice(0, -newline.length); +      } +      return r; +    }; + +    return XMLBuilder; + +  })(); + +}).call(this); | 
