// Generated by CoffeeScript 2.4.1 (function() { var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject; ({isObject} = require('./Utility')); XMLNode = require('./XMLNode'); NodeType = require('./NodeType'); XMLDTDAttList = require('./XMLDTDAttList'); XMLDTDEntity = require('./XMLDTDEntity'); XMLDTDElement = require('./XMLDTDElement'); XMLDTDNotation = require('./XMLDTDNotation'); XMLNamedNodeMap = require('./XMLNamedNodeMap'); // Represents doctype declaration module.exports = XMLDocType = (function() { class XMLDocType extends XMLNode { // Initializes a new instance of `XMLDocType` // `parent` the document object // `pubID` public identifier of the external subset // `sysID` system identifier of the external subset constructor(parent, pubID, sysID) { var child, i, len, ref; super(parent); this.type = NodeType.DocType; // set DTD name to the name of the root node if (parent.children) { ref = parent.children; for (i = 0, len = ref.length; i < len; i++) { child = ref[i]; if (child.type === NodeType.Element) { this.name = child.name; break; } } } this.documentObject = parent; // arguments may also be passed as an object if (isObject(pubID)) { ({pubID, sysID} = pubID); } if (sysID == null) { [sysID, pubID] = [pubID, sysID]; } if (pubID != null) { this.pubID = this.stringify.dtdPubID(pubID); } if (sysID != null) { this.sysID = this.stringify.dtdSysID(sysID); } } // Creates an element type declaration // `name` element name // `value` element content (defaults to #PCDATA) element(name, value) { var child; child = new XMLDTDElement(this, name, value); this.children.push(child); return this; } // Creates an attribute declaration // `elementName` the name of the element containing this attribute // `attributeName` attribute name // `attributeType` type of the attribute (defaults to CDATA) // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or // #DEFAULT) (defaults to #IMPLIED) // `defaultValue` default value of the attribute // (only used for #FIXED or #DEFAULT) attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) { var child; child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); this.children.push(child); return this; } // Creates a general entity declaration // `name` the name of the entity // `value` internal entity value or an object with external entity details // `value.pubID` public identifier // `value.sysID` system identifier // `value.nData` notation declaration entity(name, value) { var child; child = new XMLDTDEntity(this, false, name, value); this.children.push(child); return this; } // Creates a parameter entity declaration // `name` the name of the entity // `value` internal entity value or an object with external entity details // `value.pubID` public identifier // `value.sysID` system identifier pEntity(name, value) { var child; child = new XMLDTDEntity(this, true, name, value); this.children.push(child); return this; } // Creates a NOTATION declaration // `name` the name of the notation // `value` an object with external entity details // `value.pubID` public identifier // `value.sysID` system identifier notation(name, value) { var child; child = new XMLDTDNotation(this, name, value); this.children.push(child); return this; } // Converts to string // `options.pretty` pretty prints the result // `options.indent` indentation for pretty print // `options.offset` how many indentations to add to every line for pretty print // `options.newline` newline sequence for pretty print toString(options) { return this.options.writer.docType(this, this.options.writer.filterOptions(options)); } // Aliases ele(name, value) { return this.element(name, value); } att(elementName, attributeName, attributeType, defaultValueType, defaultValue) { return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); } ent(name, value) { return this.entity(name, value); } pent(name, value) { return this.pEntity(name, value); } not(name, value) { return this.notation(name, value); } up() { return this.root() || this.documentObject; } isEqualNode(node) { if (!super.isEqualNode(node)) { return false; } if (node.name !== this.name) { return false; } if (node.publicId !== this.publicId) { return false; } if (node.systemId !== this.systemId) { return false; } return true; } }; // DOM level 1 Object.defineProperty(XMLDocType.prototype, 'entities', { get: function() { var child, i, len, nodes, ref; nodes = {}; ref = this.children; for (i = 0, len = ref.length; i < len; i++) { child = ref[i]; if ((child.type === NodeType.EntityDeclaration) && !child.pe) { nodes[child.name] = child; } } return new XMLNamedNodeMap(nodes); } }); Object.defineProperty(XMLDocType.prototype, 'notations', { get: function() { var child, i, len, nodes, ref; nodes = {}; ref = this.children; for (i = 0, len = ref.length; i < len; i++) { child = ref[i]; if (child.type === NodeType.NotationDeclaration) { nodes[child.name] = child; } } return new XMLNamedNodeMap(nodes); } }); // DOM level 2 Object.defineProperty(XMLDocType.prototype, 'publicId', { get: function() { return this.pubID; } }); Object.defineProperty(XMLDocType.prototype, 'systemId', { get: function() { return this.sysID; } }); Object.defineProperty(XMLDocType.prototype, 'internalSubset', { get: function() { throw new Error("This DOM method is not implemented." + this.debugInfo()); } }); return XMLDocType; }).call(this); }).call(this);