00001
00002 (function() {
00003 var XMLDTDAttList, XMLNode,
00004 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; },
00005 hasProp = {}.hasOwnProperty;
00006
00007 XMLNode = require('./XMLNode');
00008
00009 module.exports = XMLDTDAttList = (function(superClass) {
00010 extend(XMLDTDAttList, superClass);
00011
00012 function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
00013 XMLDTDAttList.__super__.constructor.call(this, parent);
00014 if (elementName == null) {
00015 throw new Error("Missing DTD element name");
00016 }
00017 if (attributeName == null) {
00018 throw new Error("Missing DTD attribute name");
00019 }
00020 if (!attributeType) {
00021 throw new Error("Missing DTD attribute type");
00022 }
00023 if (!defaultValueType) {
00024 throw new Error("Missing DTD attribute default");
00025 }
00026 if (defaultValueType.indexOf('#') !== 0) {
00027 defaultValueType = '#' + defaultValueType;
00028 }
00029 if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
00030 throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");
00031 }
00032 if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
00033 throw new Error("Default value only applies to #FIXED or #DEFAULT");
00034 }
00035 this.elementName = this.stringify.eleName(elementName);
00036 this.attributeName = this.stringify.attName(attributeName);
00037 this.attributeType = this.stringify.dtdAttType(attributeType);
00038 this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
00039 this.defaultValueType = defaultValueType;
00040 }
00041
00042 XMLDTDAttList.prototype.toString = function(options) {
00043 return this.options.writer.set(options).dtdAttList(this);
00044 };
00045
00046 return XMLDTDAttList;
00047
00048 })(XMLNode);
00049
00050 }).call(this);