3 var XMLDeclaration, XMLNode, create, isObject,
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 create = require(
'lodash/create');
9 isObject = require(
'lodash/isObject');
11 XMLNode = require(
'./XMLNode');
13 module.exports = XMLDeclaration = (
function(superClass) {
14 extend(XMLDeclaration, superClass);
16 function XMLDeclaration(parent, version, encoding, standalone) {
18 XMLDeclaration.__super__.constructor.call(
this, parent);
19 if (isObject(version)) {
20 ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
25 this.version = this.stringify.xmlVersion(version);
26 if (encoding != null) {
27 this.encoding = this.stringify.xmlEncoding(encoding);
29 if (standalone != null) {
30 this.standalone = this.stringify.xmlStandalone(standalone);
34 XMLDeclaration.prototype.toString =
function(options, level) {
35 var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
36 pretty = (options != null ? options.pretty :
void 0) ||
false;
37 indent = (ref = options != null ? options.indent :
void 0) != null ? ref :
' ';
38 offset = (ref1 = options != null ? options.offset :
void 0) != null ? ref1 : 0;
39 newline = (ref2 = options != null ? options.newline :
void 0) != null ? ref2 :
'\n';
41 space =
new Array(level + offset + 1).join(indent);
47 r +=
' version="' + this.version +
'"';
48 if (this.encoding != null) {
49 r +=
' encoding="' + this.encoding +
'"';
51 if (this.standalone != null) {
52 r +=
' standalone="' + this.standalone +
'"';
61 return XMLDeclaration;