00001
00002 (function() {
00003 var XMLDeclaration, XMLNode, create, isObject,
00004 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; },
00005 hasProp = {}.hasOwnProperty;
00006
00007 create = require('lodash/create');
00008
00009 isObject = require('lodash/isObject');
00010
00011 XMLNode = require('./XMLNode');
00012
00013 module.exports = XMLDeclaration = (function(superClass) {
00014 extend(XMLDeclaration, superClass);
00015
00016 function XMLDeclaration(parent, version, encoding, standalone) {
00017 var ref;
00018 XMLDeclaration.__super__.constructor.call(this, parent);
00019 if (isObject(version)) {
00020 ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
00021 }
00022 if (!version) {
00023 version = '1.0';
00024 }
00025 this.version = this.stringify.xmlVersion(version);
00026 if (encoding != null) {
00027 this.encoding = this.stringify.xmlEncoding(encoding);
00028 }
00029 if (standalone != null) {
00030 this.standalone = this.stringify.xmlStandalone(standalone);
00031 }
00032 }
00033
00034 XMLDeclaration.prototype.toString = function(options, level) {
00035 var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
00036 pretty = (options != null ? options.pretty : void 0) || false;
00037 indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
00038 offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
00039 newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
00040 level || (level = 0);
00041 space = new Array(level + offset + 1).join(indent);
00042 r = '';
00043 if (pretty) {
00044 r += space;
00045 }
00046 r += '<?xml';
00047 r += ' version="' + this.version + '"';
00048 if (this.encoding != null) {
00049 r += ' encoding="' + this.encoding + '"';
00050 }
00051 if (this.standalone != null) {
00052 r += ' standalone="' + this.standalone + '"';
00053 }
00054 r += '?>';
00055 if (pretty) {
00056 r += newline;
00057 }
00058 return r;
00059 };
00060
00061 return XMLDeclaration;
00062
00063 })(XMLNode);
00064
00065 }).call(this);