XMLDocument.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var 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. XMLNode = require('./XMLNode');
  8. XMLStringifier = require('./XMLStringifier');
  9. XMLStringWriter = require('./XMLStringWriter');
  10. module.exports = XMLDocument = (function(superClass) {
  11. extend(XMLDocument, superClass);
  12. function XMLDocument(options) {
  13. XMLDocument.__super__.constructor.call(this, null);
  14. this.name = "?xml";
  15. options || (options = {});
  16. if (!options.writer) {
  17. options.writer = new XMLStringWriter();
  18. }
  19. this.options = options;
  20. this.stringify = new XMLStringifier(options);
  21. this.isDocument = true;
  22. }
  23. XMLDocument.prototype.end = function(writer) {
  24. var writerOptions;
  25. if (!writer) {
  26. writer = this.options.writer;
  27. } else if (isPlainObject(writer)) {
  28. writerOptions = writer;
  29. writer = this.options.writer.set(writerOptions);
  30. }
  31. return writer.document(this);
  32. };
  33. XMLDocument.prototype.toString = function(options) {
  34. return this.options.writer.set(options).document(this);
  35. };
  36. return XMLDocument;
  37. })(XMLNode);
  38. }).call(this);