Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

XMLDTDAttList.js 2.0KB

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");
  13. }
  14. if (attributeName == null) {
  15. throw new Error("Missing DTD attribute name");
  16. }
  17. if (!attributeType) {
  18. throw new Error("Missing DTD attribute type");
  19. }
  20. if (!defaultValueType) {
  21. throw new Error("Missing DTD attribute default");
  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");
  28. }
  29. if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
  30. throw new Error("Default value only applies to #FIXED or #DEFAULT");
  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);