XmlDtdNotation.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. "use strict";
  2. /**
  3. * Copyright (C) 2016-2019 Michael Kourlas
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. var error_1 = require("../error");
  19. var validate_1 = require("../validate");
  20. /**
  21. * Represents a notation declaration in a document type definition.
  22. *
  23. * A notation declaration is structured as follows, where `{text}` is the
  24. * text of the declaration:
  25. *
  26. * ```xml
  27. * <!NOTATION {text}>
  28. * ```
  29. */
  30. var XmlDtdNotation = /** @class */ (function () {
  31. function XmlDtdNotation(parent, validation, options) {
  32. this._validation = validation;
  33. this._parent = parent;
  34. this.charData = options.charData;
  35. }
  36. Object.defineProperty(XmlDtdNotation.prototype, "charData", {
  37. /**
  38. * Gets the text of this notation declaration.
  39. */
  40. get: function () {
  41. return this._charData;
  42. },
  43. /**
  44. * Sets the text of this notation declaration.
  45. */
  46. set: function (charData) {
  47. if (this._validation && !(0, validate_1.validateChar)(charData)) {
  48. throw new Error((0, error_1.getContext)(this.up()) + ": notation declaration"
  49. + (" \"" + charData + "\" should not contain characters")
  50. + " not allowed in XML");
  51. }
  52. this._charData = charData;
  53. },
  54. enumerable: false,
  55. configurable: true
  56. });
  57. /**
  58. * Returns an XML string representation of this notation declaration.
  59. */
  60. XmlDtdNotation.prototype.toString = function () {
  61. return "<!NOTATION " + this._charData + ">";
  62. };
  63. /**
  64. * Returns the parent of this notation declaration.
  65. */
  66. XmlDtdNotation.prototype.up = function () {
  67. return this._parent;
  68. };
  69. return XmlDtdNotation;
  70. }());
  71. exports.default = XmlDtdNotation;