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