artdaq_node_server  v1_00_08
 All Classes Namespaces Files Variables Pages
XMLDTDEntity.js
1 // Generated by CoffeeScript 1.10.0
2 (function() {
3  var XMLDTDEntity, XMLNode, 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;
6 
7  isObject = require('./Utility').isObject;
8 
9  XMLNode = require('./XMLNode');
10 
11  module.exports = XMLDTDEntity = (function(superClass) {
12  extend(XMLDTDEntity, superClass);
13 
14  function XMLDTDEntity(parent, pe, name, value) {
15  XMLDTDEntity.__super__.constructor.call(this, parent);
16  if (name == null) {
17  throw new Error("Missing entity name");
18  }
19  if (value == null) {
20  throw new Error("Missing entity value");
21  }
22  this.pe = !!pe;
23  this.name = this.stringify.eleName(name);
24  if (!isObject(value)) {
25  this.value = this.stringify.dtdEntityValue(value);
26  } else {
27  if (!value.pubID && !value.sysID) {
28  throw new Error("Public and/or system identifiers are required for an external entity");
29  }
30  if (value.pubID && !value.sysID) {
31  throw new Error("System identifier is required for a public external entity");
32  }
33  if (value.pubID != null) {
34  this.pubID = this.stringify.dtdPubID(value.pubID);
35  }
36  if (value.sysID != null) {
37  this.sysID = this.stringify.dtdSysID(value.sysID);
38  }
39  if (value.nData != null) {
40  this.nData = this.stringify.dtdNData(value.nData);
41  }
42  if (this.pe && this.nData) {
43  throw new Error("Notation declaration is not allowed in a parameter entity");
44  }
45  }
46  }
47 
48  XMLDTDEntity.prototype.toString = function(options) {
49  return this.options.writer.set(options).dtdEntity(this);
50  };
51 
52  return XMLDTDEntity;
53 
54  })(XMLNode);
55 
56 }).call(this);