00001
00002 (function() {
00003 var XMLWriterBase,
00004 hasProp = {}.hasOwnProperty;
00005
00006 module.exports = XMLWriterBase = (function() {
00007 function XMLWriterBase(options) {
00008 var key, ref, ref1, ref2, ref3, ref4, value;
00009 options || (options = {});
00010 this.pretty = options.pretty || false;
00011 this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
00012 if (this.pretty) {
00013 this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
00014 this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
00015 this.offset = (ref3 = options.offset) != null ? ref3 : 0;
00016 } else {
00017 this.indent = '';
00018 this.newline = '';
00019 this.offset = 0;
00020 }
00021 ref4 = options.writer || {};
00022 for (key in ref4) {
00023 if (!hasProp.call(ref4, key)) continue;
00024 value = ref4[key];
00025 this[key] = value;
00026 }
00027 }
00028
00029 XMLWriterBase.prototype.set = function(options) {
00030 var key, ref, value;
00031 options || (options = {});
00032 if ("pretty" in options) {
00033 this.pretty = options.pretty;
00034 }
00035 if ("allowEmpty" in options) {
00036 this.allowEmpty = options.allowEmpty;
00037 }
00038 if (this.pretty) {
00039 this.indent = "indent" in options ? options.indent : ' ';
00040 this.newline = "newline" in options ? options.newline : '\n';
00041 this.offset = "offset" in options ? options.offset : 0;
00042 } else {
00043 this.indent = '';
00044 this.newline = '';
00045 this.offset = 0;
00046 }
00047 ref = options.writer || {};
00048 for (key in ref) {
00049 if (!hasProp.call(ref, key)) continue;
00050 value = ref[key];
00051 this[key] = value;
00052 }
00053 return this;
00054 };
00055
00056 XMLWriterBase.prototype.space = function(level) {
00057 if (this.pretty) {
00058 return new Array((level || 0) + this.offset + 1).join(this.indent);
00059 } else {
00060 return '';
00061 }
00062 };
00063
00064 return XMLWriterBase;
00065
00066 })();
00067
00068 }).call(this);