XMLDocument.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
  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;
  6. isPlainObject = require('./Utility').isPlainObject;
  7. XMLDOMImplementation = require('./XMLDOMImplementation');
  8. XMLDOMConfiguration = require('./XMLDOMConfiguration');
  9. XMLNode = require('./XMLNode');
  10. NodeType = require('./NodeType');
  11. XMLStringifier = require('./XMLStringifier');
  12. XMLStringWriter = require('./XMLStringWriter');
  13. module.exports = XMLDocument = (function(superClass) {
  14. extend(XMLDocument, superClass);
  15. function XMLDocument(options) {
  16. XMLDocument.__super__.constructor.call(this, null);
  17. this.name = "#document";
  18. this.type = NodeType.Document;
  19. this.documentURI = null;
  20. this.domConfig = new XMLDOMConfiguration();
  21. options || (options = {});
  22. if (!options.writer) {
  23. options.writer = new XMLStringWriter();
  24. }
  25. this.options = options;
  26. this.stringify = new XMLStringifier(options);
  27. }
  28. Object.defineProperty(XMLDocument.prototype, 'implementation', {
  29. value: new XMLDOMImplementation()
  30. });
  31. Object.defineProperty(XMLDocument.prototype, 'doctype', {
  32. get: function() {
  33. var child, i, len, ref;
  34. ref = this.children;
  35. for (i = 0, len = ref.length; i < len; i++) {
  36. child = ref[i];
  37. if (child.type === NodeType.DocType) {
  38. return child;
  39. }
  40. }
  41. return null;
  42. }
  43. });
  44. Object.defineProperty(XMLDocument.prototype, 'documentElement', {
  45. get: function() {
  46. return this.rootObject || null;
  47. }
  48. });
  49. Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
  50. get: function() {
  51. return null;
  52. }
  53. });
  54. Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
  55. get: function() {
  56. return false;
  57. }
  58. });
  59. Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
  60. get: function() {
  61. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  62. return this.children[0].encoding;
  63. } else {
  64. return null;
  65. }
  66. }
  67. });
  68. Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
  69. get: function() {
  70. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  71. return this.children[0].standalone === 'yes';
  72. } else {
  73. return false;
  74. }
  75. }
  76. });
  77. Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
  78. get: function() {
  79. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  80. return this.children[0].version;
  81. } else {
  82. return "1.0";
  83. }
  84. }
  85. });
  86. Object.defineProperty(XMLDocument.prototype, 'URL', {
  87. get: function() {
  88. return this.documentURI;
  89. }
  90. });
  91. Object.defineProperty(XMLDocument.prototype, 'origin', {
  92. get: function() {
  93. return null;
  94. }
  95. });
  96. Object.defineProperty(XMLDocument.prototype, 'compatMode', {
  97. get: function() {
  98. return null;
  99. }
  100. });
  101. Object.defineProperty(XMLDocument.prototype, 'characterSet', {
  102. get: function() {
  103. return null;
  104. }
  105. });
  106. Object.defineProperty(XMLDocument.prototype, 'contentType', {
  107. get: function() {
  108. return null;
  109. }
  110. });
  111. XMLDocument.prototype.end = function(writer) {
  112. var writerOptions;
  113. writerOptions = {};
  114. if (!writer) {
  115. writer = this.options.writer;
  116. } else if (isPlainObject(writer)) {
  117. writerOptions = writer;
  118. writer = this.options.writer;
  119. }
  120. return writer.document(this, writer.filterOptions(writerOptions));
  121. };
  122. XMLDocument.prototype.toString = function(options) {
  123. return this.options.writer.document(this, this.options.writer.filterOptions(options));
  124. };
  125. XMLDocument.prototype.createElement = function(tagName) {
  126. throw new Error("This DOM method is not implemented." + this.debugInfo());
  127. };
  128. XMLDocument.prototype.createDocumentFragment = function() {
  129. throw new Error("This DOM method is not implemented." + this.debugInfo());
  130. };
  131. XMLDocument.prototype.createTextNode = function(data) {
  132. throw new Error("This DOM method is not implemented." + this.debugInfo());
  133. };
  134. XMLDocument.prototype.createComment = function(data) {
  135. throw new Error("This DOM method is not implemented." + this.debugInfo());
  136. };
  137. XMLDocument.prototype.createCDATASection = function(data) {
  138. throw new Error("This DOM method is not implemented." + this.debugInfo());
  139. };
  140. XMLDocument.prototype.createProcessingInstruction = function(target, data) {
  141. throw new Error("This DOM method is not implemented." + this.debugInfo());
  142. };
  143. XMLDocument.prototype.createAttribute = function(name) {
  144. throw new Error("This DOM method is not implemented." + this.debugInfo());
  145. };
  146. XMLDocument.prototype.createEntityReference = function(name) {
  147. throw new Error("This DOM method is not implemented." + this.debugInfo());
  148. };
  149. XMLDocument.prototype.getElementsByTagName = function(tagname) {
  150. throw new Error("This DOM method is not implemented." + this.debugInfo());
  151. };
  152. XMLDocument.prototype.importNode = function(importedNode, deep) {
  153. throw new Error("This DOM method is not implemented." + this.debugInfo());
  154. };
  155. XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) {
  156. throw new Error("This DOM method is not implemented." + this.debugInfo());
  157. };
  158. XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) {
  159. throw new Error("This DOM method is not implemented." + this.debugInfo());
  160. };
  161. XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
  162. throw new Error("This DOM method is not implemented." + this.debugInfo());
  163. };
  164. XMLDocument.prototype.getElementById = function(elementId) {
  165. throw new Error("This DOM method is not implemented." + this.debugInfo());
  166. };
  167. XMLDocument.prototype.adoptNode = function(source) {
  168. throw new Error("This DOM method is not implemented." + this.debugInfo());
  169. };
  170. XMLDocument.prototype.normalizeDocument = function() {
  171. throw new Error("This DOM method is not implemented." + this.debugInfo());
  172. };
  173. XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) {
  174. throw new Error("This DOM method is not implemented." + this.debugInfo());
  175. };
  176. XMLDocument.prototype.getElementsByClassName = function(classNames) {
  177. throw new Error("This DOM method is not implemented." + this.debugInfo());
  178. };
  179. XMLDocument.prototype.createEvent = function(eventInterface) {
  180. throw new Error("This DOM method is not implemented." + this.debugInfo());
  181. };
  182. XMLDocument.prototype.createRange = function() {
  183. throw new Error("This DOM method is not implemented." + this.debugInfo());
  184. };
  185. XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) {
  186. throw new Error("This DOM method is not implemented." + this.debugInfo());
  187. };
  188. XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) {
  189. throw new Error("This DOM method is not implemented." + this.debugInfo());
  190. };
  191. return XMLDocument;
  192. })(XMLNode);
  193. }).call(this);