XMLDTDElement.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var NodeType, XMLDTDElement, XMLNode,
  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. XMLNode = require('./XMLNode');
  7. NodeType = require('./NodeType');
  8. module.exports = XMLDTDElement = (function(superClass) {
  9. extend(XMLDTDElement, superClass);
  10. function XMLDTDElement(parent, name, value) {
  11. XMLDTDElement.__super__.constructor.call(this, parent);
  12. if (name == null) {
  13. throw new Error("Missing DTD element name. " + this.debugInfo());
  14. }
  15. if (!value) {
  16. value = '(#PCDATA)';
  17. }
  18. if (Array.isArray(value)) {
  19. value = '(' + value.join(',') + ')';
  20. }
  21. this.name = this.stringify.name(name);
  22. this.type = NodeType.ElementDeclaration;
  23. this.value = this.stringify.dtdElementValue(value);
  24. }
  25. XMLDTDElement.prototype.toString = function(options) {
  26. return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
  27. };
  28. return XMLDTDElement;
  29. })(XMLNode);
  30. }).call(this);