00001
00002 (function() {
00003 var XMLDTDNotation, create;
00004
00005 create = require('lodash/create');
00006
00007 module.exports = XMLDTDNotation = (function() {
00008 function XMLDTDNotation(parent, name, value) {
00009 this.stringify = parent.stringify;
00010 if (name == null) {
00011 throw new Error("Missing notation name");
00012 }
00013 if (!value.pubID && !value.sysID) {
00014 throw new Error("Public or system identifiers are required for an external entity");
00015 }
00016 this.name = this.stringify.eleName(name);
00017 if (value.pubID != null) {
00018 this.pubID = this.stringify.dtdPubID(value.pubID);
00019 }
00020 if (value.sysID != null) {
00021 this.sysID = this.stringify.dtdSysID(value.sysID);
00022 }
00023 }
00024
00025 XMLDTDNotation.prototype.toString = function(options, level) {
00026 var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
00027 pretty = (options != null ? options.pretty : void 0) || false;
00028 indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
00029 offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
00030 newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
00031 level || (level = 0);
00032 space = new Array(level + offset + 1).join(indent);
00033 r = '';
00034 if (pretty) {
00035 r += space;
00036 }
00037 r += '<!NOTATION ' + this.name;
00038 if (this.pubID && this.sysID) {
00039 r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"';
00040 } else if (this.pubID) {
00041 r += ' PUBLIC "' + this.pubID + '"';
00042 } else if (this.sysID) {
00043 r += ' SYSTEM "' + this.sysID + '"';
00044 }
00045 r += '>';
00046 if (pretty) {
00047 r += newline;
00048 }
00049 return r;
00050 };
00051
00052 return XMLDTDNotation;
00053
00054 })();
00055
00056 }).call(this);