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;
7 isObject = require(
'./Utility').isObject;
9 XMLNode = require(
'./XMLNode');
11 module.exports = XMLDTDEntity = (
function(superClass) {
12 extend(XMLDTDEntity, superClass);
14 function XMLDTDEntity(parent, pe, name, value) {
15 XMLDTDEntity.__super__.constructor.call(
this, parent);
17 throw new Error(
"Missing entity name");
20 throw new Error(
"Missing entity value");
23 this.name = this.stringify.eleName(name);
24 if (!isObject(value)) {
25 this.value = this.stringify.dtdEntityValue(value);
27 if (!value.pubID && !value.sysID) {
28 throw new Error(
"Public and/or system identifiers are required for an external entity");
30 if (value.pubID && !value.sysID) {
31 throw new Error(
"System identifier is required for a public external entity");
33 if (value.pubID != null) {
34 this.pubID = this.stringify.dtdPubID(value.pubID);
36 if (value.sysID != null) {
37 this.sysID = this.stringify.dtdSysID(value.sysID);
39 if (value.nData != null) {
40 this.nData = this.stringify.dtdNData(value.nData);
42 if (this.pe && this.nData) {
43 throw new Error(
"Notation declaration is not allowed in a parameter entity");
48 XMLDTDEntity.prototype.toString =
function(options) {
49 return this.options.writer.set(options).dtdEntity(
this);