artdaq_node_server  v1_00_09
 All Classes Namespaces Files Variables Pages
XMLDocType.js
1 // Generated by CoffeeScript 1.9.1
2 (function() {
3  var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLProcessingInstruction, create, isObject;
4 
5  create = require('lodash/create');
6 
7  isObject = require('lodash/isObject');
8 
9  XMLCData = require('./XMLCData');
10 
11  XMLComment = require('./XMLComment');
12 
13  XMLDTDAttList = require('./XMLDTDAttList');
14 
15  XMLDTDEntity = require('./XMLDTDEntity');
16 
17  XMLDTDElement = require('./XMLDTDElement');
18 
19  XMLDTDNotation = require('./XMLDTDNotation');
20 
21  XMLProcessingInstruction = require('./XMLProcessingInstruction');
22 
23  module.exports = XMLDocType = (function() {
24  function XMLDocType(parent, pubID, sysID) {
25  var ref, ref1;
26  this.documentObject = parent;
27  this.stringify = this.documentObject.stringify;
28  this.children = [];
29  if (isObject(pubID)) {
30  ref = pubID, pubID = ref.pubID, sysID = ref.sysID;
31  }
32  if (sysID == null) {
33  ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1];
34  }
35  if (pubID != null) {
36  this.pubID = this.stringify.dtdPubID(pubID);
37  }
38  if (sysID != null) {
39  this.sysID = this.stringify.dtdSysID(sysID);
40  }
41  }
42 
43  XMLDocType.prototype.element = function(name, value) {
44  var child;
45  child = new XMLDTDElement(this, name, value);
46  this.children.push(child);
47  return this;
48  };
49 
50  XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
51  var child;
52  child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
53  this.children.push(child);
54  return this;
55  };
56 
57  XMLDocType.prototype.entity = function(name, value) {
58  var child;
59  child = new XMLDTDEntity(this, false, name, value);
60  this.children.push(child);
61  return this;
62  };
63 
64  XMLDocType.prototype.pEntity = function(name, value) {
65  var child;
66  child = new XMLDTDEntity(this, true, name, value);
67  this.children.push(child);
68  return this;
69  };
70 
71  XMLDocType.prototype.notation = function(name, value) {
72  var child;
73  child = new XMLDTDNotation(this, name, value);
74  this.children.push(child);
75  return this;
76  };
77 
78  XMLDocType.prototype.cdata = function(value) {
79  var child;
80  child = new XMLCData(this, value);
81  this.children.push(child);
82  return this;
83  };
84 
85  XMLDocType.prototype.comment = function(value) {
86  var child;
87  child = new XMLComment(this, value);
88  this.children.push(child);
89  return this;
90  };
91 
92  XMLDocType.prototype.instruction = function(target, value) {
93  var child;
94  child = new XMLProcessingInstruction(this, target, value);
95  this.children.push(child);
96  return this;
97  };
98 
99  XMLDocType.prototype.root = function() {
100  return this.documentObject.root();
101  };
102 
103  XMLDocType.prototype.document = function() {
104  return this.documentObject;
105  };
106 
107  XMLDocType.prototype.toString = function(options, level) {
108  var child, i, indent, len, newline, offset, pretty, r, ref, ref1, ref2, ref3, space;
109  pretty = (options != null ? options.pretty : void 0) || false;
110  indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
111  offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
112  newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
113  level || (level = 0);
114  space = new Array(level + offset + 1).join(indent);
115  r = '';
116  if (pretty) {
117  r += space;
118  }
119  r += '<!DOCTYPE ' + this.root().name;
120  if (this.pubID && this.sysID) {
121  r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"';
122  } else if (this.sysID) {
123  r += ' SYSTEM "' + this.sysID + '"';
124  }
125  if (this.children.length > 0) {
126  r += ' [';
127  if (pretty) {
128  r += newline;
129  }
130  ref3 = this.children;
131  for (i = 0, len = ref3.length; i < len; i++) {
132  child = ref3[i];
133  r += child.toString(options, level + 1);
134  }
135  r += ']';
136  }
137  r += '>';
138  if (pretty) {
139  r += newline;
140  }
141  return r;
142  };
143 
144  XMLDocType.prototype.ele = function(name, value) {
145  return this.element(name, value);
146  };
147 
148  XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
149  return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
150  };
151 
152  XMLDocType.prototype.ent = function(name, value) {
153  return this.entity(name, value);
154  };
155 
156  XMLDocType.prototype.pent = function(name, value) {
157  return this.pEntity(name, value);
158  };
159 
160  XMLDocType.prototype.not = function(name, value) {
161  return this.notation(name, value);
162  };
163 
164  XMLDocType.prototype.dat = function(value) {
165  return this.cdata(value);
166  };
167 
168  XMLDocType.prototype.com = function(value) {
169  return this.comment(value);
170  };
171 
172  XMLDocType.prototype.ins = function(target, value) {
173  return this.instruction(target, value);
174  };
175 
176  XMLDocType.prototype.up = function() {
177  return this.root();
178  };
179 
180  XMLDocType.prototype.doc = function() {
181  return this.document();
182  };
183 
184  return XMLDocType;
185 
186  })();
187 
188 }).call(this);