XMLDTDAttList.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var NodeType, XMLDTDAttList, 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 = XMLDTDAttList = (function(superClass) {
  9. extend(XMLDTDAttList, superClass);
  10. function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  11. XMLDTDAttList.__super__.constructor.call(this, parent);
  12. if (elementName == null) {
  13. throw new Error("Missing DTD element name. " + this.debugInfo());
  14. }
  15. if (attributeName == null) {
  16. throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
  17. }
  18. if (!attributeType) {
  19. throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
  20. }
  21. if (!defaultValueType) {
  22. throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
  23. }
  24. if (defaultValueType.indexOf('#') !== 0) {
  25. defaultValueType = '#' + defaultValueType;
  26. }
  27. if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
  28. throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
  29. }
  30. if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
  31. throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
  32. }
  33. this.elementName = this.stringify.name(elementName);
  34. this.type = NodeType.AttributeDeclaration;
  35. this.attributeName = this.stringify.name(attributeName);
  36. this.attributeType = this.stringify.dtdAttType(attributeType);
  37. if (defaultValue) {
  38. this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
  39. }
  40. this.defaultValueType = defaultValueType;
  41. }
  42. XMLDTDAttList.prototype.toString = function(options) {
  43. return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
  44. };
  45. return XMLDTDAttList;
  46. })(XMLNode);
  47. }).call(this);