00001
00002 (function() {
00003 var XMLDTDElement, create;
00004
00005 create = require('lodash/create');
00006
00007 module.exports = XMLDTDElement = (function() {
00008 function XMLDTDElement(parent, name, value) {
00009 this.stringify = parent.stringify;
00010 if (name == null) {
00011 throw new Error("Missing DTD element name");
00012 }
00013 if (!value) {
00014 value = '(#PCDATA)';
00015 }
00016 if (Array.isArray(value)) {
00017 value = '(' + value.join(',') + ')';
00018 }
00019 this.name = this.stringify.eleName(name);
00020 this.value = this.stringify.dtdElementValue(value);
00021 }
00022
00023 XMLDTDElement.prototype.toString = function(options, level) {
00024 var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
00025 pretty = (options != null ? options.pretty : void 0) || false;
00026 indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
00027 offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
00028 newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
00029 level || (level = 0);
00030 space = new Array(level + offset + 1).join(indent);
00031 r = '';
00032 if (pretty) {
00033 r += space;
00034 }
00035 r += '<!ELEMENT ' + this.name + ' ' + this.value + '>';
00036 if (pretty) {
00037 r += newline;
00038 }
00039 return r;
00040 };
00041
00042 return XMLDTDElement;
00043
00044 })();
00045
00046 }).call(this);