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