123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var error_1 = require("../error");
- var validate_1 = require("../validate");
- var XmlProcInst = (function () {
- function XmlProcInst(parent, validation, options) {
- this._validation = validation;
- this._parent = parent;
- this.content = options.content;
- this.target = options.target;
- }
- Object.defineProperty(XmlProcInst.prototype, "content", {
-
- get: function () {
- return this._content;
- },
-
- set: function (content) {
- if (!(0, validate_1.isUndefined)(content)) {
- if (this._validation && !(0, validate_1.validateChar)(content)) {
- throw new Error((0, error_1.getContext)(this.up()) + ": processing"
- + (" instruction content \"" + content + "\" should")
- + " not contain characters not allowed in XML");
- }
- else if (this._validation && content.indexOf("?>") !== -1) {
- throw new Error((0, error_1.getContext)(this.up()) + ": processing"
- + (" instruction content \"" + content + "\" should")
- + " not contain the string '?>'");
- }
- }
- this._content = content;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(XmlProcInst.prototype, "target", {
-
- get: function () {
- return this._target;
- },
-
- set: function (target) {
- if (this._validation && !(0, validate_1.validateName)(target)) {
- throw new Error((0, error_1.getContext)(this.up()) + ": processing"
- + (" instruction target \"" + target + "\" should")
- + " not contain characters not allowed in XML"
- + " names");
- }
- if (this._validation && target === "xml") {
- throw new Error((0, error_1.getContext)(this.up()) + ": processing"
- + (" instruction target \"" + target + "\" should")
- + " not be the string 'xml'");
- }
- this._target = target;
- },
- enumerable: false,
- configurable: true
- });
-
- XmlProcInst.prototype.toString = function () {
- if ((0, validate_1.isUndefined)(this._content)) {
- return "<?" + this._target + "?>";
- }
- else {
- return "<?" + this._target + " " + this._content + "?>";
- }
- };
-
- XmlProcInst.prototype.up = function () {
- return this._parent;
- };
- return XmlProcInst;
- }());
- exports.default = XmlProcInst;
|