xml2js 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec_status +5 -0
  3. data/CODE_OF_CONDUCT.md +74 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +41 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +44 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/lib/xml2js.rb +5 -0
  12. data/lib/xml2js/node_modules/sax/LICENSE +41 -0
  13. data/lib/xml2js/node_modules/sax/README.md +225 -0
  14. data/lib/xml2js/node_modules/sax/lib/sax.js +1565 -0
  15. data/lib/xml2js/node_modules/sax/package.json +61 -0
  16. data/lib/xml2js/node_modules/xml2js/LICENSE +19 -0
  17. data/lib/xml2js/node_modules/xml2js/README.md +406 -0
  18. data/lib/xml2js/node_modules/xml2js/lib/bom.js +12 -0
  19. data/lib/xml2js/node_modules/xml2js/lib/builder.js +127 -0
  20. data/lib/xml2js/node_modules/xml2js/lib/defaults.js +72 -0
  21. data/lib/xml2js/node_modules/xml2js/lib/parser.js +357 -0
  22. data/lib/xml2js/node_modules/xml2js/lib/processors.js +34 -0
  23. data/lib/xml2js/node_modules/xml2js/lib/xml2js.js +37 -0
  24. data/lib/xml2js/node_modules/xml2js/package.json +280 -0
  25. data/lib/xml2js/node_modules/xmlbuilder/.npmignore +5 -0
  26. data/lib/xml2js/node_modules/xmlbuilder/CHANGELOG.md +423 -0
  27. data/lib/xml2js/node_modules/xmlbuilder/LICENSE +21 -0
  28. data/lib/xml2js/node_modules/xmlbuilder/README.md +85 -0
  29. data/lib/xml2js/node_modules/xmlbuilder/lib/Utility.js +73 -0
  30. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLAttribute.js +31 -0
  31. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLCData.js +32 -0
  32. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLComment.js +32 -0
  33. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDAttList.js +50 -0
  34. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDElement.js +35 -0
  35. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDEntity.js +56 -0
  36. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDTDNotation.js +37 -0
  37. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDeclaration.js +40 -0
  38. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDocType.js +107 -0
  39. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDocument.js +48 -0
  40. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLDocumentCB.js +402 -0
  41. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLElement.js +111 -0
  42. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLNode.js +432 -0
  43. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js +35 -0
  44. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLRaw.js +32 -0
  45. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLStreamWriter.js +279 -0
  46. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLStringWriter.js +334 -0
  47. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLStringifier.js +163 -0
  48. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLText.js +32 -0
  49. data/lib/xml2js/node_modules/xmlbuilder/lib/XMLWriterBase.js +90 -0
  50. data/lib/xml2js/node_modules/xmlbuilder/lib/index.js +53 -0
  51. data/lib/xml2js/node_modules/xmlbuilder/package.json +65 -0
  52. data/lib/xml2js/package-lock.json +25 -0
  53. data/lib/xml2js/parser.js +33 -0
  54. data/lib/xml2js/parser.rb +31 -0
  55. data/lib/xml2js/version.rb +3 -0
  56. data/xml2js.gemspec +30 -0
  57. metadata +154 -0
@@ -0,0 +1,12 @@
1
+ // Generated by CoffeeScript 1.12.7
2
+ (function() {
3
+ "use strict";
4
+ exports.stripBOM = function(str) {
5
+ if (str[0] === '\uFEFF') {
6
+ return str.substring(1);
7
+ } else {
8
+ return str;
9
+ }
10
+ };
11
+
12
+ }).call(this);
@@ -0,0 +1,127 @@
1
+ // Generated by CoffeeScript 1.12.7
2
+ (function() {
3
+ "use strict";
4
+ var builder, defaults, escapeCDATA, requiresCDATA, wrapCDATA,
5
+ hasProp = {}.hasOwnProperty;
6
+
7
+ builder = require('xmlbuilder');
8
+
9
+ defaults = require('./defaults').defaults;
10
+
11
+ requiresCDATA = function(entry) {
12
+ return typeof entry === "string" && (entry.indexOf('&') >= 0 || entry.indexOf('>') >= 0 || entry.indexOf('<') >= 0);
13
+ };
14
+
15
+ wrapCDATA = function(entry) {
16
+ return "<![CDATA[" + (escapeCDATA(entry)) + "]]>";
17
+ };
18
+
19
+ escapeCDATA = function(entry) {
20
+ return entry.replace(']]>', ']]]]><![CDATA[>');
21
+ };
22
+
23
+ exports.Builder = (function() {
24
+ function Builder(opts) {
25
+ var key, ref, value;
26
+ this.options = {};
27
+ ref = defaults["0.2"];
28
+ for (key in ref) {
29
+ if (!hasProp.call(ref, key)) continue;
30
+ value = ref[key];
31
+ this.options[key] = value;
32
+ }
33
+ for (key in opts) {
34
+ if (!hasProp.call(opts, key)) continue;
35
+ value = opts[key];
36
+ this.options[key] = value;
37
+ }
38
+ }
39
+
40
+ Builder.prototype.buildObject = function(rootObj) {
41
+ var attrkey, charkey, render, rootElement, rootName;
42
+ attrkey = this.options.attrkey;
43
+ charkey = this.options.charkey;
44
+ if ((Object.keys(rootObj).length === 1) && (this.options.rootName === defaults['0.2'].rootName)) {
45
+ rootName = Object.keys(rootObj)[0];
46
+ rootObj = rootObj[rootName];
47
+ } else {
48
+ rootName = this.options.rootName;
49
+ }
50
+ render = (function(_this) {
51
+ return function(element, obj) {
52
+ var attr, child, entry, index, key, value;
53
+ if (typeof obj !== 'object') {
54
+ if (_this.options.cdata && requiresCDATA(obj)) {
55
+ element.raw(wrapCDATA(obj));
56
+ } else {
57
+ element.txt(obj);
58
+ }
59
+ } else if (Array.isArray(obj)) {
60
+ for (index in obj) {
61
+ if (!hasProp.call(obj, index)) continue;
62
+ child = obj[index];
63
+ for (key in child) {
64
+ entry = child[key];
65
+ element = render(element.ele(key), entry).up();
66
+ }
67
+ }
68
+ } else {
69
+ for (key in obj) {
70
+ if (!hasProp.call(obj, key)) continue;
71
+ child = obj[key];
72
+ if (key === attrkey) {
73
+ if (typeof child === "object") {
74
+ for (attr in child) {
75
+ value = child[attr];
76
+ element = element.att(attr, value);
77
+ }
78
+ }
79
+ } else if (key === charkey) {
80
+ if (_this.options.cdata && requiresCDATA(child)) {
81
+ element = element.raw(wrapCDATA(child));
82
+ } else {
83
+ element = element.txt(child);
84
+ }
85
+ } else if (Array.isArray(child)) {
86
+ for (index in child) {
87
+ if (!hasProp.call(child, index)) continue;
88
+ entry = child[index];
89
+ if (typeof entry === 'string') {
90
+ if (_this.options.cdata && requiresCDATA(entry)) {
91
+ element = element.ele(key).raw(wrapCDATA(entry)).up();
92
+ } else {
93
+ element = element.ele(key, entry).up();
94
+ }
95
+ } else {
96
+ element = render(element.ele(key), entry).up();
97
+ }
98
+ }
99
+ } else if (typeof child === "object") {
100
+ element = render(element.ele(key), child).up();
101
+ } else {
102
+ if (typeof child === 'string' && _this.options.cdata && requiresCDATA(child)) {
103
+ element = element.ele(key).raw(wrapCDATA(child)).up();
104
+ } else {
105
+ if (child == null) {
106
+ child = '';
107
+ }
108
+ element = element.ele(key, child.toString()).up();
109
+ }
110
+ }
111
+ }
112
+ }
113
+ return element;
114
+ };
115
+ })(this);
116
+ rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, {
117
+ headless: this.options.headless,
118
+ allowSurrogateChars: this.options.allowSurrogateChars
119
+ });
120
+ return render(rootElement, rootObj).end(this.options.renderOpts);
121
+ };
122
+
123
+ return Builder;
124
+
125
+ })();
126
+
127
+ }).call(this);
@@ -0,0 +1,72 @@
1
+ // Generated by CoffeeScript 1.12.7
2
+ (function() {
3
+ exports.defaults = {
4
+ "0.1": {
5
+ explicitCharkey: false,
6
+ trim: true,
7
+ normalize: true,
8
+ normalizeTags: false,
9
+ attrkey: "@",
10
+ charkey: "#",
11
+ explicitArray: false,
12
+ ignoreAttrs: false,
13
+ mergeAttrs: false,
14
+ explicitRoot: false,
15
+ validator: null,
16
+ xmlns: false,
17
+ explicitChildren: false,
18
+ childkey: '@@',
19
+ charsAsChildren: false,
20
+ includeWhiteChars: false,
21
+ async: false,
22
+ strict: true,
23
+ attrNameProcessors: null,
24
+ attrValueProcessors: null,
25
+ tagNameProcessors: null,
26
+ valueProcessors: null,
27
+ emptyTag: ''
28
+ },
29
+ "0.2": {
30
+ explicitCharkey: false,
31
+ trim: false,
32
+ normalize: false,
33
+ normalizeTags: false,
34
+ attrkey: "$",
35
+ charkey: "_",
36
+ explicitArray: true,
37
+ ignoreAttrs: false,
38
+ mergeAttrs: false,
39
+ explicitRoot: true,
40
+ validator: null,
41
+ xmlns: false,
42
+ explicitChildren: false,
43
+ preserveChildrenOrder: false,
44
+ childkey: '$$',
45
+ charsAsChildren: false,
46
+ includeWhiteChars: false,
47
+ async: false,
48
+ strict: true,
49
+ attrNameProcessors: null,
50
+ attrValueProcessors: null,
51
+ tagNameProcessors: null,
52
+ valueProcessors: null,
53
+ rootName: 'root',
54
+ xmldec: {
55
+ 'version': '1.0',
56
+ 'encoding': 'UTF-8',
57
+ 'standalone': true
58
+ },
59
+ doctype: null,
60
+ renderOpts: {
61
+ 'pretty': true,
62
+ 'indent': ' ',
63
+ 'newline': '\n'
64
+ },
65
+ headless: false,
66
+ chunkSize: 10000,
67
+ emptyTag: '',
68
+ cdata: false
69
+ }
70
+ };
71
+
72
+ }).call(this);
@@ -0,0 +1,357 @@
1
+ // Generated by CoffeeScript 1.12.7
2
+ (function() {
3
+ "use strict";
4
+ var bom, defaults, events, isEmpty, processItem, processors, sax, setImmediate,
5
+ bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
6
+ 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; },
7
+ hasProp = {}.hasOwnProperty;
8
+
9
+ sax = require('sax');
10
+
11
+ events = require('events');
12
+
13
+ bom = require('./bom');
14
+
15
+ processors = require('./processors');
16
+
17
+ setImmediate = require('timers').setImmediate;
18
+
19
+ defaults = require('./defaults').defaults;
20
+
21
+ isEmpty = function(thing) {
22
+ return typeof thing === "object" && (thing != null) && Object.keys(thing).length === 0;
23
+ };
24
+
25
+ processItem = function(processors, item, key) {
26
+ var i, len, process;
27
+ for (i = 0, len = processors.length; i < len; i++) {
28
+ process = processors[i];
29
+ item = process(item, key);
30
+ }
31
+ return item;
32
+ };
33
+
34
+ exports.Parser = (function(superClass) {
35
+ extend(Parser, superClass);
36
+
37
+ function Parser(opts) {
38
+ this.parseString = bind(this.parseString, this);
39
+ this.reset = bind(this.reset, this);
40
+ this.assignOrPush = bind(this.assignOrPush, this);
41
+ this.processAsync = bind(this.processAsync, this);
42
+ var key, ref, value;
43
+ if (!(this instanceof exports.Parser)) {
44
+ return new exports.Parser(opts);
45
+ }
46
+ this.options = {};
47
+ ref = defaults["0.2"];
48
+ for (key in ref) {
49
+ if (!hasProp.call(ref, key)) continue;
50
+ value = ref[key];
51
+ this.options[key] = value;
52
+ }
53
+ for (key in opts) {
54
+ if (!hasProp.call(opts, key)) continue;
55
+ value = opts[key];
56
+ this.options[key] = value;
57
+ }
58
+ if (this.options.xmlns) {
59
+ this.options.xmlnskey = this.options.attrkey + "ns";
60
+ }
61
+ if (this.options.normalizeTags) {
62
+ if (!this.options.tagNameProcessors) {
63
+ this.options.tagNameProcessors = [];
64
+ }
65
+ this.options.tagNameProcessors.unshift(processors.normalize);
66
+ }
67
+ this.reset();
68
+ }
69
+
70
+ Parser.prototype.processAsync = function() {
71
+ var chunk, err;
72
+ try {
73
+ if (this.remaining.length <= this.options.chunkSize) {
74
+ chunk = this.remaining;
75
+ this.remaining = '';
76
+ this.saxParser = this.saxParser.write(chunk);
77
+ return this.saxParser.close();
78
+ } else {
79
+ chunk = this.remaining.substr(0, this.options.chunkSize);
80
+ this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length);
81
+ this.saxParser = this.saxParser.write(chunk);
82
+ return setImmediate(this.processAsync);
83
+ }
84
+ } catch (error1) {
85
+ err = error1;
86
+ if (!this.saxParser.errThrown) {
87
+ this.saxParser.errThrown = true;
88
+ return this.emit(err);
89
+ }
90
+ }
91
+ };
92
+
93
+ Parser.prototype.assignOrPush = function(obj, key, newValue) {
94
+ if (!(key in obj)) {
95
+ if (!this.options.explicitArray) {
96
+ return obj[key] = newValue;
97
+ } else {
98
+ return obj[key] = [newValue];
99
+ }
100
+ } else {
101
+ if (!(obj[key] instanceof Array)) {
102
+ obj[key] = [obj[key]];
103
+ }
104
+ return obj[key].push(newValue);
105
+ }
106
+ };
107
+
108
+ Parser.prototype.reset = function() {
109
+ var attrkey, charkey, ontext, stack;
110
+ this.removeAllListeners();
111
+ this.saxParser = sax.parser(this.options.strict, {
112
+ trim: false,
113
+ normalize: false,
114
+ xmlns: this.options.xmlns
115
+ });
116
+ this.saxParser.errThrown = false;
117
+ this.saxParser.onerror = (function(_this) {
118
+ return function(error) {
119
+ _this.saxParser.resume();
120
+ if (!_this.saxParser.errThrown) {
121
+ _this.saxParser.errThrown = true;
122
+ return _this.emit("error", error);
123
+ }
124
+ };
125
+ })(this);
126
+ this.saxParser.onend = (function(_this) {
127
+ return function() {
128
+ if (!_this.saxParser.ended) {
129
+ _this.saxParser.ended = true;
130
+ return _this.emit("end", _this.resultObject);
131
+ }
132
+ };
133
+ })(this);
134
+ this.saxParser.ended = false;
135
+ this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
136
+ this.resultObject = null;
137
+ stack = [];
138
+ attrkey = this.options.attrkey;
139
+ charkey = this.options.charkey;
140
+ this.saxParser.onopentag = (function(_this) {
141
+ return function(node) {
142
+ var key, newValue, obj, processedKey, ref;
143
+ obj = {};
144
+ obj[charkey] = "";
145
+ if (!_this.options.ignoreAttrs) {
146
+ ref = node.attributes;
147
+ for (key in ref) {
148
+ if (!hasProp.call(ref, key)) continue;
149
+ if (!(attrkey in obj) && !_this.options.mergeAttrs) {
150
+ obj[attrkey] = {};
151
+ }
152
+ newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
153
+ processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
154
+ if (_this.options.mergeAttrs) {
155
+ _this.assignOrPush(obj, processedKey, newValue);
156
+ } else {
157
+ obj[attrkey][processedKey] = newValue;
158
+ }
159
+ }
160
+ }
161
+ obj["#name"] = _this.options.tagNameProcessors ? processItem(_this.options.tagNameProcessors, node.name) : node.name;
162
+ if (_this.options.xmlns) {
163
+ obj[_this.options.xmlnskey] = {
164
+ uri: node.uri,
165
+ local: node.local
166
+ };
167
+ }
168
+ return stack.push(obj);
169
+ };
170
+ })(this);
171
+ this.saxParser.onclosetag = (function(_this) {
172
+ return function() {
173
+ var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath;
174
+ obj = stack.pop();
175
+ nodeName = obj["#name"];
176
+ if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) {
177
+ delete obj["#name"];
178
+ }
179
+ if (obj.cdata === true) {
180
+ cdata = obj.cdata;
181
+ delete obj.cdata;
182
+ }
183
+ s = stack[stack.length - 1];
184
+ if (obj[charkey].match(/^\s*$/) && !cdata) {
185
+ emptyStr = obj[charkey];
186
+ delete obj[charkey];
187
+ } else {
188
+ if (_this.options.trim) {
189
+ obj[charkey] = obj[charkey].trim();
190
+ }
191
+ if (_this.options.normalize) {
192
+ obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
193
+ }
194
+ obj[charkey] = _this.options.valueProcessors ? processItem(_this.options.valueProcessors, obj[charkey], nodeName) : obj[charkey];
195
+ if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
196
+ obj = obj[charkey];
197
+ }
198
+ }
199
+ if (isEmpty(obj)) {
200
+ obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
201
+ }
202
+ if (_this.options.validator != null) {
203
+ xpath = "/" + ((function() {
204
+ var i, len, results;
205
+ results = [];
206
+ for (i = 0, len = stack.length; i < len; i++) {
207
+ node = stack[i];
208
+ results.push(node["#name"]);
209
+ }
210
+ return results;
211
+ })()).concat(nodeName).join("/");
212
+ (function() {
213
+ var err;
214
+ try {
215
+ return obj = _this.options.validator(xpath, s && s[nodeName], obj);
216
+ } catch (error1) {
217
+ err = error1;
218
+ return _this.emit("error", err);
219
+ }
220
+ })();
221
+ }
222
+ if (_this.options.explicitChildren && !_this.options.mergeAttrs && typeof obj === 'object') {
223
+ if (!_this.options.preserveChildrenOrder) {
224
+ node = {};
225
+ if (_this.options.attrkey in obj) {
226
+ node[_this.options.attrkey] = obj[_this.options.attrkey];
227
+ delete obj[_this.options.attrkey];
228
+ }
229
+ if (!_this.options.charsAsChildren && _this.options.charkey in obj) {
230
+ node[_this.options.charkey] = obj[_this.options.charkey];
231
+ delete obj[_this.options.charkey];
232
+ }
233
+ if (Object.getOwnPropertyNames(obj).length > 0) {
234
+ node[_this.options.childkey] = obj;
235
+ }
236
+ obj = node;
237
+ } else if (s) {
238
+ s[_this.options.childkey] = s[_this.options.childkey] || [];
239
+ objClone = {};
240
+ for (key in obj) {
241
+ if (!hasProp.call(obj, key)) continue;
242
+ objClone[key] = obj[key];
243
+ }
244
+ s[_this.options.childkey].push(objClone);
245
+ delete obj["#name"];
246
+ if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
247
+ obj = obj[charkey];
248
+ }
249
+ }
250
+ }
251
+ if (stack.length > 0) {
252
+ return _this.assignOrPush(s, nodeName, obj);
253
+ } else {
254
+ if (_this.options.explicitRoot) {
255
+ old = obj;
256
+ obj = {};
257
+ obj[nodeName] = old;
258
+ }
259
+ _this.resultObject = obj;
260
+ _this.saxParser.ended = true;
261
+ return _this.emit("end", _this.resultObject);
262
+ }
263
+ };
264
+ })(this);
265
+ ontext = (function(_this) {
266
+ return function(text) {
267
+ var charChild, s;
268
+ s = stack[stack.length - 1];
269
+ if (s) {
270
+ s[charkey] += text;
271
+ if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, '').trim() !== '')) {
272
+ s[_this.options.childkey] = s[_this.options.childkey] || [];
273
+ charChild = {
274
+ '#name': '__text__'
275
+ };
276
+ charChild[charkey] = text;
277
+ if (_this.options.normalize) {
278
+ charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim();
279
+ }
280
+ s[_this.options.childkey].push(charChild);
281
+ }
282
+ return s;
283
+ }
284
+ };
285
+ })(this);
286
+ this.saxParser.ontext = ontext;
287
+ return this.saxParser.oncdata = (function(_this) {
288
+ return function(text) {
289
+ var s;
290
+ s = ontext(text);
291
+ if (s) {
292
+ return s.cdata = true;
293
+ }
294
+ };
295
+ })(this);
296
+ };
297
+
298
+ Parser.prototype.parseString = function(str, cb) {
299
+ var err;
300
+ if ((cb != null) && typeof cb === "function") {
301
+ this.on("end", function(result) {
302
+ this.reset();
303
+ return cb(null, result);
304
+ });
305
+ this.on("error", function(err) {
306
+ this.reset();
307
+ return cb(err);
308
+ });
309
+ }
310
+ try {
311
+ str = str.toString();
312
+ if (str.trim() === '') {
313
+ this.emit("end", null);
314
+ return true;
315
+ }
316
+ str = bom.stripBOM(str);
317
+ if (this.options.async) {
318
+ this.remaining = str;
319
+ setImmediate(this.processAsync);
320
+ return this.saxParser;
321
+ }
322
+ return this.saxParser.write(str).close();
323
+ } catch (error1) {
324
+ err = error1;
325
+ if (!(this.saxParser.errThrown || this.saxParser.ended)) {
326
+ this.emit('error', err);
327
+ return this.saxParser.errThrown = true;
328
+ } else if (this.saxParser.ended) {
329
+ throw err;
330
+ }
331
+ }
332
+ };
333
+
334
+ return Parser;
335
+
336
+ })(events.EventEmitter);
337
+
338
+ exports.parseString = function(str, a, b) {
339
+ var cb, options, parser;
340
+ if (b != null) {
341
+ if (typeof b === 'function') {
342
+ cb = b;
343
+ }
344
+ if (typeof a === 'object') {
345
+ options = a;
346
+ }
347
+ } else {
348
+ if (typeof a === 'function') {
349
+ cb = a;
350
+ }
351
+ options = {};
352
+ }
353
+ parser = new exports.Parser(options);
354
+ return parser.parseString(str, cb);
355
+ };
356
+
357
+ }).call(this);