XMLDTDAttList.js 2.2 KB

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