00001
00002 (function() {
00003 var XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNode, isObject,
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 isObject = require('./Utility').isObject;
00008
00009 XMLNode = require('./XMLNode');
00010
00011 XMLDTDAttList = require('./XMLDTDAttList');
00012
00013 XMLDTDEntity = require('./XMLDTDEntity');
00014
00015 XMLDTDElement = require('./XMLDTDElement');
00016
00017 XMLDTDNotation = require('./XMLDTDNotation');
00018
00019 module.exports = XMLDocType = (function(superClass) {
00020 extend(XMLDocType, superClass);
00021
00022 function XMLDocType(parent, pubID, sysID) {
00023 var ref, ref1;
00024 XMLDocType.__super__.constructor.call(this, parent);
00025 this.documentObject = parent;
00026 if (isObject(pubID)) {
00027 ref = pubID, pubID = ref.pubID, sysID = ref.sysID;
00028 }
00029 if (sysID == null) {
00030 ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1];
00031 }
00032 if (pubID != null) {
00033 this.pubID = this.stringify.dtdPubID(pubID);
00034 }
00035 if (sysID != null) {
00036 this.sysID = this.stringify.dtdSysID(sysID);
00037 }
00038 }
00039
00040 XMLDocType.prototype.element = function(name, value) {
00041 var child;
00042 child = new XMLDTDElement(this, name, value);
00043 this.children.push(child);
00044 return this;
00045 };
00046
00047 XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
00048 var child;
00049 child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
00050 this.children.push(child);
00051 return this;
00052 };
00053
00054 XMLDocType.prototype.entity = function(name, value) {
00055 var child;
00056 child = new XMLDTDEntity(this, false, name, value);
00057 this.children.push(child);
00058 return this;
00059 };
00060
00061 XMLDocType.prototype.pEntity = function(name, value) {
00062 var child;
00063 child = new XMLDTDEntity(this, true, name, value);
00064 this.children.push(child);
00065 return this;
00066 };
00067
00068 XMLDocType.prototype.notation = function(name, value) {
00069 var child;
00070 child = new XMLDTDNotation(this, name, value);
00071 this.children.push(child);
00072 return this;
00073 };
00074
00075 XMLDocType.prototype.toString = function(options) {
00076 return this.options.writer.set(options).docType(this);
00077 };
00078
00079 XMLDocType.prototype.ele = function(name, value) {
00080 return this.element(name, value);
00081 };
00082
00083 XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
00084 return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
00085 };
00086
00087 XMLDocType.prototype.ent = function(name, value) {
00088 return this.entity(name, value);
00089 };
00090
00091 XMLDocType.prototype.pent = function(name, value) {
00092 return this.pEntity(name, value);
00093 };
00094
00095 XMLDocType.prototype.not = function(name, value) {
00096 return this.notation(name, value);
00097 };
00098
00099 XMLDocType.prototype.up = function() {
00100 return this.root() || this.documentObject;
00101 };
00102
00103 return XMLDocType;
00104
00105 })(XMLNode);
00106
00107 }).call(this);