XMLDTDEntity.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var NodeType, 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. isObject = require('./Utility').isObject;
  7. XMLNode = require('./XMLNode');
  8. NodeType = require('./NodeType');
  9. module.exports = XMLDTDEntity = (function(superClass) {
  10. extend(XMLDTDEntity, superClass);
  11. function XMLDTDEntity(parent, pe, name, value) {
  12. XMLDTDEntity.__super__.constructor.call(this, parent);
  13. if (name == null) {
  14. throw new Error("Missing DTD entity name. " + this.debugInfo(name));
  15. }
  16. if (value == null) {
  17. throw new Error("Missing DTD entity value. " + this.debugInfo(name));
  18. }
  19. this.pe = !!pe;
  20. this.name = this.stringify.name(name);
  21. this.type = NodeType.EntityDeclaration;
  22. if (!isObject(value)) {
  23. this.value = this.stringify.dtdEntityValue(value);
  24. this.internal = true;
  25. } else {
  26. if (!value.pubID && !value.sysID) {
  27. throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
  28. }
  29. if (value.pubID && !value.sysID) {
  30. throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
  31. }
  32. this.internal = false;
  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. " + this.debugInfo(name));
  44. }
  45. }
  46. }
  47. Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
  48. get: function() {
  49. return this.pubID;
  50. }
  51. });
  52. Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
  53. get: function() {
  54. return this.sysID;
  55. }
  56. });
  57. Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
  58. get: function() {
  59. return this.nData || null;
  60. }
  61. });
  62. Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
  63. get: function() {
  64. return null;
  65. }
  66. });
  67. Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
  68. get: function() {
  69. return null;
  70. }
  71. });
  72. Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
  73. get: function() {
  74. return null;
  75. }
  76. });
  77. XMLDTDEntity.prototype.toString = function(options) {
  78. return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
  79. };
  80. return XMLDTDEntity;
  81. })(XMLNode);
  82. }).call(this);