index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
  4. ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
  5. XMLDOMImplementation = require('./XMLDOMImplementation');
  6. XMLDocument = require('./XMLDocument');
  7. XMLDocumentCB = require('./XMLDocumentCB');
  8. XMLStringWriter = require('./XMLStringWriter');
  9. XMLStreamWriter = require('./XMLStreamWriter');
  10. NodeType = require('./NodeType');
  11. WriterState = require('./WriterState');
  12. module.exports.create = function(name, xmldec, doctype, options) {
  13. var doc, root;
  14. if (name == null) {
  15. throw new Error("Root element needs a name.");
  16. }
  17. options = assign({}, xmldec, doctype, options);
  18. doc = new XMLDocument(options);
  19. root = doc.element(name);
  20. if (!options.headless) {
  21. doc.declaration(options);
  22. if ((options.pubID != null) || (options.sysID != null)) {
  23. doc.dtd(options);
  24. }
  25. }
  26. return root;
  27. };
  28. module.exports.begin = function(options, onData, onEnd) {
  29. var ref1;
  30. if (isFunction(options)) {
  31. ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
  32. options = {};
  33. }
  34. if (onData) {
  35. return new XMLDocumentCB(options, onData, onEnd);
  36. } else {
  37. return new XMLDocument(options);
  38. }
  39. };
  40. module.exports.stringWriter = function(options) {
  41. return new XMLStringWriter(options);
  42. };
  43. module.exports.streamWriter = function(stream, options) {
  44. return new XMLStreamWriter(stream, options);
  45. };
  46. module.exports.implementation = new XMLDOMImplementation();
  47. module.exports.nodeType = NodeType;
  48. module.exports.writerState = WriterState;
  49. }).call(this);