박지환

Update send JSON/XML data

Showing 58 changed files with 6318 additions and 4 deletions
...@@ -984,6 +984,26 @@ ...@@ -984,6 +984,26 @@
984 "bin": { 984 "bin": {
985 "xml-js": "bin/cli.js" 985 "xml-js": "bin/cli.js"
986 } 986 }
987 + },
988 + "node_modules/xml2js": {
989 + "version": "0.4.23",
990 + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
991 + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
992 + "dependencies": {
993 + "sax": ">=0.6.0",
994 + "xmlbuilder": "~11.0.0"
995 + },
996 + "engines": {
997 + "node": ">=4.0.0"
998 + }
999 + },
1000 + "node_modules/xmlbuilder": {
1001 + "version": "11.0.1",
1002 + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
1003 + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
1004 + "engines": {
1005 + "node": ">=4.0"
1006 + }
987 } 1007 }
988 } 1008 }
989 } 1009 }
......
1 +Copyright 2010, 2011, 2012, 2013. All rights reserved.
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining a copy
4 +of this software and associated documentation files (the "Software"), to
5 +deal in the Software without restriction, including without limitation the
6 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 +sell copies of the Software, and to permit persons to whom the Software is
8 +furnished to do so, subject to the following conditions:
9 +
10 +The above copyright notice and this permission notice shall be included in
11 +all copies or substantial portions of the Software.
12 +
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 +IN THE SOFTWARE.
1 +node-xml2js
2 +===========
3 +
4 +Ever had the urge to parse XML? And wanted to access the data in some sane,
5 +easy way? Don't want to compile a C parser, for whatever reason? Then xml2js is
6 +what you're looking for!
7 +
8 +Description
9 +===========
10 +
11 +Simple XML to JavaScript object converter. It supports bi-directional conversion.
12 +Uses [sax-js](https://github.com/isaacs/sax-js/) and
13 +[xmlbuilder-js](https://github.com/oozcitak/xmlbuilder-js/).
14 +
15 +Note: If you're looking for a full DOM parser, you probably want
16 +[JSDom](https://github.com/tmpvar/jsdom).
17 +
18 +Installation
19 +============
20 +
21 +Simplest way to install `xml2js` is to use [npm](http://npmjs.org), just `npm
22 +install xml2js` which will download xml2js and all dependencies.
23 +
24 +xml2js is also available via [Bower](http://bower.io/), just `bower install
25 +xml2js` which will download xml2js and all dependencies.
26 +
27 +Usage
28 +=====
29 +
30 +No extensive tutorials required because you are a smart developer! The task of
31 +parsing XML should be an easy one, so let's make it so! Here's some examples.
32 +
33 +Shoot-and-forget usage
34 +----------------------
35 +
36 +You want to parse XML as simple and easy as possible? It's dangerous to go
37 +alone, take this:
38 +
39 +```javascript
40 +var parseString = require('xml2js').parseString;
41 +var xml = "<root>Hello xml2js!</root>"
42 +parseString(xml, function (err, result) {
43 + console.dir(result);
44 +});
45 +```
46 +
47 +Can't get easier than this, right? This works starting with `xml2js` 0.2.3.
48 +With CoffeeScript it looks like this:
49 +
50 +```coffeescript
51 +{parseString} = require 'xml2js'
52 +xml = "<root>Hello xml2js!</root>"
53 +parseString xml, (err, result) ->
54 + console.dir result
55 +```
56 +
57 +If you need some special options, fear not, `xml2js` supports a number of
58 +options (see below), you can specify these as second argument:
59 +
60 +```javascript
61 +parseString(xml, {trim: true}, function (err, result) {
62 +});
63 +```
64 +
65 +Simple as pie usage
66 +-------------------
67 +
68 +That's right, if you have been using xml-simple or a home-grown
69 +wrapper, this was added in 0.1.11 just for you:
70 +
71 +```javascript
72 +var fs = require('fs'),
73 + xml2js = require('xml2js');
74 +
75 +var parser = new xml2js.Parser();
76 +fs.readFile(__dirname + '/foo.xml', function(err, data) {
77 + parser.parseString(data, function (err, result) {
78 + console.dir(result);
79 + console.log('Done');
80 + });
81 +});
82 +```
83 +
84 +Look ma, no event listeners!
85 +
86 +You can also use `xml2js` from
87 +[CoffeeScript](https://github.com/jashkenas/coffeescript), further reducing
88 +the clutter:
89 +
90 +```coffeescript
91 +fs = require 'fs',
92 +xml2js = require 'xml2js'
93 +
94 +parser = new xml2js.Parser()
95 +fs.readFile __dirname + '/foo.xml', (err, data) ->
96 + parser.parseString data, (err, result) ->
97 + console.dir result
98 + console.log 'Done.'
99 +```
100 +
101 +But what happens if you forget the `new` keyword to create a new `Parser`? In
102 +the middle of a nightly coding session, it might get lost, after all. Worry
103 +not, we got you covered! Starting with 0.2.8 you can also leave it out, in
104 +which case `xml2js` will helpfully add it for you, no bad surprises and
105 +inexplicable bugs!
106 +
107 +Promise usage
108 +-------------
109 +
110 +```javascript
111 +var xml2js = require('xml2js');
112 +var xml = '<foo></foo>';
113 +
114 +// With parser
115 +var parser = new xml2js.Parser(/* options */);
116 +parser.parseStringPromise(data).then(function (result) {
117 + console.dir(result);
118 + console.log('Done');
119 +})
120 +.catch(function (err) {
121 + // Failed
122 +});
123 +
124 +// Without parser
125 +xml2js.parseStringPromise(data /*, options */).then(function (result) {
126 + console.dir(result);
127 + console.log('Done');
128 +})
129 +.catch(function (err) {
130 + // Failed
131 +});
132 +```
133 +
134 +Parsing multiple files
135 +----------------------
136 +
137 +If you want to parse multiple files, you have multiple possibilities:
138 +
139 + * You can create one `xml2js.Parser` per file. That's the recommended one
140 + and is promised to always *just work*.
141 + * You can call `reset()` on your parser object.
142 + * You can hope everything goes well anyway. This behaviour is not
143 + guaranteed work always, if ever. Use option #1 if possible. Thanks!
144 +
145 +So you wanna some JSON?
146 +-----------------------
147 +
148 +Just wrap the `result` object in a call to `JSON.stringify` like this
149 +`JSON.stringify(result)`. You get a string containing the JSON representation
150 +of the parsed object that you can feed to JSON-hungry consumers.
151 +
152 +Displaying results
153 +------------------
154 +
155 +You might wonder why, using `console.dir` or `console.log` the output at some
156 +level is only `[Object]`. Don't worry, this is not because `xml2js` got lazy.
157 +That's because Node uses `util.inspect` to convert the object into strings and
158 +that function stops after `depth=2` which is a bit low for most XML.
159 +
160 +To display the whole deal, you can use `console.log(util.inspect(result, false,
161 +null))`, which displays the whole result.
162 +
163 +So much for that, but what if you use
164 +[eyes](https://github.com/cloudhead/eyes.js) for nice colored output and it
165 +truncates the output with `…`? Don't fear, there's also a solution for that,
166 +you just need to increase the `maxLength` limit by creating a custom inspector
167 +`var inspect = require('eyes').inspector({maxLength: false})` and then you can
168 +easily `inspect(result)`.
169 +
170 +XML builder usage
171 +-----------------
172 +
173 +Since 0.4.0, objects can be also be used to build XML:
174 +
175 +```javascript
176 +var xml2js = require('xml2js');
177 +
178 +var obj = {name: "Super", Surname: "Man", age: 23};
179 +
180 +var builder = new xml2js.Builder();
181 +var xml = builder.buildObject(obj);
182 +```
183 +
184 +At the moment, a one to one bi-directional conversion is guaranteed only for
185 +default configuration, except for `attrkey`, `charkey` and `explicitArray` options
186 +you can redefine to your taste. Writing CDATA is supported via setting the `cdata`
187 +option to `true`.
188 +
189 +To specify attributes:
190 +```javascript
191 +var xml2js = require('xml2js');
192 +
193 +var obj = {root: {$: {id: "my id"}, _: "my inner text"}};
194 +
195 +var builder = new xml2js.Builder();
196 +var xml = builder.buildObject(obj);
197 +```
198 +
199 +### Adding xmlns attributes
200 +
201 +You can generate XML that declares XML namespace prefix / URI pairs with xmlns attributes.
202 +
203 +Example declaring a default namespace on the root element:
204 +
205 +```javascript
206 +let obj = {
207 + Foo: {
208 + $: {
209 + "xmlns": "http://foo.com"
210 + }
211 + }
212 +};
213 +```
214 +Result of `buildObject(obj)`:
215 +```xml
216 +<Foo xmlns="http://foo.com"/>
217 +```
218 +Example declaring non-default namespaces on non-root elements:
219 +```javascript
220 +let obj = {
221 + 'foo:Foo': {
222 + $: {
223 + 'xmlns:foo': 'http://foo.com'
224 + },
225 + 'bar:Bar': {
226 + $: {
227 + 'xmlns:bar': 'http://bar.com'
228 + }
229 + }
230 + }
231 +}
232 +```
233 +Result of `buildObject(obj)`:
234 +```xml
235 +<foo:Foo xmlns:foo="http://foo.com">
236 + <bar:Bar xmlns:bar="http://bar.com"/>
237 +</foo:Foo>
238 +```
239 +
240 +
241 +Processing attribute, tag names and values
242 +------------------------------------------
243 +
244 +Since 0.4.1 you can optionally provide the parser with attribute name and tag name processors as well as element value processors (Since 0.4.14, you can also optionally provide the parser with attribute value processors):
245 +
246 +```javascript
247 +
248 +function nameToUpperCase(name){
249 + return name.toUpperCase();
250 +}
251 +
252 +//transform all attribute and tag names and values to uppercase
253 +parseString(xml, {
254 + tagNameProcessors: [nameToUpperCase],
255 + attrNameProcessors: [nameToUpperCase],
256 + valueProcessors: [nameToUpperCase],
257 + attrValueProcessors: [nameToUpperCase]},
258 + function (err, result) {
259 + // processed data
260 +});
261 +```
262 +
263 +The `tagNameProcessors` and `attrNameProcessors` options
264 +accept an `Array` of functions with the following signature:
265 +
266 +```javascript
267 +function (name){
268 + //do something with `name`
269 + return name
270 +}
271 +```
272 +
273 +The `attrValueProcessors` and `valueProcessors` options
274 +accept an `Array` of functions with the following signature:
275 +
276 +```javascript
277 +function (value, name) {
278 + //`name` will be the node name or attribute name
279 + //do something with `value`, (optionally) dependent on the node/attr name
280 + return value
281 +}
282 +```
283 +
284 +Some processors are provided out-of-the-box and can be found in `lib/processors.js`:
285 +
286 +- `normalize`: transforms the name to lowercase.
287 +(Automatically used when `options.normalize` is set to `true`)
288 +
289 +- `firstCharLowerCase`: transforms the first character to lower case.
290 +E.g. 'MyTagName' becomes 'myTagName'
291 +
292 +- `stripPrefix`: strips the xml namespace prefix. E.g `<foo:Bar/>` will become 'Bar'.
293 +(N.B.: the `xmlns` prefix is NOT stripped.)
294 +
295 +- `parseNumbers`: parses integer-like strings as integers and float-like strings as floats
296 +E.g. "0" becomes 0 and "15.56" becomes 15.56
297 +
298 +- `parseBooleans`: parses boolean-like strings to booleans
299 +E.g. "true" becomes true and "False" becomes false
300 +
301 +Options
302 +=======
303 +
304 +Apart from the default settings, there are a number of options that can be
305 +specified for the parser. Options are specified by ``new Parser({optionName:
306 +value})``. Possible options are:
307 +
308 + * `attrkey` (default: `$`): Prefix that is used to access the attributes.
309 + Version 0.1 default was `@`.
310 + * `charkey` (default: `_`): Prefix that is used to access the character
311 + content. Version 0.1 default was `#`.
312 + * `explicitCharkey` (default: `false`)
313 + * `trim` (default: `false`): Trim the whitespace at the beginning and end of
314 + text nodes.
315 + * `normalizeTags` (default: `false`): Normalize all tag names to lowercase.
316 + * `normalize` (default: `false`): Trim whitespaces inside text nodes.
317 + * `explicitRoot` (default: `true`): Set this if you want to get the root
318 + node in the resulting object.
319 + * `emptyTag` (default: `''`): what will the value of empty nodes be.
320 + * `explicitArray` (default: `true`): Always put child nodes in an array if
321 + true; otherwise an array is created only if there is more than one.
322 + * `ignoreAttrs` (default: `false`): Ignore all XML attributes and only create
323 + text nodes.
324 + * `mergeAttrs` (default: `false`): Merge attributes and child elements as
325 + properties of the parent, instead of keying attributes off a child
326 + attribute object. This option is ignored if `ignoreAttrs` is `true`.
327 + * `validator` (default `null`): You can specify a callable that validates
328 + the resulting structure somehow, however you want. See unit tests
329 + for an example.
330 + * `xmlns` (default `false`): Give each element a field usually called '$ns'
331 + (the first character is the same as attrkey) that contains its local name
332 + and namespace URI.
333 + * `explicitChildren` (default `false`): Put child elements to separate
334 + property. Doesn't work with `mergeAttrs = true`. If element has no children
335 + then "children" won't be created. Added in 0.2.5.
336 + * `childkey` (default `$$`): Prefix that is used to access child elements if
337 + `explicitChildren` is set to `true`. Added in 0.2.5.
338 + * `preserveChildrenOrder` (default `false`): Modifies the behavior of
339 + `explicitChildren` so that the value of the "children" property becomes an
340 + ordered array. When this is `true`, every node will also get a `#name` field
341 + whose value will correspond to the XML nodeName, so that you may iterate
342 + the "children" array and still be able to determine node names. The named
343 + (and potentially unordered) properties are also retained in this
344 + configuration at the same level as the ordered "children" array. Added in
345 + 0.4.9.
346 + * `charsAsChildren` (default `false`): Determines whether chars should be
347 + considered children if `explicitChildren` is on. Added in 0.2.5.
348 + * `includeWhiteChars` (default `false`): Determines whether whitespace-only
349 + text nodes should be included. Added in 0.4.17.
350 + * `async` (default `false`): Should the callbacks be async? This *might* be
351 + an incompatible change if your code depends on sync execution of callbacks.
352 + Future versions of `xml2js` might change this default, so the recommendation
353 + is to not depend on sync execution anyway. Added in 0.2.6.
354 + * `strict` (default `true`): Set sax-js to strict or non-strict parsing mode.
355 + Defaults to `true` which is *highly* recommended, since parsing HTML which
356 + is not well-formed XML might yield just about anything. Added in 0.2.7.
357 + * `attrNameProcessors` (default: `null`): Allows the addition of attribute
358 + name processing functions. Accepts an `Array` of functions with following
359 + signature:
360 + ```javascript
361 + function (name){
362 + //do something with `name`
363 + return name
364 + }
365 + ```
366 + Added in 0.4.14
367 + * `attrValueProcessors` (default: `null`): Allows the addition of attribute
368 + value processing functions. Accepts an `Array` of functions with following
369 + signature:
370 + ```javascript
371 + function (value, name){
372 + //do something with `name`
373 + return name
374 + }
375 + ```
376 + Added in 0.4.1
377 + * `tagNameProcessors` (default: `null`): Allows the addition of tag name
378 + processing functions. Accepts an `Array` of functions with following
379 + signature:
380 + ```javascript
381 + function (name){
382 + //do something with `name`
383 + return name
384 + }
385 + ```
386 + Added in 0.4.1
387 + * `valueProcessors` (default: `null`): Allows the addition of element value
388 + processing functions. Accepts an `Array` of functions with following
389 + signature:
390 + ```javascript
391 + function (value, name){
392 + //do something with `name`
393 + return name
394 + }
395 + ```
396 + Added in 0.4.6
397 +
398 +Options for the `Builder` class
399 +-------------------------------
400 +These options are specified by ``new Builder({optionName: value})``.
401 +Possible options are:
402 +
403 + * `attrkey` (default: `$`): Prefix that is used to access the attributes.
404 + Version 0.1 default was `@`.
405 + * `charkey` (default: `_`): Prefix that is used to access the character
406 + content. Version 0.1 default was `#`.
407 + * `rootName` (default `root` or the root key name): root element name to be used in case
408 + `explicitRoot` is `false` or to override the root element name.
409 + * `renderOpts` (default `{ 'pretty': true, 'indent': ' ', 'newline': '\n' }`):
410 + Rendering options for xmlbuilder-js.
411 + * pretty: prettify generated XML
412 + * indent: whitespace for indentation (only when pretty)
413 + * newline: newline char (only when pretty)
414 + * `xmldec` (default `{ 'version': '1.0', 'encoding': 'UTF-8', 'standalone': true }`:
415 + XML declaration attributes.
416 + * `xmldec.version` A version number string, e.g. 1.0
417 + * `xmldec.encoding` Encoding declaration, e.g. UTF-8
418 + * `xmldec.standalone` standalone document declaration: true or false
419 + * `doctype` (default `null`): optional DTD. Eg. `{'ext': 'hello.dtd'}`
420 + * `headless` (default: `false`): omit the XML header. Added in 0.4.3.
421 + * `allowSurrogateChars` (default: `false`): allows using characters from the Unicode
422 + surrogate blocks.
423 + * `cdata` (default: `false`): wrap text nodes in `<![CDATA[ ... ]]>` instead of
424 + escaping when necessary. Does not add `<![CDATA[ ... ]]>` if it is not required.
425 + Added in 0.4.5.
426 +
427 +`renderOpts`, `xmldec`,`doctype` and `headless` pass through to
428 +[xmlbuilder-js](https://github.com/oozcitak/xmlbuilder-js).
429 +
430 +Updating to new version
431 +=======================
432 +
433 +Version 0.2 changed the default parsing settings, but version 0.1.14 introduced
434 +the default settings for version 0.2, so these settings can be tried before the
435 +migration.
436 +
437 +```javascript
438 +var xml2js = require('xml2js');
439 +var parser = new xml2js.Parser(xml2js.defaults["0.2"]);
440 +```
441 +
442 +To get the 0.1 defaults in version 0.2 you can just use
443 +`xml2js.defaults["0.1"]` in the same place. This provides you with enough time
444 +to migrate to the saner way of parsing in `xml2js` 0.2. We try to make the
445 +migration as simple and gentle as possible, but some breakage cannot be
446 +avoided.
447 +
448 +So, what exactly did change and why? In 0.2 we changed some defaults to parse
449 +the XML in a more universal and sane way. So we disabled `normalize` and `trim`
450 +so `xml2js` does not cut out any text content. You can reenable this at will of
451 +course. A more important change is that we return the root tag in the resulting
452 +JavaScript structure via the `explicitRoot` setting, so you need to access the
453 +first element. This is useful for anybody who wants to know what the root node
454 +is and preserves more information. The last major change was to enable
455 +`explicitArray`, so everytime it is possible that one might embed more than one
456 +sub-tag into a tag, xml2js >= 0.2 returns an array even if the array just
457 +includes one element. This is useful when dealing with APIs that return
458 +variable amounts of subtags.
459 +
460 +Running tests, development
461 +==========================
462 +
463 +[![Build Status](https://travis-ci.org/Leonidas-from-XIV/node-xml2js.svg?branch=master)](https://travis-ci.org/Leonidas-from-XIV/node-xml2js)
464 +[![Coverage Status](https://coveralls.io/repos/Leonidas-from-XIV/node-xml2js/badge.svg?branch=)](https://coveralls.io/r/Leonidas-from-XIV/node-xml2js?branch=master)
465 +[![Dependency Status](https://david-dm.org/Leonidas-from-XIV/node-xml2js.svg)](https://david-dm.org/Leonidas-from-XIV/node-xml2js)
466 +
467 +The development requirements are handled by npm, you just need to install them.
468 +We also have a number of unit tests, they can be run using `npm test` directly
469 +from the project root. This runs zap to discover all the tests and execute
470 +them.
471 +
472 +If you like to contribute, keep in mind that `xml2js` is written in
473 +CoffeeScript, so don't develop on the JavaScript files that are checked into
474 +the repository for convenience reasons. Also, please write some unit test to
475 +check your behaviour and if it is some user-facing thing, add some
476 +documentation to this README, so people will know it exists. Thanks in advance!
477 +
478 +Getting support
479 +===============
480 +
481 +Please, if you have a problem with the library, first make sure you read this
482 +README. If you read this far, thanks, you're good. Then, please make sure your
483 +problem really is with `xml2js`. It is? Okay, then I'll look at it. Send me a
484 +mail and we can talk. Please don't open issues, as I don't think that is the
485 +proper forum for support problems. Some problems might as well really be bugs
486 +in `xml2js`, if so I'll let you know to open an issue instead :)
487 +
488 +But if you know you really found a bug, feel free to open an issue instead.
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);
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);
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);
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.parseStringPromise = bind(this.parseStringPromise, this);
39 + this.parseString = bind(this.parseString, this);
40 + this.reset = bind(this.reset, this);
41 + this.assignOrPush = bind(this.assignOrPush, this);
42 + this.processAsync = bind(this.processAsync, this);
43 + var key, ref, value;
44 + if (!(this instanceof exports.Parser)) {
45 + return new exports.Parser(opts);
46 + }
47 + this.options = {};
48 + ref = defaults["0.2"];
49 + for (key in ref) {
50 + if (!hasProp.call(ref, key)) continue;
51 + value = ref[key];
52 + this.options[key] = value;
53 + }
54 + for (key in opts) {
55 + if (!hasProp.call(opts, key)) continue;
56 + value = opts[key];
57 + this.options[key] = value;
58 + }
59 + if (this.options.xmlns) {
60 + this.options.xmlnskey = this.options.attrkey + "ns";
61 + }
62 + if (this.options.normalizeTags) {
63 + if (!this.options.tagNameProcessors) {
64 + this.options.tagNameProcessors = [];
65 + }
66 + this.options.tagNameProcessors.unshift(processors.normalize);
67 + }
68 + this.reset();
69 + }
70 +
71 + Parser.prototype.processAsync = function() {
72 + var chunk, err;
73 + try {
74 + if (this.remaining.length <= this.options.chunkSize) {
75 + chunk = this.remaining;
76 + this.remaining = '';
77 + this.saxParser = this.saxParser.write(chunk);
78 + return this.saxParser.close();
79 + } else {
80 + chunk = this.remaining.substr(0, this.options.chunkSize);
81 + this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length);
82 + this.saxParser = this.saxParser.write(chunk);
83 + return setImmediate(this.processAsync);
84 + }
85 + } catch (error1) {
86 + err = error1;
87 + if (!this.saxParser.errThrown) {
88 + this.saxParser.errThrown = true;
89 + return this.emit(err);
90 + }
91 + }
92 + };
93 +
94 + Parser.prototype.assignOrPush = function(obj, key, newValue) {
95 + if (!(key in obj)) {
96 + if (!this.options.explicitArray) {
97 + return obj[key] = newValue;
98 + } else {
99 + return obj[key] = [newValue];
100 + }
101 + } else {
102 + if (!(obj[key] instanceof Array)) {
103 + obj[key] = [obj[key]];
104 + }
105 + return obj[key].push(newValue);
106 + }
107 + };
108 +
109 + Parser.prototype.reset = function() {
110 + var attrkey, charkey, ontext, stack;
111 + this.removeAllListeners();
112 + this.saxParser = sax.parser(this.options.strict, {
113 + trim: false,
114 + normalize: false,
115 + xmlns: this.options.xmlns
116 + });
117 + this.saxParser.errThrown = false;
118 + this.saxParser.onerror = (function(_this) {
119 + return function(error) {
120 + _this.saxParser.resume();
121 + if (!_this.saxParser.errThrown) {
122 + _this.saxParser.errThrown = true;
123 + return _this.emit("error", error);
124 + }
125 + };
126 + })(this);
127 + this.saxParser.onend = (function(_this) {
128 + return function() {
129 + if (!_this.saxParser.ended) {
130 + _this.saxParser.ended = true;
131 + return _this.emit("end", _this.resultObject);
132 + }
133 + };
134 + })(this);
135 + this.saxParser.ended = false;
136 + this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
137 + this.resultObject = null;
138 + stack = [];
139 + attrkey = this.options.attrkey;
140 + charkey = this.options.charkey;
141 + this.saxParser.onopentag = (function(_this) {
142 + return function(node) {
143 + var key, newValue, obj, processedKey, ref;
144 + obj = {};
145 + obj[charkey] = "";
146 + if (!_this.options.ignoreAttrs) {
147 + ref = node.attributes;
148 + for (key in ref) {
149 + if (!hasProp.call(ref, key)) continue;
150 + if (!(attrkey in obj) && !_this.options.mergeAttrs) {
151 + obj[attrkey] = {};
152 + }
153 + newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
154 + processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
155 + if (_this.options.mergeAttrs) {
156 + _this.assignOrPush(obj, processedKey, newValue);
157 + } else {
158 + obj[attrkey][processedKey] = newValue;
159 + }
160 + }
161 + }
162 + obj["#name"] = _this.options.tagNameProcessors ? processItem(_this.options.tagNameProcessors, node.name) : node.name;
163 + if (_this.options.xmlns) {
164 + obj[_this.options.xmlnskey] = {
165 + uri: node.uri,
166 + local: node.local
167 + };
168 + }
169 + return stack.push(obj);
170 + };
171 + })(this);
172 + this.saxParser.onclosetag = (function(_this) {
173 + return function() {
174 + var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath;
175 + obj = stack.pop();
176 + nodeName = obj["#name"];
177 + if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) {
178 + delete obj["#name"];
179 + }
180 + if (obj.cdata === true) {
181 + cdata = obj.cdata;
182 + delete obj.cdata;
183 + }
184 + s = stack[stack.length - 1];
185 + if (obj[charkey].match(/^\s*$/) && !cdata) {
186 + emptyStr = obj[charkey];
187 + delete obj[charkey];
188 + } else {
189 + if (_this.options.trim) {
190 + obj[charkey] = obj[charkey].trim();
191 + }
192 + if (_this.options.normalize) {
193 + obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
194 + }
195 + obj[charkey] = _this.options.valueProcessors ? processItem(_this.options.valueProcessors, obj[charkey], nodeName) : obj[charkey];
196 + if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
197 + obj = obj[charkey];
198 + }
199 + }
200 + if (isEmpty(obj)) {
201 + obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
202 + }
203 + if (_this.options.validator != null) {
204 + xpath = "/" + ((function() {
205 + var i, len, results;
206 + results = [];
207 + for (i = 0, len = stack.length; i < len; i++) {
208 + node = stack[i];
209 + results.push(node["#name"]);
210 + }
211 + return results;
212 + })()).concat(nodeName).join("/");
213 + (function() {
214 + var err;
215 + try {
216 + return obj = _this.options.validator(xpath, s && s[nodeName], obj);
217 + } catch (error1) {
218 + err = error1;
219 + return _this.emit("error", err);
220 + }
221 + })();
222 + }
223 + if (_this.options.explicitChildren && !_this.options.mergeAttrs && typeof obj === 'object') {
224 + if (!_this.options.preserveChildrenOrder) {
225 + node = {};
226 + if (_this.options.attrkey in obj) {
227 + node[_this.options.attrkey] = obj[_this.options.attrkey];
228 + delete obj[_this.options.attrkey];
229 + }
230 + if (!_this.options.charsAsChildren && _this.options.charkey in obj) {
231 + node[_this.options.charkey] = obj[_this.options.charkey];
232 + delete obj[_this.options.charkey];
233 + }
234 + if (Object.getOwnPropertyNames(obj).length > 0) {
235 + node[_this.options.childkey] = obj;
236 + }
237 + obj = node;
238 + } else if (s) {
239 + s[_this.options.childkey] = s[_this.options.childkey] || [];
240 + objClone = {};
241 + for (key in obj) {
242 + if (!hasProp.call(obj, key)) continue;
243 + objClone[key] = obj[key];
244 + }
245 + s[_this.options.childkey].push(objClone);
246 + delete obj["#name"];
247 + if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
248 + obj = obj[charkey];
249 + }
250 + }
251 + }
252 + if (stack.length > 0) {
253 + return _this.assignOrPush(s, nodeName, obj);
254 + } else {
255 + if (_this.options.explicitRoot) {
256 + old = obj;
257 + obj = {};
258 + obj[nodeName] = old;
259 + }
260 + _this.resultObject = obj;
261 + _this.saxParser.ended = true;
262 + return _this.emit("end", _this.resultObject);
263 + }
264 + };
265 + })(this);
266 + ontext = (function(_this) {
267 + return function(text) {
268 + var charChild, s;
269 + s = stack[stack.length - 1];
270 + if (s) {
271 + s[charkey] += text;
272 + if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, '').trim() !== '')) {
273 + s[_this.options.childkey] = s[_this.options.childkey] || [];
274 + charChild = {
275 + '#name': '__text__'
276 + };
277 + charChild[charkey] = text;
278 + if (_this.options.normalize) {
279 + charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim();
280 + }
281 + s[_this.options.childkey].push(charChild);
282 + }
283 + return s;
284 + }
285 + };
286 + })(this);
287 + this.saxParser.ontext = ontext;
288 + return this.saxParser.oncdata = (function(_this) {
289 + return function(text) {
290 + var s;
291 + s = ontext(text);
292 + if (s) {
293 + return s.cdata = true;
294 + }
295 + };
296 + })(this);
297 + };
298 +
299 + Parser.prototype.parseString = function(str, cb) {
300 + var err;
301 + if ((cb != null) && typeof cb === "function") {
302 + this.on("end", function(result) {
303 + this.reset();
304 + return cb(null, result);
305 + });
306 + this.on("error", function(err) {
307 + this.reset();
308 + return cb(err);
309 + });
310 + }
311 + try {
312 + str = str.toString();
313 + if (str.trim() === '') {
314 + this.emit("end", null);
315 + return true;
316 + }
317 + str = bom.stripBOM(str);
318 + if (this.options.async) {
319 + this.remaining = str;
320 + setImmediate(this.processAsync);
321 + return this.saxParser;
322 + }
323 + return this.saxParser.write(str).close();
324 + } catch (error1) {
325 + err = error1;
326 + if (!(this.saxParser.errThrown || this.saxParser.ended)) {
327 + this.emit('error', err);
328 + return this.saxParser.errThrown = true;
329 + } else if (this.saxParser.ended) {
330 + throw err;
331 + }
332 + }
333 + };
334 +
335 + Parser.prototype.parseStringPromise = function(str) {
336 + return new Promise((function(_this) {
337 + return function(resolve, reject) {
338 + return _this.parseString(str, function(err, value) {
339 + if (err) {
340 + return reject(err);
341 + } else {
342 + return resolve(value);
343 + }
344 + });
345 + };
346 + })(this));
347 + };
348 +
349 + return Parser;
350 +
351 + })(events);
352 +
353 + exports.parseString = function(str, a, b) {
354 + var cb, options, parser;
355 + if (b != null) {
356 + if (typeof b === 'function') {
357 + cb = b;
358 + }
359 + if (typeof a === 'object') {
360 + options = a;
361 + }
362 + } else {
363 + if (typeof a === 'function') {
364 + cb = a;
365 + }
366 + options = {};
367 + }
368 + parser = new exports.Parser(options);
369 + return parser.parseString(str, cb);
370 + };
371 +
372 + exports.parseStringPromise = function(str, a) {
373 + var options, parser;
374 + if (typeof a === 'object') {
375 + options = a;
376 + }
377 + parser = new exports.Parser(options);
378 + return parser.parseStringPromise(str);
379 + };
380 +
381 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + "use strict";
4 + var prefixMatch;
5 +
6 + prefixMatch = new RegExp(/(?!xmlns)^.*:/);
7 +
8 + exports.normalize = function(str) {
9 + return str.toLowerCase();
10 + };
11 +
12 + exports.firstCharLowerCase = function(str) {
13 + return str.charAt(0).toLowerCase() + str.slice(1);
14 + };
15 +
16 + exports.stripPrefix = function(str) {
17 + return str.replace(prefixMatch, '');
18 + };
19 +
20 + exports.parseNumbers = function(str) {
21 + if (!isNaN(str)) {
22 + str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
23 + }
24 + return str;
25 + };
26 +
27 + exports.parseBooleans = function(str) {
28 + if (/^(?:true|false)$/i.test(str)) {
29 + str = str.toLowerCase() === 'true';
30 + }
31 + return str;
32 + };
33 +
34 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + "use strict";
4 + var builder, defaults, parser, processors,
5 + 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; },
6 + hasProp = {}.hasOwnProperty;
7 +
8 + defaults = require('./defaults');
9 +
10 + builder = require('./builder');
11 +
12 + parser = require('./parser');
13 +
14 + processors = require('./processors');
15 +
16 + exports.defaults = defaults.defaults;
17 +
18 + exports.processors = processors;
19 +
20 + exports.ValidationError = (function(superClass) {
21 + extend(ValidationError, superClass);
22 +
23 + function ValidationError(message) {
24 + this.message = message;
25 + }
26 +
27 + return ValidationError;
28 +
29 + })(Error);
30 +
31 + exports.Builder = builder.Builder;
32 +
33 + exports.Parser = parser.Parser;
34 +
35 + exports.parseString = parser.parseString;
36 +
37 + exports.parseStringPromise = parser.parseStringPromise;
38 +
39 +}).call(this);
1 +{
2 + "name": "xml2js",
3 + "description": "Simple XML to JavaScript object converter.",
4 + "keywords": [
5 + "xml",
6 + "json"
7 + ],
8 + "homepage": "https://github.com/Leonidas-from-XIV/node-xml2js",
9 + "version": "0.4.23",
10 + "author": "Marek Kubica <marek@xivilization.net> (https://xivilization.net)",
11 + "contributors": [
12 + "maqr <maqr.lollerskates@gmail.com> (https://github.com/maqr)",
13 + "Ben Weaver (http://benweaver.com/)",
14 + "Jae Kwon (https://github.com/jaekwon)",
15 + "Jim Robert",
16 + "Ștefan Rusu (http://www.saltwaterc.eu/)",
17 + "Carter Cole <carter.cole@cartercole.com> (http://cartercole.com/)",
18 + "Kurt Raschke <kurt@kurtraschke.com> (http://www.kurtraschke.com/)",
19 + "Contra <contra@australia.edu> (https://github.com/Contra)",
20 + "Marcelo Diniz <marudiniz@gmail.com> (https://github.com/mdiniz)",
21 + "Michael Hart (https://github.com/mhart)",
22 + "Zachary Scott <zachary@zacharyscott.net> (http://zacharyscott.net/)",
23 + "Raoul Millais (https://github.com/raoulmillais)",
24 + "Salsita Software (http://www.salsitasoft.com/)",
25 + "Mike Schilling <mike@emotive.com> (http://www.emotive.com/)",
26 + "Jackson Tian <shyvo1987@gmail.com> (http://weibo.com/shyvo)",
27 + "Mikhail Zyatin <mikhail.zyatin@gmail.com> (https://github.com/Sitin)",
28 + "Chris Tavares <ctavares@microsoft.com> (https://github.com/christav)",
29 + "Frank Xu <yyfrankyy@gmail.com> (http://f2e.us/)",
30 + "Guido D'Albore <guido@bitstorm.it> (http://www.bitstorm.it/)",
31 + "Jack Senechal (http://jacksenechal.com/)",
32 + "Matthias Hölzl <tc@xantira.com> (https://github.com/hoelzl)",
33 + "Camille Reynders <info@creynders.be> (http://www.creynders.be/)",
34 + "Taylor Gautier (https://github.com/tsgautier)",
35 + "Todd Bryan (https://github.com/toddrbryan)",
36 + "Leore Avidar <leore.avidar@gmail.com> (http://leoreavidar.com/)",
37 + "Dave Aitken <dave.aitken@gmail.com> (http://www.actionshrimp.com/)",
38 + "Shaney Orrowe <shaney.orrowe@practiceweb.co.uk>",
39 + "Candle <candle@candle.me.uk>",
40 + "Jess Telford <hi@jes.st> (http://jes.st)",
41 + "Tom Hughes <<tom@compton.nu> (http://compton.nu/)",
42 + "Piotr Rochala (http://rocha.la/)",
43 + "Michael Avila (https://github.com/michaelavila)",
44 + "Ryan Gahl (https://github.com/ryedin)",
45 + "Eric Laberge <e.laberge@gmail.com> (https://github.com/elaberge)",
46 + "Benjamin E. Coe <ben@npmjs.com> (https://twitter.com/benjamincoe)",
47 + "Stephen Cresswell (https://github.com/cressie176)",
48 + "Pascal Ehlert <pascal@hacksrus.net> (http://www.hacksrus.net/)",
49 + "Tom Spencer <fiznool@gmail.com> (http://fiznool.com/)",
50 + "Tristian Flanagan <tflanagan@datacollaborative.com> (https://github.com/tflanagan)",
51 + "Tim Johns <timjohns@yahoo.com> (https://github.com/TimJohns)",
52 + "Bogdan Chadkin <trysound@yandex.ru> (https://github.com/TrySound)",
53 + "David Wood <david.p.wood@gmail.com> (http://codesleuth.co.uk/)",
54 + "Nicolas Maquet (https://github.com/nmaquet)",
55 + "Lovell Fuller (http://lovell.info/)",
56 + "d3adc0d3 (https://github.com/d3adc0d3)"
57 + ],
58 + "main": "./lib/xml2js",
59 + "files": [
60 + "lib"
61 + ],
62 + "directories": {
63 + "lib": "./lib"
64 + },
65 + "scripts": {
66 + "build": "cake build",
67 + "test": "zap",
68 + "coverage": "nyc npm test && nyc report",
69 + "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
70 + "doc": "cake doc"
71 + },
72 + "repository": {
73 + "type": "git",
74 + "url": "https://github.com/Leonidas-from-XIV/node-xml2js.git"
75 + },
76 + "dependencies": {
77 + "sax": ">=0.6.0",
78 + "xmlbuilder": "~11.0.0"
79 + },
80 + "devDependencies": {
81 + "coffee-script": ">=1.10.0",
82 + "coveralls": "^3.0.1",
83 + "diff": ">=1.0.8",
84 + "docco": ">=0.6.2",
85 + "nyc": ">=2.2.1",
86 + "zap": ">=0.2.9"
87 + },
88 + "engines": {
89 + "node": ">=4.0.0"
90 + },
91 + "license": "MIT"
92 +}
1 +# Change Log
2 +
3 +All notable changes to this project are documented in this file. This project adheres to [Semantic Versioning](http://semver.org/#semantic-versioning-200).
4 +
5 +## [11.0.0] - 2019-02-18
6 +- Calling `end()` with arguments no longer overwrites writer options. See [#120](https://github.com/oozcitak/xmlbuilder-js/issues/120).
7 +- Added writer state and customizable space and endline functions to help customize writer behavior. Also added `openNode` and `closeNode` functions to writer. See [#193](https://github.com/oozcitak/xmlbuilder-js/issues/193).
8 +- Fixed a bug where writer functions would not be called for nodes with a single child node in pretty print mode. See [#195](https://github.com/oozcitak/xmlbuilder-js/issues/195).
9 +- Renamed `elEscape` to `textEscape` in `XMLStringifier`.
10 +- Fixed a bug where empty arrays would produce child nodes. See [#190](https://github.com/oozcitak/xmlbuilder-js/issues/190).
11 +- Removed the `skipNullAttributes` option. `null` attributes are now skipped by default. Added the `keepNullAttributes` option in case someone needs the old behavior.
12 +- Removed the `skipNullNodes` option. `null` nodes are now skipped by default. Added the `keepNullNodes` option in case someone needs the old behavior.
13 +- `undefined` values are now skipped when converting JS objects.
14 +- Renamed stringify functions. See [#194](https://github.com/oozcitak/xmlbuilder-js/issues/194):
15 + * `eleName` -> `name`
16 + * `attName` -> `name`
17 + * `eleText` -> `text`
18 +- Fixed argument order for `attribute` function in the writer. See [#196](https://github.com/oozcitak/xmlbuilder-js/issues/196).
19 +- Added `openAttribute` and `closeAttribute` functions to writer. See [#196](https://github.com/oozcitak/xmlbuilder-js/issues/196).
20 +- Added node types to node objects. Node types and writer states are exported by the module with the `nodeType` and `writerState` properties.
21 +- Fixed a bug where array items would not be correctly converted. See [#159](https://github.com/oozcitak/xmlbuilder-js/issues/159).
22 +- Fixed a bug where mixed-content inside JS objects with `#text` decorator would not be correctly converted. See [#171](https://github.com/oozcitak/xmlbuilder-js/issues/171).
23 +- Fixed a bug where JS objects would not be expanded in callback mode. See [#173](https://github.com/oozcitak/xmlbuilder-js/issues/173).
24 +- Fixed a bug where character validation would not obey document's XML version. Added separate validation for XML 1.0 and XML 1.1 documents. See [#169](https://github.com/oozcitak/xmlbuilder-js/issues/169).
25 +- Fixed a bug where names would not be validated according to the spec. See [#49](https://github.com/oozcitak/xmlbuilder-js/issues/49).
26 +- Renamed `text` property to `value` in comment and cdata nodes to unify the API.
27 +- Removed `doctype` function to prevent name clash with DOM implementation. Use the `dtd` function instead.
28 +- Removed dummy nodes from the XML tree (Those were created while chain-building the tree).
29 +- Renamed `attributes`property to `attribs` to prevent name clash with DOM property with the same name.
30 +- Implemented the DOM standard (read-only) to support XPath lookups. XML namespaces are not currently supported. See [#122](https://github.com/oozcitak/xmlbuilder-js/issues/122).
31 +
32 +## [10.1.1] - 2018-10-24
33 +- Fixed an edge case where a null node at root level would be printed although `skipNullNodes` was set. See [#187](https://github.com/oozcitak/xmlbuilder-js/issues/187).
34 +
35 +## [10.1.0] - 2018-10-10
36 +- Added the `skipNullNodes` option to skip nodes with null values. See [#158](https://github.com/oozcitak/xmlbuilder-js/issues/158).
37 +
38 +## [10.0.0] - 2018-04-26
39 +- Added current indentation level as a parameter to the onData function when in callback mode. See [#125](https://github.com/oozcitak/xmlbuilder-js/issues/125).
40 +- Added name of the current node and parent node to error messages where possible. See [#152](https://github.com/oozcitak/xmlbuilder-js/issues/152). This has the potential to break code depending on the content of error messages.
41 +- Fixed an issue where objects created with Object.create(null) created an error. See [#176](https://github.com/oozcitak/xmlbuilder-js/issues/176).
42 +- Added test builds for node.js v8 and v10.
43 +
44 +## [9.0.7] - 2018-02-09
45 +- Simplified regex used for validating encoding.
46 +
47 +## [9.0.4] - 2017-08-16
48 +- `spacebeforeslash` writer option accepts `true` as well as space char(s).
49 +
50 +## [9.0.3] - 2017-08-15
51 +- `spacebeforeslash` writer option can now be used with XML fragments.
52 +
53 +## [9.0.2] - 2017-08-15
54 +- Added the `spacebeforeslash` writer option to add a space character before closing tags of empty elements. See
55 +[#157](https://github.com/oozcitak/xmlbuilder-js/issues/157).
56 +
57 +## [9.0.1] - 2017-06-19
58 +- Fixed character validity checks to work with node.js 4.0 and 5.0. See
59 +[#161](https://github.com/oozcitak/xmlbuilder-js/issues/161).
60 +
61 +## [9.0.0] - 2017-05-05
62 +- Removed case conversion options.
63 +- Removed support for node.js 4.0 and 5.0. Minimum required version is now 6.0.
64 +- Fixed valid char filter to use XML 1.1 instead of 1.0. See
65 +[#147](https://github.com/oozcitak/xmlbuilder-js/issues/147).
66 +- Added options for negative indentation and suppressing pretty printing of text
67 +nodes. See
68 +[#145](https://github.com/oozcitak/xmlbuilder-js/issues/145).
69 +
70 +## [8.2.2] - 2016-04-08
71 +- Falsy values can now be used as a text node in callback mode.
72 +
73 +## [8.2.1] - 2016-04-07
74 +- Falsy values can now be used as a text node. See
75 +[#117](https://github.com/oozcitak/xmlbuilder-js/issues/117).
76 +
77 +## [8.2.0] - 2016-04-01
78 +- Removed lodash dependency to keep the library small and simple. See
79 +[#114](https://github.com/oozcitak/xmlbuilder-js/issues/114),
80 +[#53](https://github.com/oozcitak/xmlbuilder-js/issues/53),
81 +and [#43](https://github.com/oozcitak/xmlbuilder-js/issues/43).
82 +- Added title case to name conversion options.
83 +
84 +## [8.1.0] - 2016-03-29
85 +- Added the callback option to the `begin` export function. When used with a
86 +callback function, the XML document will be generated in chunks and each chunk
87 +will be passed to the supplied function. In this mode, `begin` uses a different
88 +code path and the builder should use much less memory since the entire XML tree
89 +is not kept. There are a few drawbacks though. For example, traversing the document
90 +tree or adding attributes to a node after it is written is not possible. It is
91 +also not possible to remove nodes or attributes.
92 +
93 +``` js
94 +var result = '';
95 +
96 +builder.begin(function(chunk) { result += chunk; })
97 + .dec()
98 + .ele('root')
99 + .ele('xmlbuilder').up()
100 + .end();
101 +```
102 +
103 +- Replaced native `Object.assign` with `lodash.assign` to support old JS engines. See [#111](https://github.com/oozcitak/xmlbuilder-js/issues/111).
104 +
105 +## [8.0.0] - 2016-03-25
106 +- Added the `begin` export function. See the wiki for details.
107 +- Added the ability to add comments and processing instructions before and after the root element. Added `commentBefore`, `commentAfter`, `instructionBefore` and `instructionAfter` functions for this purpose.
108 +- Dropped support for old node.js releases. Minimum required node.js version is now 4.0.
109 +
110 +## [7.0.0] - 2016-03-21
111 +- Processing instructions are now created as regular nodes. This is a major breaking change if you are using processing instructions. Previously processing instructions were inserted before their parent node. After this change processing instructions are appended to the children of the parent node. Note that it is not currently possible to insert processing instructions before or after the root element.
112 +```js
113 +root.ele('node').ins('pi');
114 +// pre-v7
115 +<?pi?><node/>
116 +// v7
117 +<node><?pi?></node>
118 +```
119 +
120 +## [6.0.0] - 2016-03-20
121 +- Added custom XML writers. The default string conversion functions are now collected under the `XMLStringWriter` class which can be accessed by the `stringWriter(options)` function exported by the module. An `XMLStreamWriter` is also added which outputs the XML document to a writable stream. A stream writer can be created by calling the `streamWriter(stream, options)` function exported by the module. Both classes are heavily customizable and the details are added to the wiki. It is also possible to write an XML writer from scratch and use it when calling `end()` on the XML document.
122 +
123 +## [5.0.1] - 2016-03-08
124 +- Moved require statements for text case conversion to the top of files to reduce lazy requires.
125 +
126 +## [5.0.0] - 2016-03-05
127 +- Added text case option for element names and attribute names. Valid cases are `lower`, `upper`, `camel`, `kebab` and `snake`.
128 +- Attribute and element values are escaped according to the [Canonical XML 1.0 specification](http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping). See [#54](https://github.com/oozcitak/xmlbuilder-js/issues/54) and [#86](https://github.com/oozcitak/xmlbuilder-js/issues/86).
129 +- Added the `allowEmpty` option to `end()`. When this option is set, empty elements are not self-closed.
130 +- Added support for [nested CDATA](https://en.wikipedia.org/wiki/CDATA#Nesting). The triad `]]>` in CDATA is now automatically replaced with `]]]]><![CDATA[>`.
131 +
132 +## [4.2.1] - 2016-01-15
133 +- Updated lodash dependency to 4.0.0.
134 +
135 +## [4.2.0] - 2015-12-16
136 +- Added the `noDoubleEncoding` option to `create()` to control whether existing html entities are encoded.
137 +
138 +## [4.1.0] - 2015-11-11
139 +- Added the `separateArrayItems` option to `create()` to control how arrays are handled when converting from objects. e.g.
140 +
141 +```js
142 +root.ele({ number: [ "one", "two" ]});
143 +// with separateArrayItems: true
144 +<number>
145 + <one/>
146 + <two/>
147 +</number>
148 +// with separateArrayItems: false
149 +<number>one</number>
150 +<number>two</number>
151 +```
152 +
153 +## [4.0.0] - 2015-11-01
154 +- Removed the `#list` decorator. Array items are now created as child nodes by default.
155 +- Fixed a bug where the XML encoding string was checked partially.
156 +
157 +## [3.1.0] - 2015-09-19
158 +- `#list` decorator ignores empty arrays.
159 +
160 +## [3.0.0] - 2015-09-10
161 +- Allow `\r`, `\n` and `\t` in attribute values without escaping. See [#86](https://github.com/oozcitak/xmlbuilder-js/issues/86).
162 +
163 +## [2.6.5] - 2015-09-09
164 +- Use native `isArray` instead of lodash.
165 +- Indentation of processing instructions are set to the parent element's.
166 +
167 +## [2.6.4] - 2015-05-27
168 +- Updated lodash dependency to 3.5.0.
169 +
170 +## [2.6.3] - 2015-05-27
171 +- Bumped version because previous release was not published on npm.
172 +
173 +## [2.6.2] - 2015-03-10
174 +- Updated lodash dependency to 3.5.0.
175 +
176 +## [2.6.1] - 2015-02-20
177 +- Updated lodash dependency to 3.3.0.
178 +
179 +## [2.6.0] - 2015-02-20
180 +- Fixed a bug where the `XMLNode` constructor overwrote the super class parent.
181 +- Removed document property from cloned nodes.
182 +- Switched to mocha.js for testing.
183 +
184 +## [2.5.2] - 2015-02-16
185 +- Updated lodash dependency to 3.2.0.
186 +
187 +## [2.5.1] - 2015-02-09
188 +- Updated lodash dependency to 3.1.0.
189 +- Support all node >= 0.8.
190 +
191 +## [2.5.0] - 2015-00-03
192 +- Updated lodash dependency to 3.0.0.
193 +
194 +## [2.4.6] - 2015-01-26
195 +- Show more information from attribute creation with null values.
196 +- Added iojs as an engine.
197 +- Self close elements with empty text.
198 +
199 +## [2.4.5] - 2014-11-15
200 +- Fixed prepublish script to run on windows.
201 +- Fixed bug in XMLStringifier where an undefined value was used while reporting an invalid encoding value.
202 +- Moved require statements to the top of files to reduce lazy requires. See [#62](https://github.com/oozcitak/xmlbuilder-js/issues/62).
203 +
204 +## [2.4.4] - 2014-09-08
205 +- Added the `offset` option to `toString()` for use in XML fragments.
206 +
207 +## [2.4.3] - 2014-08-13
208 +- Corrected license in package description.
209 +
210 +## [2.4.2] - 2014-08-13
211 +- Dropped performance test and memwatch dependency.
212 +
213 +## [2.4.1] - 2014-08-12
214 +- Fixed a bug where empty indent string was omitted when pretty printing. See [#59](https://github.com/oozcitak/xmlbuilder-js/issues/59).
215 +
216 +## [2.4.0] - 2014-08-04
217 +- Correct cases of pubID and sysID.
218 +- Use single lodash instead of separate npm modules. See [#53](https://github.com/oozcitak/xmlbuilder-js/issues/53).
219 +- Escape according to Canonical XML 1.0. See [#54](https://github.com/oozcitak/xmlbuilder-js/issues/54).
220 +
221 +## [2.3.0] - 2014-07-17
222 +- Convert objects to JS primitives while sanitizing user input.
223 +- Object builder preserves items with null values. See [#44](https://github.com/oozcitak/xmlbuilder-js/issues/44).
224 +- Use modularized lodash functions to cut down dependencies.
225 +- Process empty objects when converting from objects so that we don't throw on empty child objects.
226 +
227 +## [2.2.1] - 2014-04-04
228 +- Bumped version because previous release was not published on npm.
229 +
230 +## [2.2.0] - 2014-04-04
231 +- Switch to lodash from underscore.
232 +- Removed legacy `ext` option from `create()`.
233 +- Drop old node versions: 0.4, 0.5, 0.6. 0.8 is the minimum requirement from now on.
234 +
235 +## [2.1.0] - 2013-12-30
236 +- Removed duplicate null checks from constructors.
237 +- Fixed node count in performance test.
238 +- Added option for skipping null attribute values. See [#26](https://github.com/oozcitak/xmlbuilder-js/issues/26).
239 +- Allow multiple values in `att()` and `ins()`.
240 +- Added ability to run individual performance tests.
241 +- Added flag for ignoring decorator strings.
242 +
243 +## [2.0.1] - 2013-12-24
244 +- Removed performance tests from npm package.
245 +
246 +## [2.0.0] - 2013-12-24
247 +- Combined loops for speed up.
248 +- Added support for the DTD and XML declaration.
249 +- `clone` includes attributes.
250 +- Added performance tests.
251 +- Evaluate attribute value if function.
252 +- Evaluate instruction value if function.
253 +
254 +## [1.1.2] - 2013-12-11
255 +- Changed processing instruction decorator to `?`.
256 +
257 +## [1.1.1] - 2013-12-11
258 +- Added processing instructions to JS object conversion.
259 +
260 +## [1.1.0] - 2013-12-10
261 +- Added license to package.
262 +- `create()` and `element()` accept JS object to fully build the document.
263 +- Added `nod()` and `n()` aliases for `node()`.
264 +- Renamed `convertAttChar` decorator to `convertAttKey`.
265 +- Ignore empty decorator strings when converting JS objects.
266 +
267 +## [1.0.2] - 2013-11-27
268 +- Removed temp file which was accidentally included in the package.
269 +
270 +## [1.0.1] - 2013-11-27
271 +- Custom stringify functions affect current instance only.
272 +
273 +## [1.0.0] - 2013-11-27
274 +- Added processing instructions.
275 +- Added stringify functions to sanitize and convert input values.
276 +- Added option for headless XML documents.
277 +- Added vows tests.
278 +- Removed Makefile. Using npm publish scripts instead.
279 +- Removed the `begin()` function. `create()` begins the document by creating the root node.
280 +
281 +## [0.4.3] - 2013-11-08
282 +- Added option to include surrogate pairs in XML content. See [#29](https://github.com/oozcitak/xmlbuilder-js/issues/29).
283 +- Fixed empty value string representation in pretty mode.
284 +- Added pre and postpublish scripts to package.json.
285 +- Filtered out prototype properties when appending attributes. See [#31](https://github.com/oozcitak/xmlbuilder-js/issues/31).
286 +
287 +## [0.4.2] - 2012-09-14
288 +- Removed README.md from `.npmignore`.
289 +
290 +## [0.4.1] - 2012-08-31
291 +- Removed `begin()` calls in favor of `XMLBuilder` constructor.
292 +- Added the `end()` function. `end()` is a convenience over `doc().toString()`.
293 +
294 +## [0.4.0] - 2012-08-31
295 +- Added arguments to `XMLBuilder` constructor to allow the name of the root element and XML prolog to be defined in one line.
296 +- Soft deprecated `begin()`.
297 +
298 +## [0.3.11] - 2012-08-13
299 +- Package keywords are fixed to be an array of values.
300 +
301 +## [0.3.10] - 2012-08-13
302 +- Brought back npm package contents which were lost due to incorrect configuration of `package.json` in previous releases.
303 +
304 +## [0.3.3] - 2012-07-27
305 +- Implemented `importXMLBuilder()`.
306 +
307 +## [0.3.2] - 2012-07-20
308 +- Fixed a duplicated escaping problem on `element()`.
309 +- Fixed a problem with text node creation from empty string.
310 +- Calling `root()` on the document element returns the root element.
311 +- `XMLBuilder` no longer extends `XMLFragment`.
312 +
313 +## [0.3.1] - 2011-11-28
314 +- Added guards for document element so that nodes cannot be inserted at document level.
315 +
316 +## [0.3.0] - 2011-11-28
317 +- Added `doc()` to return the document element.
318 +
319 +## [0.2.2] - 2011-11-28
320 +- Prevent code relying on `up()`'s older behavior to break.
321 +
322 +## [0.2.1] - 2011-11-28
323 +- Added the `root()` function.
324 +
325 +## [0.2.0] - 2011-11-21
326 +- Added Travis-CI integration.
327 +- Added coffee-script dependency.
328 +- Added insert, traversal and delete functions.
329 +
330 +## [0.1.7] - 2011-10-25
331 +- No changes. Accidental release.
332 +
333 +## [0.1.6] - 2011-10-25
334 +- Corrected `package.json` bugs link to `url` from `web`.
335 +
336 +## [0.1.5] - 2011-08-08
337 +- Added missing npm package contents.
338 +
339 +## [0.1.4] - 2011-07-29
340 +- Text-only nodes are no longer indented.
341 +- Added documentation for multiple instances.
342 +
343 +## [0.1.3] - 2011-07-27
344 +- Exported the `create()` function to return a new instance. This allows multiple builder instances to be constructed.
345 +- Fixed `u()` function so that it now correctly calls `up()`.
346 +- Fixed typo in `element()` so that `attributes` and `text` can be passed interchangeably.
347 +
348 +## [0.1.2] - 2011-06-03
349 +- `ele()` accepts element text.
350 +- `attributes()` now overrides existing attributes if passed the same attribute name.
351 +
352 +## [0.1.1] - 2011-05-19
353 +- Added the raw output option.
354 +- Removed most validity checks.
355 +
356 +## [0.1.0] - 2011-04-27
357 +- `text()` and `cdata()` now return parent element.
358 +- Attribute values are escaped.
359 +
360 +## [0.0.7] - 2011-04-23
361 +- Coerced text values to string.
362 +
363 +## [0.0.6] - 2011-02-23
364 +- Added support for XML comments.
365 +- Text nodes are checked against CharData.
366 +
367 +## [0.0.5] - 2010-12-31
368 +- Corrected the name of the main npm module in `package.json`.
369 +
370 +## [0.0.4] - 2010-12-28
371 +- Added `.npmignore`.
372 +
373 +## [0.0.3] - 2010-12-27
374 +- root element is now constructed in `begin()`.
375 +- moved prolog to `begin()`.
376 +- Added the ability to have CDATA in element text.
377 +- Removed unused prolog aliases.
378 +- Removed `builder()` function from main module.
379 +- Added the name of the main npm module in `package.json`.
380 +
381 +## [0.0.2] - 2010-11-03
382 +- `element()` expands nested arrays.
383 +- Added pretty printing.
384 +- Added the `up()`, `build()` and `prolog()` functions.
385 +- Added readme.
386 +
387 +## 0.0.1 - 2010-11-02
388 +- Initial release
389 +
390 +[11.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v10.1.1...v11.0.0
391 +[10.1.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v10.1.0...v10.1.1
392 +[10.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v10.0.0...v10.1.0
393 +[10.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.7...v10.0.0
394 +[9.0.7]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.4...v9.0.7
395 +[9.0.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.3...v9.0.4
396 +[9.0.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.2...v9.0.3
397 +[9.0.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.1...v9.0.2
398 +[9.0.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.0...v9.0.1
399 +[9.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.2.2...v9.0.0
400 +[8.2.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.2.1...v8.2.2
401 +[8.2.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.2.0...v8.2.1
402 +[8.2.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.1.0...v8.2.0
403 +[8.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.0.0...v8.1.0
404 +[8.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v7.0.0...v8.0.0
405 +[7.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v6.0.0...v7.0.0
406 +[6.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v5.0.1...v6.0.0
407 +[5.0.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v5.0.0...v5.0.1
408 +[5.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v4.2.1...v5.0.0
409 +[4.2.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v4.2.0...v4.2.1
410 +[4.2.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v4.1.0...v4.2.0
411 +[4.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v4.0.0...v4.1.0
412 +[4.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v3.1.0...v4.0.0
413 +[3.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v3.0.0...v3.1.0
414 +[3.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.5...v3.0.0
415 +[2.6.5]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.4...v2.6.5
416 +[2.6.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.3...v2.6.4
417 +[2.6.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.2...v2.6.3
418 +[2.6.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.1...v2.6.2
419 +[2.6.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.0...v2.6.1
420 +[2.6.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.5.2...v2.6.0
421 +[2.5.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.5.1...v2.5.2
422 +[2.5.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.5.0...v2.5.1
423 +[2.5.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.6...v2.5.0
424 +[2.4.6]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.5...v2.4.6
425 +[2.4.5]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.4...v2.4.5
426 +[2.4.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.3...v2.4.4
427 +[2.4.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.2...v2.4.3
428 +[2.4.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.1...v2.4.2
429 +[2.4.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.0...v2.4.1
430 +[2.4.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.3.0...v2.4.0
431 +[2.3.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.2.1...v2.3.0
432 +[2.2.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.2.0...v2.2.1
433 +[2.2.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.1.0...v2.2.0
434 +[2.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.0.1...v2.1.0
435 +[2.0.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.0.0...v2.0.1
436 +[2.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.1.2...v2.0.0
437 +[1.1.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.1.1...v1.1.2
438 +[1.1.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.1.0...v1.1.1
439 +[1.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.0.2...v1.1.0
440 +[1.0.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.0.1...v1.0.2
441 +[1.0.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.0.0...v1.0.1
442 +[1.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.4.3...v1.0.0
443 +[0.4.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.4.2...v0.4.3
444 +[0.4.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.4.1...v0.4.2
445 +[0.4.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.4.0...v0.4.1
446 +[0.4.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.11...v0.4.0
447 +[0.3.11]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.10...v0.3.11
448 +[0.3.10]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.3...v0.3.10
449 +[0.3.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.2...v0.3.3
450 +[0.3.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.1...v0.3.2
451 +[0.3.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.0...v0.3.1
452 +[0.3.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.2.2...v0.3.0
453 +[0.2.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.2.1...v0.2.2
454 +[0.2.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.2.0...v0.2.1
455 +[0.2.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.7...v0.2.0
456 +[0.1.7]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.6...v0.1.7
457 +[0.1.6]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.5...v0.1.6
458 +[0.1.5]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.4...v0.1.5
459 +[0.1.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.3...v0.1.4
460 +[0.1.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.2...v0.1.3
461 +[0.1.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.1...v0.1.2
462 +[0.1.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.0...v0.1.1
463 +[0.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.7...v0.1.0
464 +[0.0.7]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.6...v0.0.7
465 +[0.0.6]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.5...v0.0.6
466 +[0.0.5]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.4...v0.0.5
467 +[0.0.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.3...v0.0.4
468 +[0.0.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.2...v0.0.3
469 +[0.0.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.1...v0.0.2
470 +
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2013 Ozgur Ozcitak
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +# xmlbuilder-js
2 +
3 +An XML builder for [node.js](https://nodejs.org/) similar to
4 +[java-xmlbuilder](https://github.com/jmurty/java-xmlbuilder).
5 +
6 +[![License](http://img.shields.io/npm/l/xmlbuilder.svg?style=flat-square)](http://opensource.org/licenses/MIT)
7 +[![NPM Version](http://img.shields.io/npm/v/xmlbuilder.svg?style=flat-square)](https://npmjs.com/package/xmlbuilder)
8 +[![NPM Downloads](https://img.shields.io/npm/dm/xmlbuilder.svg?style=flat-square)](https://npmjs.com/package/xmlbuilder)
9 +
10 +[![Travis Build Status](http://img.shields.io/travis/oozcitak/xmlbuilder-js.svg?style=flat-square)](http://travis-ci.org/oozcitak/xmlbuilder-js)
11 +[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/bf7odb20hj77isry?svg=true)](https://ci.appveyor.com/project/oozcitak/xmlbuilder-js)
12 +[![Dev Dependency Status](http://img.shields.io/david/dev/oozcitak/xmlbuilder-js.svg?style=flat-square)](https://david-dm.org/oozcitak/xmlbuilder-js)
13 +[![Code Coverage](https://img.shields.io/coveralls/oozcitak/xmlbuilder-js.svg?style=flat-square)](https://coveralls.io/github/oozcitak/xmlbuilder-js)
14 +
15 +### Installation:
16 +
17 +``` sh
18 +npm install xmlbuilder
19 +```
20 +
21 +### Usage:
22 +
23 +``` js
24 +var builder = require('xmlbuilder');
25 +var xml = builder.create('root')
26 + .ele('xmlbuilder')
27 + .ele('repo', {'type': 'git'}, 'git://github.com/oozcitak/xmlbuilder-js.git')
28 + .end({ pretty: true});
29 +
30 +console.log(xml);
31 +```
32 +
33 +will result in:
34 +
35 +``` xml
36 +<?xml version="1.0"?>
37 +<root>
38 + <xmlbuilder>
39 + <repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo>
40 + </xmlbuilder>
41 +</root>
42 +```
43 +
44 +It is also possible to convert objects into nodes:
45 +
46 +``` js
47 +builder.create({
48 + root: {
49 + xmlbuilder: {
50 + repo: {
51 + '@type': 'git', // attributes start with @
52 + '#text': 'git://github.com/oozcitak/xmlbuilder-js.git' // text node
53 + }
54 + }
55 + }
56 +});
57 +```
58 +
59 +If you need to do some processing:
60 +
61 +``` js
62 +var root = builder.create('squares');
63 +root.com('f(x) = x^2');
64 +for(var i = 1; i <= 5; i++)
65 +{
66 + var item = root.ele('data');
67 + item.att('x', i);
68 + item.att('y', i * i);
69 +}
70 +```
71 +
72 +This will result in:
73 +
74 +``` xml
75 +<?xml version="1.0"?>
76 +<squares>
77 + <!-- f(x) = x^2 -->
78 + <data x="1" y="1"/>
79 + <data x="2" y="4"/>
80 + <data x="3" y="9"/>
81 + <data x="4" y="16"/>
82 + <data x="5" y="25"/>
83 +</squares>
84 +```
85 +
86 +See the [wiki](https://github.com/oozcitak/xmlbuilder-js/wiki) for details and [examples](https://github.com/oozcitak/xmlbuilder-js/wiki/Examples) for more complex examples.
1 +environment:
2 + matrix:
3 + - nodejs_version: "4"
4 + - nodejs_version: "5"
5 + - nodejs_version: "6"
6 + - nodejs_version: "8"
7 + - nodejs_version: "10"
8 + - nodejs_version: "" # latest
9 +
10 +install:
11 + - ps: "Install-Product node $env:nodejs_version"
12 + - "npm install"
13 +
14 +test_script:
15 + - "node --version"
16 + - "npm --version"
17 + - "npm test"
18 +
19 +build: off
20 +
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + module.exports = {
4 + Restriction: 1,
5 + Extension: 2,
6 + Union: 4,
7 + List: 8
8 + };
9 +
10 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + module.exports = {
4 + Disconnected: 1,
5 + Preceding: 2,
6 + Following: 4,
7 + Contains: 8,
8 + ContainedBy: 16,
9 + ImplementationSpecific: 32
10 + };
11 +
12 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + module.exports = {
4 + Element: 1,
5 + Attribute: 2,
6 + Text: 3,
7 + CData: 4,
8 + EntityReference: 5,
9 + EntityDeclaration: 6,
10 + ProcessingInstruction: 7,
11 + Comment: 8,
12 + Document: 9,
13 + DocType: 10,
14 + DocumentFragment: 11,
15 + NotationDeclaration: 12,
16 + Declaration: 201,
17 + Raw: 202,
18 + AttributeDeclaration: 203,
19 + ElementDeclaration: 204,
20 + Dummy: 205
21 + };
22 +
23 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + module.exports = {
4 + Clones: 1,
5 + Imported: 2,
6 + Deleted: 3,
7 + Renamed: 4,
8 + Adopted: 5
9 + };
10 +
11 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
4 + slice = [].slice,
5 + hasProp = {}.hasOwnProperty;
6 +
7 + assign = function() {
8 + var i, key, len, source, sources, target;
9 + target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
10 + if (isFunction(Object.assign)) {
11 + Object.assign.apply(null, arguments);
12 + } else {
13 + for (i = 0, len = sources.length; i < len; i++) {
14 + source = sources[i];
15 + if (source != null) {
16 + for (key in source) {
17 + if (!hasProp.call(source, key)) continue;
18 + target[key] = source[key];
19 + }
20 + }
21 + }
22 + }
23 + return target;
24 + };
25 +
26 + isFunction = function(val) {
27 + return !!val && Object.prototype.toString.call(val) === '[object Function]';
28 + };
29 +
30 + isObject = function(val) {
31 + var ref;
32 + return !!val && ((ref = typeof val) === 'function' || ref === 'object');
33 + };
34 +
35 + isArray = function(val) {
36 + if (isFunction(Array.isArray)) {
37 + return Array.isArray(val);
38 + } else {
39 + return Object.prototype.toString.call(val) === '[object Array]';
40 + }
41 + };
42 +
43 + isEmpty = function(val) {
44 + var key;
45 + if (isArray(val)) {
46 + return !val.length;
47 + } else {
48 + for (key in val) {
49 + if (!hasProp.call(val, key)) continue;
50 + return false;
51 + }
52 + return true;
53 + }
54 + };
55 +
56 + isPlainObject = function(val) {
57 + var ctor, proto;
58 + return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
59 + };
60 +
61 + getValue = function(obj) {
62 + if (isFunction(obj.valueOf)) {
63 + return obj.valueOf();
64 + } else {
65 + return obj;
66 + }
67 + };
68 +
69 + module.exports.assign = assign;
70 +
71 + module.exports.isFunction = isFunction;
72 +
73 + module.exports.isObject = isObject;
74 +
75 + module.exports.isArray = isArray;
76 +
77 + module.exports.isEmpty = isEmpty;
78 +
79 + module.exports.isPlainObject = isPlainObject;
80 +
81 + module.exports.getValue = getValue;
82 +
83 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + module.exports = {
4 + None: 0,
5 + OpenTag: 1,
6 + InsideTag: 2,
7 + CloseTag: 3
8 + };
9 +
10 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLAttribute, XMLNode;
4 +
5 + NodeType = require('./NodeType');
6 +
7 + XMLNode = require('./XMLNode');
8 +
9 + module.exports = XMLAttribute = (function() {
10 + function XMLAttribute(parent, name, value) {
11 + this.parent = parent;
12 + if (this.parent) {
13 + this.options = this.parent.options;
14 + this.stringify = this.parent.stringify;
15 + }
16 + if (name == null) {
17 + throw new Error("Missing attribute name. " + this.debugInfo(name));
18 + }
19 + this.name = this.stringify.name(name);
20 + this.value = this.stringify.attValue(value);
21 + this.type = NodeType.Attribute;
22 + this.isId = false;
23 + this.schemaTypeInfo = null;
24 + }
25 +
26 + Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
27 + get: function() {
28 + return this.type;
29 + }
30 + });
31 +
32 + Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
33 + get: function() {
34 + return this.parent;
35 + }
36 + });
37 +
38 + Object.defineProperty(XMLAttribute.prototype, 'textContent', {
39 + get: function() {
40 + return this.value;
41 + },
42 + set: function(value) {
43 + return this.value = value || '';
44 + }
45 + });
46 +
47 + Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
48 + get: function() {
49 + return '';
50 + }
51 + });
52 +
53 + Object.defineProperty(XMLAttribute.prototype, 'prefix', {
54 + get: function() {
55 + return '';
56 + }
57 + });
58 +
59 + Object.defineProperty(XMLAttribute.prototype, 'localName', {
60 + get: function() {
61 + return this.name;
62 + }
63 + });
64 +
65 + Object.defineProperty(XMLAttribute.prototype, 'specified', {
66 + get: function() {
67 + return true;
68 + }
69 + });
70 +
71 + XMLAttribute.prototype.clone = function() {
72 + return Object.create(this);
73 + };
74 +
75 + XMLAttribute.prototype.toString = function(options) {
76 + return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
77 + };
78 +
79 + XMLAttribute.prototype.debugInfo = function(name) {
80 + name = name || this.name;
81 + if (name == null) {
82 + return "parent: <" + this.parent.name + ">";
83 + } else {
84 + return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
85 + }
86 + };
87 +
88 + XMLAttribute.prototype.isEqualNode = function(node) {
89 + if (node.namespaceURI !== this.namespaceURI) {
90 + return false;
91 + }
92 + if (node.prefix !== this.prefix) {
93 + return false;
94 + }
95 + if (node.localName !== this.localName) {
96 + return false;
97 + }
98 + if (node.value !== this.value) {
99 + return false;
100 + }
101 + return true;
102 + };
103 +
104 + return XMLAttribute;
105 +
106 + })();
107 +
108 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLCData, XMLCharacterData,
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 +
7 + NodeType = require('./NodeType');
8 +
9 + XMLCharacterData = require('./XMLCharacterData');
10 +
11 + module.exports = XMLCData = (function(superClass) {
12 + extend(XMLCData, superClass);
13 +
14 + function XMLCData(parent, text) {
15 + XMLCData.__super__.constructor.call(this, parent);
16 + if (text == null) {
17 + throw new Error("Missing CDATA text. " + this.debugInfo());
18 + }
19 + this.name = "#cdata-section";
20 + this.type = NodeType.CData;
21 + this.value = this.stringify.cdata(text);
22 + }
23 +
24 + XMLCData.prototype.clone = function() {
25 + return Object.create(this);
26 + };
27 +
28 + XMLCData.prototype.toString = function(options) {
29 + return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
30 + };
31 +
32 + return XMLCData;
33 +
34 + })(XMLCharacterData);
35 +
36 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var XMLCharacterData, XMLNode,
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 +
7 + XMLNode = require('./XMLNode');
8 +
9 + module.exports = XMLCharacterData = (function(superClass) {
10 + extend(XMLCharacterData, superClass);
11 +
12 + function XMLCharacterData(parent) {
13 + XMLCharacterData.__super__.constructor.call(this, parent);
14 + this.value = '';
15 + }
16 +
17 + Object.defineProperty(XMLCharacterData.prototype, 'data', {
18 + get: function() {
19 + return this.value;
20 + },
21 + set: function(value) {
22 + return this.value = value || '';
23 + }
24 + });
25 +
26 + Object.defineProperty(XMLCharacterData.prototype, 'length', {
27 + get: function() {
28 + return this.value.length;
29 + }
30 + });
31 +
32 + Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
33 + get: function() {
34 + return this.value;
35 + },
36 + set: function(value) {
37 + return this.value = value || '';
38 + }
39 + });
40 +
41 + XMLCharacterData.prototype.clone = function() {
42 + return Object.create(this);
43 + };
44 +
45 + XMLCharacterData.prototype.substringData = function(offset, count) {
46 + throw new Error("This DOM method is not implemented." + this.debugInfo());
47 + };
48 +
49 + XMLCharacterData.prototype.appendData = function(arg) {
50 + throw new Error("This DOM method is not implemented." + this.debugInfo());
51 + };
52 +
53 + XMLCharacterData.prototype.insertData = function(offset, arg) {
54 + throw new Error("This DOM method is not implemented." + this.debugInfo());
55 + };
56 +
57 + XMLCharacterData.prototype.deleteData = function(offset, count) {
58 + throw new Error("This DOM method is not implemented." + this.debugInfo());
59 + };
60 +
61 + XMLCharacterData.prototype.replaceData = function(offset, count, arg) {
62 + throw new Error("This DOM method is not implemented." + this.debugInfo());
63 + };
64 +
65 + XMLCharacterData.prototype.isEqualNode = function(node) {
66 + if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
67 + return false;
68 + }
69 + if (node.data !== this.data) {
70 + return false;
71 + }
72 + return true;
73 + };
74 +
75 + return XMLCharacterData;
76 +
77 + })(XMLNode);
78 +
79 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLCharacterData, XMLComment,
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 +
7 + NodeType = require('./NodeType');
8 +
9 + XMLCharacterData = require('./XMLCharacterData');
10 +
11 + module.exports = XMLComment = (function(superClass) {
12 + extend(XMLComment, superClass);
13 +
14 + function XMLComment(parent, text) {
15 + XMLComment.__super__.constructor.call(this, parent);
16 + if (text == null) {
17 + throw new Error("Missing comment text. " + this.debugInfo());
18 + }
19 + this.name = "#comment";
20 + this.type = NodeType.Comment;
21 + this.value = this.stringify.comment(text);
22 + }
23 +
24 + XMLComment.prototype.clone = function() {
25 + return Object.create(this);
26 + };
27 +
28 + XMLComment.prototype.toString = function(options) {
29 + return this.options.writer.comment(this, this.options.writer.filterOptions(options));
30 + };
31 +
32 + return XMLComment;
33 +
34 + })(XMLCharacterData);
35 +
36 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
4 +
5 + XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
6 +
7 + XMLDOMStringList = require('./XMLDOMStringList');
8 +
9 + module.exports = XMLDOMConfiguration = (function() {
10 + function XMLDOMConfiguration() {
11 + var clonedSelf;
12 + this.defaultParams = {
13 + "canonical-form": false,
14 + "cdata-sections": false,
15 + "comments": false,
16 + "datatype-normalization": false,
17 + "element-content-whitespace": true,
18 + "entities": true,
19 + "error-handler": new XMLDOMErrorHandler(),
20 + "infoset": true,
21 + "validate-if-schema": false,
22 + "namespaces": true,
23 + "namespace-declarations": true,
24 + "normalize-characters": false,
25 + "schema-location": '',
26 + "schema-type": '',
27 + "split-cdata-sections": true,
28 + "validate": false,
29 + "well-formed": true
30 + };
31 + this.params = clonedSelf = Object.create(this.defaultParams);
32 + }
33 +
34 + Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
35 + get: function() {
36 + return new XMLDOMStringList(Object.keys(this.defaultParams));
37 + }
38 + });
39 +
40 + XMLDOMConfiguration.prototype.getParameter = function(name) {
41 + if (this.params.hasOwnProperty(name)) {
42 + return this.params[name];
43 + } else {
44 + return null;
45 + }
46 + };
47 +
48 + XMLDOMConfiguration.prototype.canSetParameter = function(name, value) {
49 + return true;
50 + };
51 +
52 + XMLDOMConfiguration.prototype.setParameter = function(name, value) {
53 + if (value != null) {
54 + return this.params[name] = value;
55 + } else {
56 + return delete this.params[name];
57 + }
58 + };
59 +
60 + return XMLDOMConfiguration;
61 +
62 + })();
63 +
64 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var XMLDOMErrorHandler;
4 +
5 + module.exports = XMLDOMErrorHandler = (function() {
6 + function XMLDOMErrorHandler() {}
7 +
8 + XMLDOMErrorHandler.prototype.handleError = function(error) {
9 + throw new Error(error);
10 + };
11 +
12 + return XMLDOMErrorHandler;
13 +
14 + })();
15 +
16 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var XMLDOMImplementation;
4 +
5 + module.exports = XMLDOMImplementation = (function() {
6 + function XMLDOMImplementation() {}
7 +
8 + XMLDOMImplementation.prototype.hasFeature = function(feature, version) {
9 + return true;
10 + };
11 +
12 + XMLDOMImplementation.prototype.createDocumentType = function(qualifiedName, publicId, systemId) {
13 + throw new Error("This DOM method is not implemented.");
14 + };
15 +
16 + XMLDOMImplementation.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) {
17 + throw new Error("This DOM method is not implemented.");
18 + };
19 +
20 + XMLDOMImplementation.prototype.createHTMLDocument = function(title) {
21 + throw new Error("This DOM method is not implemented.");
22 + };
23 +
24 + XMLDOMImplementation.prototype.getFeature = function(feature, version) {
25 + throw new Error("This DOM method is not implemented.");
26 + };
27 +
28 + return XMLDOMImplementation;
29 +
30 + })();
31 +
32 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var XMLDOMStringList;
4 +
5 + module.exports = XMLDOMStringList = (function() {
6 + function XMLDOMStringList(arr) {
7 + this.arr = arr || [];
8 + }
9 +
10 + Object.defineProperty(XMLDOMStringList.prototype, 'length', {
11 + get: function() {
12 + return this.arr.length;
13 + }
14 + });
15 +
16 + XMLDOMStringList.prototype.item = function(index) {
17 + return this.arr[index] || null;
18 + };
19 +
20 + XMLDOMStringList.prototype.contains = function(str) {
21 + return this.arr.indexOf(str) !== -1;
22 + };
23 +
24 + return XMLDOMStringList;
25 +
26 + })();
27 +
28 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLDTDAttList, XMLNode,
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 +
7 + XMLNode = require('./XMLNode');
8 +
9 + NodeType = require('./NodeType');
10 +
11 + module.exports = XMLDTDAttList = (function(superClass) {
12 + extend(XMLDTDAttList, superClass);
13 +
14 + function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
15 + XMLDTDAttList.__super__.constructor.call(this, parent);
16 + if (elementName == null) {
17 + throw new Error("Missing DTD element name. " + this.debugInfo());
18 + }
19 + if (attributeName == null) {
20 + throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
21 + }
22 + if (!attributeType) {
23 + throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
24 + }
25 + if (!defaultValueType) {
26 + throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
27 + }
28 + if (defaultValueType.indexOf('#') !== 0) {
29 + defaultValueType = '#' + defaultValueType;
30 + }
31 + if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
32 + throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
33 + }
34 + if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
35 + throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
36 + }
37 + this.elementName = this.stringify.name(elementName);
38 + this.type = NodeType.AttributeDeclaration;
39 + this.attributeName = this.stringify.name(attributeName);
40 + this.attributeType = this.stringify.dtdAttType(attributeType);
41 + if (defaultValue) {
42 + this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
43 + }
44 + this.defaultValueType = defaultValueType;
45 + }
46 +
47 + XMLDTDAttList.prototype.toString = function(options) {
48 + return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
49 + };
50 +
51 + return XMLDTDAttList;
52 +
53 + })(XMLNode);
54 +
55 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLDTDElement, XMLNode,
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 +
7 + XMLNode = require('./XMLNode');
8 +
9 + NodeType = require('./NodeType');
10 +
11 + module.exports = XMLDTDElement = (function(superClass) {
12 + extend(XMLDTDElement, superClass);
13 +
14 + function XMLDTDElement(parent, name, value) {
15 + XMLDTDElement.__super__.constructor.call(this, parent);
16 + if (name == null) {
17 + throw new Error("Missing DTD element name. " + this.debugInfo());
18 + }
19 + if (!value) {
20 + value = '(#PCDATA)';
21 + }
22 + if (Array.isArray(value)) {
23 + value = '(' + value.join(',') + ')';
24 + }
25 + this.name = this.stringify.name(name);
26 + this.type = NodeType.ElementDeclaration;
27 + this.value = this.stringify.dtdElementValue(value);
28 + }
29 +
30 + XMLDTDElement.prototype.toString = function(options) {
31 + return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
32 + };
33 +
34 + return XMLDTDElement;
35 +
36 + })(XMLNode);
37 +
38 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLDTDEntity, XMLNode, isObject,
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 +
7 + isObject = require('./Utility').isObject;
8 +
9 + XMLNode = require('./XMLNode');
10 +
11 + NodeType = require('./NodeType');
12 +
13 + module.exports = XMLDTDEntity = (function(superClass) {
14 + extend(XMLDTDEntity, superClass);
15 +
16 + function XMLDTDEntity(parent, pe, name, value) {
17 + XMLDTDEntity.__super__.constructor.call(this, parent);
18 + if (name == null) {
19 + throw new Error("Missing DTD entity name. " + this.debugInfo(name));
20 + }
21 + if (value == null) {
22 + throw new Error("Missing DTD entity value. " + this.debugInfo(name));
23 + }
24 + this.pe = !!pe;
25 + this.name = this.stringify.name(name);
26 + this.type = NodeType.EntityDeclaration;
27 + if (!isObject(value)) {
28 + this.value = this.stringify.dtdEntityValue(value);
29 + this.internal = true;
30 + } else {
31 + if (!value.pubID && !value.sysID) {
32 + throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
33 + }
34 + if (value.pubID && !value.sysID) {
35 + throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
36 + }
37 + this.internal = false;
38 + if (value.pubID != null) {
39 + this.pubID = this.stringify.dtdPubID(value.pubID);
40 + }
41 + if (value.sysID != null) {
42 + this.sysID = this.stringify.dtdSysID(value.sysID);
43 + }
44 + if (value.nData != null) {
45 + this.nData = this.stringify.dtdNData(value.nData);
46 + }
47 + if (this.pe && this.nData) {
48 + throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
49 + }
50 + }
51 + }
52 +
53 + Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
54 + get: function() {
55 + return this.pubID;
56 + }
57 + });
58 +
59 + Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
60 + get: function() {
61 + return this.sysID;
62 + }
63 + });
64 +
65 + Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
66 + get: function() {
67 + return this.nData || null;
68 + }
69 + });
70 +
71 + Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
72 + get: function() {
73 + return null;
74 + }
75 + });
76 +
77 + Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
78 + get: function() {
79 + return null;
80 + }
81 + });
82 +
83 + Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
84 + get: function() {
85 + return null;
86 + }
87 + });
88 +
89 + XMLDTDEntity.prototype.toString = function(options) {
90 + return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
91 + };
92 +
93 + return XMLDTDEntity;
94 +
95 + })(XMLNode);
96 +
97 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLDTDNotation, XMLNode,
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 +
7 + XMLNode = require('./XMLNode');
8 +
9 + NodeType = require('./NodeType');
10 +
11 + module.exports = XMLDTDNotation = (function(superClass) {
12 + extend(XMLDTDNotation, superClass);
13 +
14 + function XMLDTDNotation(parent, name, value) {
15 + XMLDTDNotation.__super__.constructor.call(this, parent);
16 + if (name == null) {
17 + throw new Error("Missing DTD notation name. " + this.debugInfo(name));
18 + }
19 + if (!value.pubID && !value.sysID) {
20 + throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
21 + }
22 + this.name = this.stringify.name(name);
23 + this.type = NodeType.NotationDeclaration;
24 + if (value.pubID != null) {
25 + this.pubID = this.stringify.dtdPubID(value.pubID);
26 + }
27 + if (value.sysID != null) {
28 + this.sysID = this.stringify.dtdSysID(value.sysID);
29 + }
30 + }
31 +
32 + Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
33 + get: function() {
34 + return this.pubID;
35 + }
36 + });
37 +
38 + Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
39 + get: function() {
40 + return this.sysID;
41 + }
42 + });
43 +
44 + XMLDTDNotation.prototype.toString = function(options) {
45 + return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
46 + };
47 +
48 + return XMLDTDNotation;
49 +
50 + })(XMLNode);
51 +
52 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLDeclaration, XMLNode, isObject,
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 +
7 + isObject = require('./Utility').isObject;
8 +
9 + XMLNode = require('./XMLNode');
10 +
11 + NodeType = require('./NodeType');
12 +
13 + module.exports = XMLDeclaration = (function(superClass) {
14 + extend(XMLDeclaration, superClass);
15 +
16 + function XMLDeclaration(parent, version, encoding, standalone) {
17 + var ref;
18 + XMLDeclaration.__super__.constructor.call(this, parent);
19 + if (isObject(version)) {
20 + ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
21 + }
22 + if (!version) {
23 + version = '1.0';
24 + }
25 + this.type = NodeType.Declaration;
26 + this.version = this.stringify.xmlVersion(version);
27 + if (encoding != null) {
28 + this.encoding = this.stringify.xmlEncoding(encoding);
29 + }
30 + if (standalone != null) {
31 + this.standalone = this.stringify.xmlStandalone(standalone);
32 + }
33 + }
34 +
35 + XMLDeclaration.prototype.toString = function(options) {
36 + return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
37 + };
38 +
39 + return XMLDeclaration;
40 +
41 + })(XMLNode);
42 +
43 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject,
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 +
7 + isObject = require('./Utility').isObject;
8 +
9 + XMLNode = require('./XMLNode');
10 +
11 + NodeType = require('./NodeType');
12 +
13 + XMLDTDAttList = require('./XMLDTDAttList');
14 +
15 + XMLDTDEntity = require('./XMLDTDEntity');
16 +
17 + XMLDTDElement = require('./XMLDTDElement');
18 +
19 + XMLDTDNotation = require('./XMLDTDNotation');
20 +
21 + XMLNamedNodeMap = require('./XMLNamedNodeMap');
22 +
23 + module.exports = XMLDocType = (function(superClass) {
24 + extend(XMLDocType, superClass);
25 +
26 + function XMLDocType(parent, pubID, sysID) {
27 + var child, i, len, ref, ref1, ref2;
28 + XMLDocType.__super__.constructor.call(this, parent);
29 + this.type = NodeType.DocType;
30 + if (parent.children) {
31 + ref = parent.children;
32 + for (i = 0, len = ref.length; i < len; i++) {
33 + child = ref[i];
34 + if (child.type === NodeType.Element) {
35 + this.name = child.name;
36 + break;
37 + }
38 + }
39 + }
40 + this.documentObject = parent;
41 + if (isObject(pubID)) {
42 + ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID;
43 + }
44 + if (sysID == null) {
45 + ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1];
46 + }
47 + if (pubID != null) {
48 + this.pubID = this.stringify.dtdPubID(pubID);
49 + }
50 + if (sysID != null) {
51 + this.sysID = this.stringify.dtdSysID(sysID);
52 + }
53 + }
54 +
55 + Object.defineProperty(XMLDocType.prototype, 'entities', {
56 + get: function() {
57 + var child, i, len, nodes, ref;
58 + nodes = {};
59 + ref = this.children;
60 + for (i = 0, len = ref.length; i < len; i++) {
61 + child = ref[i];
62 + if ((child.type === NodeType.EntityDeclaration) && !child.pe) {
63 + nodes[child.name] = child;
64 + }
65 + }
66 + return new XMLNamedNodeMap(nodes);
67 + }
68 + });
69 +
70 + Object.defineProperty(XMLDocType.prototype, 'notations', {
71 + get: function() {
72 + var child, i, len, nodes, ref;
73 + nodes = {};
74 + ref = this.children;
75 + for (i = 0, len = ref.length; i < len; i++) {
76 + child = ref[i];
77 + if (child.type === NodeType.NotationDeclaration) {
78 + nodes[child.name] = child;
79 + }
80 + }
81 + return new XMLNamedNodeMap(nodes);
82 + }
83 + });
84 +
85 + Object.defineProperty(XMLDocType.prototype, 'publicId', {
86 + get: function() {
87 + return this.pubID;
88 + }
89 + });
90 +
91 + Object.defineProperty(XMLDocType.prototype, 'systemId', {
92 + get: function() {
93 + return this.sysID;
94 + }
95 + });
96 +
97 + Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
98 + get: function() {
99 + throw new Error("This DOM method is not implemented." + this.debugInfo());
100 + }
101 + });
102 +
103 + XMLDocType.prototype.element = function(name, value) {
104 + var child;
105 + child = new XMLDTDElement(this, name, value);
106 + this.children.push(child);
107 + return this;
108 + };
109 +
110 + XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
111 + var child;
112 + child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
113 + this.children.push(child);
114 + return this;
115 + };
116 +
117 + XMLDocType.prototype.entity = function(name, value) {
118 + var child;
119 + child = new XMLDTDEntity(this, false, name, value);
120 + this.children.push(child);
121 + return this;
122 + };
123 +
124 + XMLDocType.prototype.pEntity = function(name, value) {
125 + var child;
126 + child = new XMLDTDEntity(this, true, name, value);
127 + this.children.push(child);
128 + return this;
129 + };
130 +
131 + XMLDocType.prototype.notation = function(name, value) {
132 + var child;
133 + child = new XMLDTDNotation(this, name, value);
134 + this.children.push(child);
135 + return this;
136 + };
137 +
138 + XMLDocType.prototype.toString = function(options) {
139 + return this.options.writer.docType(this, this.options.writer.filterOptions(options));
140 + };
141 +
142 + XMLDocType.prototype.ele = function(name, value) {
143 + return this.element(name, value);
144 + };
145 +
146 + XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
147 + return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
148 + };
149 +
150 + XMLDocType.prototype.ent = function(name, value) {
151 + return this.entity(name, value);
152 + };
153 +
154 + XMLDocType.prototype.pent = function(name, value) {
155 + return this.pEntity(name, value);
156 + };
157 +
158 + XMLDocType.prototype.not = function(name, value) {
159 + return this.notation(name, value);
160 + };
161 +
162 + XMLDocType.prototype.up = function() {
163 + return this.root() || this.documentObject;
164 + };
165 +
166 + XMLDocType.prototype.isEqualNode = function(node) {
167 + if (!XMLDocType.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
168 + return false;
169 + }
170 + if (node.name !== this.name) {
171 + return false;
172 + }
173 + if (node.publicId !== this.publicId) {
174 + return false;
175 + }
176 + if (node.systemId !== this.systemId) {
177 + return false;
178 + }
179 + return true;
180 + };
181 +
182 + return XMLDocType;
183 +
184 + })(XMLNode);
185 +
186 +}).call(this);
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 +
7 + isPlainObject = require('./Utility').isPlainObject;
8 +
9 + XMLDOMImplementation = require('./XMLDOMImplementation');
10 +
11 + XMLDOMConfiguration = require('./XMLDOMConfiguration');
12 +
13 + XMLNode = require('./XMLNode');
14 +
15 + NodeType = require('./NodeType');
16 +
17 + XMLStringifier = require('./XMLStringifier');
18 +
19 + XMLStringWriter = require('./XMLStringWriter');
20 +
21 + module.exports = XMLDocument = (function(superClass) {
22 + extend(XMLDocument, superClass);
23 +
24 + function XMLDocument(options) {
25 + XMLDocument.__super__.constructor.call(this, null);
26 + this.name = "#document";
27 + this.type = NodeType.Document;
28 + this.documentURI = null;
29 + this.domConfig = new XMLDOMConfiguration();
30 + options || (options = {});
31 + if (!options.writer) {
32 + options.writer = new XMLStringWriter();
33 + }
34 + this.options = options;
35 + this.stringify = new XMLStringifier(options);
36 + }
37 +
38 + Object.defineProperty(XMLDocument.prototype, 'implementation', {
39 + value: new XMLDOMImplementation()
40 + });
41 +
42 + Object.defineProperty(XMLDocument.prototype, 'doctype', {
43 + get: function() {
44 + var child, i, len, ref;
45 + ref = this.children;
46 + for (i = 0, len = ref.length; i < len; i++) {
47 + child = ref[i];
48 + if (child.type === NodeType.DocType) {
49 + return child;
50 + }
51 + }
52 + return null;
53 + }
54 + });
55 +
56 + Object.defineProperty(XMLDocument.prototype, 'documentElement', {
57 + get: function() {
58 + return this.rootObject || null;
59 + }
60 + });
61 +
62 + Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
63 + get: function() {
64 + return null;
65 + }
66 + });
67 +
68 + Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
69 + get: function() {
70 + return false;
71 + }
72 + });
73 +
74 + Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
75 + get: function() {
76 + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
77 + return this.children[0].encoding;
78 + } else {
79 + return null;
80 + }
81 + }
82 + });
83 +
84 + Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
85 + get: function() {
86 + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
87 + return this.children[0].standalone === 'yes';
88 + } else {
89 + return false;
90 + }
91 + }
92 + });
93 +
94 + Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
95 + get: function() {
96 + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
97 + return this.children[0].version;
98 + } else {
99 + return "1.0";
100 + }
101 + }
102 + });
103 +
104 + Object.defineProperty(XMLDocument.prototype, 'URL', {
105 + get: function() {
106 + return this.documentURI;
107 + }
108 + });
109 +
110 + Object.defineProperty(XMLDocument.prototype, 'origin', {
111 + get: function() {
112 + return null;
113 + }
114 + });
115 +
116 + Object.defineProperty(XMLDocument.prototype, 'compatMode', {
117 + get: function() {
118 + return null;
119 + }
120 + });
121 +
122 + Object.defineProperty(XMLDocument.prototype, 'characterSet', {
123 + get: function() {
124 + return null;
125 + }
126 + });
127 +
128 + Object.defineProperty(XMLDocument.prototype, 'contentType', {
129 + get: function() {
130 + return null;
131 + }
132 + });
133 +
134 + XMLDocument.prototype.end = function(writer) {
135 + var writerOptions;
136 + writerOptions = {};
137 + if (!writer) {
138 + writer = this.options.writer;
139 + } else if (isPlainObject(writer)) {
140 + writerOptions = writer;
141 + writer = this.options.writer;
142 + }
143 + return writer.document(this, writer.filterOptions(writerOptions));
144 + };
145 +
146 + XMLDocument.prototype.toString = function(options) {
147 + return this.options.writer.document(this, this.options.writer.filterOptions(options));
148 + };
149 +
150 + XMLDocument.prototype.createElement = function(tagName) {
151 + throw new Error("This DOM method is not implemented." + this.debugInfo());
152 + };
153 +
154 + XMLDocument.prototype.createDocumentFragment = function() {
155 + throw new Error("This DOM method is not implemented." + this.debugInfo());
156 + };
157 +
158 + XMLDocument.prototype.createTextNode = function(data) {
159 + throw new Error("This DOM method is not implemented." + this.debugInfo());
160 + };
161 +
162 + XMLDocument.prototype.createComment = function(data) {
163 + throw new Error("This DOM method is not implemented." + this.debugInfo());
164 + };
165 +
166 + XMLDocument.prototype.createCDATASection = function(data) {
167 + throw new Error("This DOM method is not implemented." + this.debugInfo());
168 + };
169 +
170 + XMLDocument.prototype.createProcessingInstruction = function(target, data) {
171 + throw new Error("This DOM method is not implemented." + this.debugInfo());
172 + };
173 +
174 + XMLDocument.prototype.createAttribute = function(name) {
175 + throw new Error("This DOM method is not implemented." + this.debugInfo());
176 + };
177 +
178 + XMLDocument.prototype.createEntityReference = function(name) {
179 + throw new Error("This DOM method is not implemented." + this.debugInfo());
180 + };
181 +
182 + XMLDocument.prototype.getElementsByTagName = function(tagname) {
183 + throw new Error("This DOM method is not implemented." + this.debugInfo());
184 + };
185 +
186 + XMLDocument.prototype.importNode = function(importedNode, deep) {
187 + throw new Error("This DOM method is not implemented." + this.debugInfo());
188 + };
189 +
190 + XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) {
191 + throw new Error("This DOM method is not implemented." + this.debugInfo());
192 + };
193 +
194 + XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) {
195 + throw new Error("This DOM method is not implemented." + this.debugInfo());
196 + };
197 +
198 + XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
199 + throw new Error("This DOM method is not implemented." + this.debugInfo());
200 + };
201 +
202 + XMLDocument.prototype.getElementById = function(elementId) {
203 + throw new Error("This DOM method is not implemented." + this.debugInfo());
204 + };
205 +
206 + XMLDocument.prototype.adoptNode = function(source) {
207 + throw new Error("This DOM method is not implemented." + this.debugInfo());
208 + };
209 +
210 + XMLDocument.prototype.normalizeDocument = function() {
211 + throw new Error("This DOM method is not implemented." + this.debugInfo());
212 + };
213 +
214 + XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) {
215 + throw new Error("This DOM method is not implemented." + this.debugInfo());
216 + };
217 +
218 + XMLDocument.prototype.getElementsByClassName = function(classNames) {
219 + throw new Error("This DOM method is not implemented." + this.debugInfo());
220 + };
221 +
222 + XMLDocument.prototype.createEvent = function(eventInterface) {
223 + throw new Error("This DOM method is not implemented." + this.debugInfo());
224 + };
225 +
226 + XMLDocument.prototype.createRange = function() {
227 + throw new Error("This DOM method is not implemented." + this.debugInfo());
228 + };
229 +
230 + XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) {
231 + throw new Error("This DOM method is not implemented." + this.debugInfo());
232 + };
233 +
234 + XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) {
235 + throw new Error("This DOM method is not implemented." + this.debugInfo());
236 + };
237 +
238 + return XMLDocument;
239 +
240 + })(XMLNode);
241 +
242 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject, ref,
4 + hasProp = {}.hasOwnProperty;
5 +
6 + ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue;
7 +
8 + NodeType = require('./NodeType');
9 +
10 + XMLDocument = require('./XMLDocument');
11 +
12 + XMLElement = require('./XMLElement');
13 +
14 + XMLCData = require('./XMLCData');
15 +
16 + XMLComment = require('./XMLComment');
17 +
18 + XMLRaw = require('./XMLRaw');
19 +
20 + XMLText = require('./XMLText');
21 +
22 + XMLProcessingInstruction = require('./XMLProcessingInstruction');
23 +
24 + XMLDeclaration = require('./XMLDeclaration');
25 +
26 + XMLDocType = require('./XMLDocType');
27 +
28 + XMLDTDAttList = require('./XMLDTDAttList');
29 +
30 + XMLDTDEntity = require('./XMLDTDEntity');
31 +
32 + XMLDTDElement = require('./XMLDTDElement');
33 +
34 + XMLDTDNotation = require('./XMLDTDNotation');
35 +
36 + XMLAttribute = require('./XMLAttribute');
37 +
38 + XMLStringifier = require('./XMLStringifier');
39 +
40 + XMLStringWriter = require('./XMLStringWriter');
41 +
42 + WriterState = require('./WriterState');
43 +
44 + module.exports = XMLDocumentCB = (function() {
45 + function XMLDocumentCB(options, onData, onEnd) {
46 + var writerOptions;
47 + this.name = "?xml";
48 + this.type = NodeType.Document;
49 + options || (options = {});
50 + writerOptions = {};
51 + if (!options.writer) {
52 + options.writer = new XMLStringWriter();
53 + } else if (isPlainObject(options.writer)) {
54 + writerOptions = options.writer;
55 + options.writer = new XMLStringWriter();
56 + }
57 + this.options = options;
58 + this.writer = options.writer;
59 + this.writerOptions = this.writer.filterOptions(writerOptions);
60 + this.stringify = new XMLStringifier(options);
61 + this.onDataCallback = onData || function() {};
62 + this.onEndCallback = onEnd || function() {};
63 + this.currentNode = null;
64 + this.currentLevel = -1;
65 + this.openTags = {};
66 + this.documentStarted = false;
67 + this.documentCompleted = false;
68 + this.root = null;
69 + }
70 +
71 + XMLDocumentCB.prototype.createChildNode = function(node) {
72 + var att, attName, attributes, child, i, len, ref1, ref2;
73 + switch (node.type) {
74 + case NodeType.CData:
75 + this.cdata(node.value);
76 + break;
77 + case NodeType.Comment:
78 + this.comment(node.value);
79 + break;
80 + case NodeType.Element:
81 + attributes = {};
82 + ref1 = node.attribs;
83 + for (attName in ref1) {
84 + if (!hasProp.call(ref1, attName)) continue;
85 + att = ref1[attName];
86 + attributes[attName] = att.value;
87 + }
88 + this.node(node.name, attributes);
89 + break;
90 + case NodeType.Dummy:
91 + this.dummy();
92 + break;
93 + case NodeType.Raw:
94 + this.raw(node.value);
95 + break;
96 + case NodeType.Text:
97 + this.text(node.value);
98 + break;
99 + case NodeType.ProcessingInstruction:
100 + this.instruction(node.target, node.value);
101 + break;
102 + default:
103 + throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
104 + }
105 + ref2 = node.children;
106 + for (i = 0, len = ref2.length; i < len; i++) {
107 + child = ref2[i];
108 + this.createChildNode(child);
109 + if (child.type === NodeType.Element) {
110 + this.up();
111 + }
112 + }
113 + return this;
114 + };
115 +
116 + XMLDocumentCB.prototype.dummy = function() {
117 + return this;
118 + };
119 +
120 + XMLDocumentCB.prototype.node = function(name, attributes, text) {
121 + var ref1;
122 + if (name == null) {
123 + throw new Error("Missing node name.");
124 + }
125 + if (this.root && this.currentLevel === -1) {
126 + throw new Error("Document can only have one root node. " + this.debugInfo(name));
127 + }
128 + this.openCurrent();
129 + name = getValue(name);
130 + if (attributes == null) {
131 + attributes = {};
132 + }
133 + attributes = getValue(attributes);
134 + if (!isObject(attributes)) {
135 + ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
136 + }
137 + this.currentNode = new XMLElement(this, name, attributes);
138 + this.currentNode.children = false;
139 + this.currentLevel++;
140 + this.openTags[this.currentLevel] = this.currentNode;
141 + if (text != null) {
142 + this.text(text);
143 + }
144 + return this;
145 + };
146 +
147 + XMLDocumentCB.prototype.element = function(name, attributes, text) {
148 + var child, i, len, oldValidationFlag, ref1, root;
149 + if (this.currentNode && this.currentNode.type === NodeType.DocType) {
150 + this.dtdElement.apply(this, arguments);
151 + } else {
152 + if (Array.isArray(name) || isObject(name) || isFunction(name)) {
153 + oldValidationFlag = this.options.noValidation;
154 + this.options.noValidation = true;
155 + root = new XMLDocument(this.options).element('TEMP_ROOT');
156 + root.element(name);
157 + this.options.noValidation = oldValidationFlag;
158 + ref1 = root.children;
159 + for (i = 0, len = ref1.length; i < len; i++) {
160 + child = ref1[i];
161 + this.createChildNode(child);
162 + if (child.type === NodeType.Element) {
163 + this.up();
164 + }
165 + }
166 + } else {
167 + this.node(name, attributes, text);
168 + }
169 + }
170 + return this;
171 + };
172 +
173 + XMLDocumentCB.prototype.attribute = function(name, value) {
174 + var attName, attValue;
175 + if (!this.currentNode || this.currentNode.children) {
176 + throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
177 + }
178 + if (name != null) {
179 + name = getValue(name);
180 + }
181 + if (isObject(name)) {
182 + for (attName in name) {
183 + if (!hasProp.call(name, attName)) continue;
184 + attValue = name[attName];
185 + this.attribute(attName, attValue);
186 + }
187 + } else {
188 + if (isFunction(value)) {
189 + value = value.apply();
190 + }
191 + if (this.options.keepNullAttributes && (value == null)) {
192 + this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
193 + } else if (value != null) {
194 + this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
195 + }
196 + }
197 + return this;
198 + };
199 +
200 + XMLDocumentCB.prototype.text = function(value) {
201 + var node;
202 + this.openCurrent();
203 + node = new XMLText(this, value);
204 + this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
205 + return this;
206 + };
207 +
208 + XMLDocumentCB.prototype.cdata = function(value) {
209 + var node;
210 + this.openCurrent();
211 + node = new XMLCData(this, value);
212 + this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
213 + return this;
214 + };
215 +
216 + XMLDocumentCB.prototype.comment = function(value) {
217 + var node;
218 + this.openCurrent();
219 + node = new XMLComment(this, value);
220 + this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
221 + return this;
222 + };
223 +
224 + XMLDocumentCB.prototype.raw = function(value) {
225 + var node;
226 + this.openCurrent();
227 + node = new XMLRaw(this, value);
228 + this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
229 + return this;
230 + };
231 +
232 + XMLDocumentCB.prototype.instruction = function(target, value) {
233 + var i, insTarget, insValue, len, node;
234 + this.openCurrent();
235 + if (target != null) {
236 + target = getValue(target);
237 + }
238 + if (value != null) {
239 + value = getValue(value);
240 + }
241 + if (Array.isArray(target)) {
242 + for (i = 0, len = target.length; i < len; i++) {
243 + insTarget = target[i];
244 + this.instruction(insTarget);
245 + }
246 + } else if (isObject(target)) {
247 + for (insTarget in target) {
248 + if (!hasProp.call(target, insTarget)) continue;
249 + insValue = target[insTarget];
250 + this.instruction(insTarget, insValue);
251 + }
252 + } else {
253 + if (isFunction(value)) {
254 + value = value.apply();
255 + }
256 + node = new XMLProcessingInstruction(this, target, value);
257 + this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
258 + }
259 + return this;
260 + };
261 +
262 + XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
263 + var node;
264 + this.openCurrent();
265 + if (this.documentStarted) {
266 + throw new Error("declaration() must be the first node.");
267 + }
268 + node = new XMLDeclaration(this, version, encoding, standalone);
269 + this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
270 + return this;
271 + };
272 +
273 + XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
274 + this.openCurrent();
275 + if (root == null) {
276 + throw new Error("Missing root node name.");
277 + }
278 + if (this.root) {
279 + throw new Error("dtd() must come before the root node.");
280 + }
281 + this.currentNode = new XMLDocType(this, pubID, sysID);
282 + this.currentNode.rootNodeName = root;
283 + this.currentNode.children = false;
284 + this.currentLevel++;
285 + this.openTags[this.currentLevel] = this.currentNode;
286 + return this;
287 + };
288 +
289 + XMLDocumentCB.prototype.dtdElement = function(name, value) {
290 + var node;
291 + this.openCurrent();
292 + node = new XMLDTDElement(this, name, value);
293 + this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
294 + return this;
295 + };
296 +
297 + XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
298 + var node;
299 + this.openCurrent();
300 + node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
301 + this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
302 + return this;
303 + };
304 +
305 + XMLDocumentCB.prototype.entity = function(name, value) {
306 + var node;
307 + this.openCurrent();
308 + node = new XMLDTDEntity(this, false, name, value);
309 + this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
310 + return this;
311 + };
312 +
313 + XMLDocumentCB.prototype.pEntity = function(name, value) {
314 + var node;
315 + this.openCurrent();
316 + node = new XMLDTDEntity(this, true, name, value);
317 + this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
318 + return this;
319 + };
320 +
321 + XMLDocumentCB.prototype.notation = function(name, value) {
322 + var node;
323 + this.openCurrent();
324 + node = new XMLDTDNotation(this, name, value);
325 + this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
326 + return this;
327 + };
328 +
329 + XMLDocumentCB.prototype.up = function() {
330 + if (this.currentLevel < 0) {
331 + throw new Error("The document node has no parent.");
332 + }
333 + if (this.currentNode) {
334 + if (this.currentNode.children) {
335 + this.closeNode(this.currentNode);
336 + } else {
337 + this.openNode(this.currentNode);
338 + }
339 + this.currentNode = null;
340 + } else {
341 + this.closeNode(this.openTags[this.currentLevel]);
342 + }
343 + delete this.openTags[this.currentLevel];
344 + this.currentLevel--;
345 + return this;
346 + };
347 +
348 + XMLDocumentCB.prototype.end = function() {
349 + while (this.currentLevel >= 0) {
350 + this.up();
351 + }
352 + return this.onEnd();
353 + };
354 +
355 + XMLDocumentCB.prototype.openCurrent = function() {
356 + if (this.currentNode) {
357 + this.currentNode.children = true;
358 + return this.openNode(this.currentNode);
359 + }
360 + };
361 +
362 + XMLDocumentCB.prototype.openNode = function(node) {
363 + var att, chunk, name, ref1;
364 + if (!node.isOpen) {
365 + if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
366 + this.root = node;
367 + }
368 + chunk = '';
369 + if (node.type === NodeType.Element) {
370 + this.writerOptions.state = WriterState.OpenTag;
371 + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
372 + ref1 = node.attribs;
373 + for (name in ref1) {
374 + if (!hasProp.call(ref1, name)) continue;
375 + att = ref1[name];
376 + chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
377 + }
378 + chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
379 + this.writerOptions.state = WriterState.InsideTag;
380 + } else {
381 + this.writerOptions.state = WriterState.OpenTag;
382 + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName;
383 + if (node.pubID && node.sysID) {
384 + chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
385 + } else if (node.sysID) {
386 + chunk += ' SYSTEM "' + node.sysID + '"';
387 + }
388 + if (node.children) {
389 + chunk += ' [';
390 + this.writerOptions.state = WriterState.InsideTag;
391 + } else {
392 + this.writerOptions.state = WriterState.CloseTag;
393 + chunk += '>';
394 + }
395 + chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
396 + }
397 + this.onData(chunk, this.currentLevel);
398 + return node.isOpen = true;
399 + }
400 + };
401 +
402 + XMLDocumentCB.prototype.closeNode = function(node) {
403 + var chunk;
404 + if (!node.isClosed) {
405 + chunk = '';
406 + this.writerOptions.state = WriterState.CloseTag;
407 + if (node.type === NodeType.Element) {
408 + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '</' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
409 + } else {
410 + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
411 + }
412 + this.writerOptions.state = WriterState.None;
413 + this.onData(chunk, this.currentLevel);
414 + return node.isClosed = true;
415 + }
416 + };
417 +
418 + XMLDocumentCB.prototype.onData = function(chunk, level) {
419 + this.documentStarted = true;
420 + return this.onDataCallback(chunk, level + 1);
421 + };
422 +
423 + XMLDocumentCB.prototype.onEnd = function() {
424 + this.documentCompleted = true;
425 + return this.onEndCallback();
426 + };
427 +
428 + XMLDocumentCB.prototype.debugInfo = function(name) {
429 + if (name == null) {
430 + return "";
431 + } else {
432 + return "node: <" + name + ">";
433 + }
434 + };
435 +
436 + XMLDocumentCB.prototype.ele = function() {
437 + return this.element.apply(this, arguments);
438 + };
439 +
440 + XMLDocumentCB.prototype.nod = function(name, attributes, text) {
441 + return this.node(name, attributes, text);
442 + };
443 +
444 + XMLDocumentCB.prototype.txt = function(value) {
445 + return this.text(value);
446 + };
447 +
448 + XMLDocumentCB.prototype.dat = function(value) {
449 + return this.cdata(value);
450 + };
451 +
452 + XMLDocumentCB.prototype.com = function(value) {
453 + return this.comment(value);
454 + };
455 +
456 + XMLDocumentCB.prototype.ins = function(target, value) {
457 + return this.instruction(target, value);
458 + };
459 +
460 + XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
461 + return this.declaration(version, encoding, standalone);
462 + };
463 +
464 + XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
465 + return this.doctype(root, pubID, sysID);
466 + };
467 +
468 + XMLDocumentCB.prototype.e = function(name, attributes, text) {
469 + return this.element(name, attributes, text);
470 + };
471 +
472 + XMLDocumentCB.prototype.n = function(name, attributes, text) {
473 + return this.node(name, attributes, text);
474 + };
475 +
476 + XMLDocumentCB.prototype.t = function(value) {
477 + return this.text(value);
478 + };
479 +
480 + XMLDocumentCB.prototype.d = function(value) {
481 + return this.cdata(value);
482 + };
483 +
484 + XMLDocumentCB.prototype.c = function(value) {
485 + return this.comment(value);
486 + };
487 +
488 + XMLDocumentCB.prototype.r = function(value) {
489 + return this.raw(value);
490 + };
491 +
492 + XMLDocumentCB.prototype.i = function(target, value) {
493 + return this.instruction(target, value);
494 + };
495 +
496 + XMLDocumentCB.prototype.att = function() {
497 + if (this.currentNode && this.currentNode.type === NodeType.DocType) {
498 + return this.attList.apply(this, arguments);
499 + } else {
500 + return this.attribute.apply(this, arguments);
501 + }
502 + };
503 +
504 + XMLDocumentCB.prototype.a = function() {
505 + if (this.currentNode && this.currentNode.type === NodeType.DocType) {
506 + return this.attList.apply(this, arguments);
507 + } else {
508 + return this.attribute.apply(this, arguments);
509 + }
510 + };
511 +
512 + XMLDocumentCB.prototype.ent = function(name, value) {
513 + return this.entity(name, value);
514 + };
515 +
516 + XMLDocumentCB.prototype.pent = function(name, value) {
517 + return this.pEntity(name, value);
518 + };
519 +
520 + XMLDocumentCB.prototype.not = function(name, value) {
521 + return this.notation(name, value);
522 + };
523 +
524 + return XMLDocumentCB;
525 +
526 + })();
527 +
528 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLDocumentFragment, XMLNode,
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 +
7 + XMLNode = require('./XMLNode');
8 +
9 + NodeType = require('./NodeType');
10 +
11 + module.exports = XMLDocumentFragment = (function(superClass) {
12 + extend(XMLDocumentFragment, superClass);
13 +
14 + function XMLDocumentFragment() {
15 + XMLDocumentFragment.__super__.constructor.call(this, null);
16 + this.name = "#document-fragment";
17 + this.type = NodeType.DocumentFragment;
18 + }
19 +
20 + return XMLDocumentFragment;
21 +
22 + })(XMLNode);
23 +
24 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLDummy, XMLNode,
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 +
7 + XMLNode = require('./XMLNode');
8 +
9 + NodeType = require('./NodeType');
10 +
11 + module.exports = XMLDummy = (function(superClass) {
12 + extend(XMLDummy, superClass);
13 +
14 + function XMLDummy(parent) {
15 + XMLDummy.__super__.constructor.call(this, parent);
16 + this.type = NodeType.Dummy;
17 + }
18 +
19 + XMLDummy.prototype.clone = function() {
20 + return Object.create(this);
21 + };
22 +
23 + XMLDummy.prototype.toString = function(options) {
24 + return '';
25 + };
26 +
27 + return XMLDummy;
28 +
29 + })(XMLNode);
30 +
31 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject, ref,
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 +
7 + ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
8 +
9 + XMLNode = require('./XMLNode');
10 +
11 + NodeType = require('./NodeType');
12 +
13 + XMLAttribute = require('./XMLAttribute');
14 +
15 + XMLNamedNodeMap = require('./XMLNamedNodeMap');
16 +
17 + module.exports = XMLElement = (function(superClass) {
18 + extend(XMLElement, superClass);
19 +
20 + function XMLElement(parent, name, attributes) {
21 + var child, j, len, ref1;
22 + XMLElement.__super__.constructor.call(this, parent);
23 + if (name == null) {
24 + throw new Error("Missing element name. " + this.debugInfo());
25 + }
26 + this.name = this.stringify.name(name);
27 + this.type = NodeType.Element;
28 + this.attribs = {};
29 + this.schemaTypeInfo = null;
30 + if (attributes != null) {
31 + this.attribute(attributes);
32 + }
33 + if (parent.type === NodeType.Document) {
34 + this.isRoot = true;
35 + this.documentObject = parent;
36 + parent.rootObject = this;
37 + if (parent.children) {
38 + ref1 = parent.children;
39 + for (j = 0, len = ref1.length; j < len; j++) {
40 + child = ref1[j];
41 + if (child.type === NodeType.DocType) {
42 + child.name = this.name;
43 + break;
44 + }
45 + }
46 + }
47 + }
48 + }
49 +
50 + Object.defineProperty(XMLElement.prototype, 'tagName', {
51 + get: function() {
52 + return this.name;
53 + }
54 + });
55 +
56 + Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
57 + get: function() {
58 + return '';
59 + }
60 + });
61 +
62 + Object.defineProperty(XMLElement.prototype, 'prefix', {
63 + get: function() {
64 + return '';
65 + }
66 + });
67 +
68 + Object.defineProperty(XMLElement.prototype, 'localName', {
69 + get: function() {
70 + return this.name;
71 + }
72 + });
73 +
74 + Object.defineProperty(XMLElement.prototype, 'id', {
75 + get: function() {
76 + throw new Error("This DOM method is not implemented." + this.debugInfo());
77 + }
78 + });
79 +
80 + Object.defineProperty(XMLElement.prototype, 'className', {
81 + get: function() {
82 + throw new Error("This DOM method is not implemented." + this.debugInfo());
83 + }
84 + });
85 +
86 + Object.defineProperty(XMLElement.prototype, 'classList', {
87 + get: function() {
88 + throw new Error("This DOM method is not implemented." + this.debugInfo());
89 + }
90 + });
91 +
92 + Object.defineProperty(XMLElement.prototype, 'attributes', {
93 + get: function() {
94 + if (!this.attributeMap || !this.attributeMap.nodes) {
95 + this.attributeMap = new XMLNamedNodeMap(this.attribs);
96 + }
97 + return this.attributeMap;
98 + }
99 + });
100 +
101 + XMLElement.prototype.clone = function() {
102 + var att, attName, clonedSelf, ref1;
103 + clonedSelf = Object.create(this);
104 + if (clonedSelf.isRoot) {
105 + clonedSelf.documentObject = null;
106 + }
107 + clonedSelf.attribs = {};
108 + ref1 = this.attribs;
109 + for (attName in ref1) {
110 + if (!hasProp.call(ref1, attName)) continue;
111 + att = ref1[attName];
112 + clonedSelf.attribs[attName] = att.clone();
113 + }
114 + clonedSelf.children = [];
115 + this.children.forEach(function(child) {
116 + var clonedChild;
117 + clonedChild = child.clone();
118 + clonedChild.parent = clonedSelf;
119 + return clonedSelf.children.push(clonedChild);
120 + });
121 + return clonedSelf;
122 + };
123 +
124 + XMLElement.prototype.attribute = function(name, value) {
125 + var attName, attValue;
126 + if (name != null) {
127 + name = getValue(name);
128 + }
129 + if (isObject(name)) {
130 + for (attName in name) {
131 + if (!hasProp.call(name, attName)) continue;
132 + attValue = name[attName];
133 + this.attribute(attName, attValue);
134 + }
135 + } else {
136 + if (isFunction(value)) {
137 + value = value.apply();
138 + }
139 + if (this.options.keepNullAttributes && (value == null)) {
140 + this.attribs[name] = new XMLAttribute(this, name, "");
141 + } else if (value != null) {
142 + this.attribs[name] = new XMLAttribute(this, name, value);
143 + }
144 + }
145 + return this;
146 + };
147 +
148 + XMLElement.prototype.removeAttribute = function(name) {
149 + var attName, j, len;
150 + if (name == null) {
151 + throw new Error("Missing attribute name. " + this.debugInfo());
152 + }
153 + name = getValue(name);
154 + if (Array.isArray(name)) {
155 + for (j = 0, len = name.length; j < len; j++) {
156 + attName = name[j];
157 + delete this.attribs[attName];
158 + }
159 + } else {
160 + delete this.attribs[name];
161 + }
162 + return this;
163 + };
164 +
165 + XMLElement.prototype.toString = function(options) {
166 + return this.options.writer.element(this, this.options.writer.filterOptions(options));
167 + };
168 +
169 + XMLElement.prototype.att = function(name, value) {
170 + return this.attribute(name, value);
171 + };
172 +
173 + XMLElement.prototype.a = function(name, value) {
174 + return this.attribute(name, value);
175 + };
176 +
177 + XMLElement.prototype.getAttribute = function(name) {
178 + if (this.attribs.hasOwnProperty(name)) {
179 + return this.attribs[name].value;
180 + } else {
181 + return null;
182 + }
183 + };
184 +
185 + XMLElement.prototype.setAttribute = function(name, value) {
186 + throw new Error("This DOM method is not implemented." + this.debugInfo());
187 + };
188 +
189 + XMLElement.prototype.getAttributeNode = function(name) {
190 + if (this.attribs.hasOwnProperty(name)) {
191 + return this.attribs[name];
192 + } else {
193 + return null;
194 + }
195 + };
196 +
197 + XMLElement.prototype.setAttributeNode = function(newAttr) {
198 + throw new Error("This DOM method is not implemented." + this.debugInfo());
199 + };
200 +
201 + XMLElement.prototype.removeAttributeNode = function(oldAttr) {
202 + throw new Error("This DOM method is not implemented." + this.debugInfo());
203 + };
204 +
205 + XMLElement.prototype.getElementsByTagName = function(name) {
206 + throw new Error("This DOM method is not implemented." + this.debugInfo());
207 + };
208 +
209 + XMLElement.prototype.getAttributeNS = function(namespaceURI, localName) {
210 + throw new Error("This DOM method is not implemented." + this.debugInfo());
211 + };
212 +
213 + XMLElement.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) {
214 + throw new Error("This DOM method is not implemented." + this.debugInfo());
215 + };
216 +
217 + XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) {
218 + throw new Error("This DOM method is not implemented." + this.debugInfo());
219 + };
220 +
221 + XMLElement.prototype.getAttributeNodeNS = function(namespaceURI, localName) {
222 + throw new Error("This DOM method is not implemented." + this.debugInfo());
223 + };
224 +
225 + XMLElement.prototype.setAttributeNodeNS = function(newAttr) {
226 + throw new Error("This DOM method is not implemented." + this.debugInfo());
227 + };
228 +
229 + XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
230 + throw new Error("This DOM method is not implemented." + this.debugInfo());
231 + };
232 +
233 + XMLElement.prototype.hasAttribute = function(name) {
234 + return this.attribs.hasOwnProperty(name);
235 + };
236 +
237 + XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) {
238 + throw new Error("This DOM method is not implemented." + this.debugInfo());
239 + };
240 +
241 + XMLElement.prototype.setIdAttribute = function(name, isId) {
242 + if (this.attribs.hasOwnProperty(name)) {
243 + return this.attribs[name].isId;
244 + } else {
245 + return isId;
246 + }
247 + };
248 +
249 + XMLElement.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) {
250 + throw new Error("This DOM method is not implemented." + this.debugInfo());
251 + };
252 +
253 + XMLElement.prototype.setIdAttributeNode = function(idAttr, isId) {
254 + throw new Error("This DOM method is not implemented." + this.debugInfo());
255 + };
256 +
257 + XMLElement.prototype.getElementsByTagName = function(tagname) {
258 + throw new Error("This DOM method is not implemented." + this.debugInfo());
259 + };
260 +
261 + XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
262 + throw new Error("This DOM method is not implemented." + this.debugInfo());
263 + };
264 +
265 + XMLElement.prototype.getElementsByClassName = function(classNames) {
266 + throw new Error("This DOM method is not implemented." + this.debugInfo());
267 + };
268 +
269 + XMLElement.prototype.isEqualNode = function(node) {
270 + var i, j, ref1;
271 + if (!XMLElement.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
272 + return false;
273 + }
274 + if (node.namespaceURI !== this.namespaceURI) {
275 + return false;
276 + }
277 + if (node.prefix !== this.prefix) {
278 + return false;
279 + }
280 + if (node.localName !== this.localName) {
281 + return false;
282 + }
283 + if (node.attribs.length !== this.attribs.length) {
284 + return false;
285 + }
286 + for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) {
287 + if (!this.attribs[i].isEqualNode(node.attribs[i])) {
288 + return false;
289 + }
290 + }
291 + return true;
292 + };
293 +
294 + return XMLElement;
295 +
296 + })(XMLNode);
297 +
298 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var XMLNamedNodeMap;
4 +
5 + module.exports = XMLNamedNodeMap = (function() {
6 + function XMLNamedNodeMap(nodes) {
7 + this.nodes = nodes;
8 + }
9 +
10 + Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
11 + get: function() {
12 + return Object.keys(this.nodes).length || 0;
13 + }
14 + });
15 +
16 + XMLNamedNodeMap.prototype.clone = function() {
17 + return this.nodes = null;
18 + };
19 +
20 + XMLNamedNodeMap.prototype.getNamedItem = function(name) {
21 + return this.nodes[name];
22 + };
23 +
24 + XMLNamedNodeMap.prototype.setNamedItem = function(node) {
25 + var oldNode;
26 + oldNode = this.nodes[node.nodeName];
27 + this.nodes[node.nodeName] = node;
28 + return oldNode || null;
29 + };
30 +
31 + XMLNamedNodeMap.prototype.removeNamedItem = function(name) {
32 + var oldNode;
33 + oldNode = this.nodes[name];
34 + delete this.nodes[name];
35 + return oldNode || null;
36 + };
37 +
38 + XMLNamedNodeMap.prototype.item = function(index) {
39 + return this.nodes[Object.keys(this.nodes)[index]] || null;
40 + };
41 +
42 + XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) {
43 + throw new Error("This DOM method is not implemented.");
44 + };
45 +
46 + XMLNamedNodeMap.prototype.setNamedItemNS = function(node) {
47 + throw new Error("This DOM method is not implemented.");
48 + };
49 +
50 + XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) {
51 + throw new Error("This DOM method is not implemented.");
52 + };
53 +
54 + return XMLNamedNodeMap;
55 +
56 + })();
57 +
58 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1,
4 + hasProp = {}.hasOwnProperty;
5 +
6 + ref1 = require('./Utility'), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue;
7 +
8 + XMLElement = null;
9 +
10 + XMLCData = null;
11 +
12 + XMLComment = null;
13 +
14 + XMLDeclaration = null;
15 +
16 + XMLDocType = null;
17 +
18 + XMLRaw = null;
19 +
20 + XMLText = null;
21 +
22 + XMLProcessingInstruction = null;
23 +
24 + XMLDummy = null;
25 +
26 + NodeType = null;
27 +
28 + XMLNodeList = null;
29 +
30 + XMLNamedNodeMap = null;
31 +
32 + DocumentPosition = null;
33 +
34 + module.exports = XMLNode = (function() {
35 + function XMLNode(parent1) {
36 + this.parent = parent1;
37 + if (this.parent) {
38 + this.options = this.parent.options;
39 + this.stringify = this.parent.stringify;
40 + }
41 + this.value = null;
42 + this.children = [];
43 + this.baseURI = null;
44 + if (!XMLElement) {
45 + XMLElement = require('./XMLElement');
46 + XMLCData = require('./XMLCData');
47 + XMLComment = require('./XMLComment');
48 + XMLDeclaration = require('./XMLDeclaration');
49 + XMLDocType = require('./XMLDocType');
50 + XMLRaw = require('./XMLRaw');
51 + XMLText = require('./XMLText');
52 + XMLProcessingInstruction = require('./XMLProcessingInstruction');
53 + XMLDummy = require('./XMLDummy');
54 + NodeType = require('./NodeType');
55 + XMLNodeList = require('./XMLNodeList');
56 + XMLNamedNodeMap = require('./XMLNamedNodeMap');
57 + DocumentPosition = require('./DocumentPosition');
58 + }
59 + }
60 +
61 + Object.defineProperty(XMLNode.prototype, 'nodeName', {
62 + get: function() {
63 + return this.name;
64 + }
65 + });
66 +
67 + Object.defineProperty(XMLNode.prototype, 'nodeType', {
68 + get: function() {
69 + return this.type;
70 + }
71 + });
72 +
73 + Object.defineProperty(XMLNode.prototype, 'nodeValue', {
74 + get: function() {
75 + return this.value;
76 + }
77 + });
78 +
79 + Object.defineProperty(XMLNode.prototype, 'parentNode', {
80 + get: function() {
81 + return this.parent;
82 + }
83 + });
84 +
85 + Object.defineProperty(XMLNode.prototype, 'childNodes', {
86 + get: function() {
87 + if (!this.childNodeList || !this.childNodeList.nodes) {
88 + this.childNodeList = new XMLNodeList(this.children);
89 + }
90 + return this.childNodeList;
91 + }
92 + });
93 +
94 + Object.defineProperty(XMLNode.prototype, 'firstChild', {
95 + get: function() {
96 + return this.children[0] || null;
97 + }
98 + });
99 +
100 + Object.defineProperty(XMLNode.prototype, 'lastChild', {
101 + get: function() {
102 + return this.children[this.children.length - 1] || null;
103 + }
104 + });
105 +
106 + Object.defineProperty(XMLNode.prototype, 'previousSibling', {
107 + get: function() {
108 + var i;
109 + i = this.parent.children.indexOf(this);
110 + return this.parent.children[i - 1] || null;
111 + }
112 + });
113 +
114 + Object.defineProperty(XMLNode.prototype, 'nextSibling', {
115 + get: function() {
116 + var i;
117 + i = this.parent.children.indexOf(this);
118 + return this.parent.children[i + 1] || null;
119 + }
120 + });
121 +
122 + Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
123 + get: function() {
124 + return this.document() || null;
125 + }
126 + });
127 +
128 + Object.defineProperty(XMLNode.prototype, 'textContent', {
129 + get: function() {
130 + var child, j, len, ref2, str;
131 + if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
132 + str = '';
133 + ref2 = this.children;
134 + for (j = 0, len = ref2.length; j < len; j++) {
135 + child = ref2[j];
136 + if (child.textContent) {
137 + str += child.textContent;
138 + }
139 + }
140 + return str;
141 + } else {
142 + return null;
143 + }
144 + },
145 + set: function(value) {
146 + throw new Error("This DOM method is not implemented." + this.debugInfo());
147 + }
148 + });
149 +
150 + XMLNode.prototype.setParent = function(parent) {
151 + var child, j, len, ref2, results;
152 + this.parent = parent;
153 + if (parent) {
154 + this.options = parent.options;
155 + this.stringify = parent.stringify;
156 + }
157 + ref2 = this.children;
158 + results = [];
159 + for (j = 0, len = ref2.length; j < len; j++) {
160 + child = ref2[j];
161 + results.push(child.setParent(this));
162 + }
163 + return results;
164 + };
165 +
166 + XMLNode.prototype.element = function(name, attributes, text) {
167 + var childNode, item, j, k, key, lastChild, len, len1, ref2, ref3, val;
168 + lastChild = null;
169 + if (attributes === null && (text == null)) {
170 + ref2 = [{}, null], attributes = ref2[0], text = ref2[1];
171 + }
172 + if (attributes == null) {
173 + attributes = {};
174 + }
175 + attributes = getValue(attributes);
176 + if (!isObject(attributes)) {
177 + ref3 = [attributes, text], text = ref3[0], attributes = ref3[1];
178 + }
179 + if (name != null) {
180 + name = getValue(name);
181 + }
182 + if (Array.isArray(name)) {
183 + for (j = 0, len = name.length; j < len; j++) {
184 + item = name[j];
185 + lastChild = this.element(item);
186 + }
187 + } else if (isFunction(name)) {
188 + lastChild = this.element(name.apply());
189 + } else if (isObject(name)) {
190 + for (key in name) {
191 + if (!hasProp.call(name, key)) continue;
192 + val = name[key];
193 + if (isFunction(val)) {
194 + val = val.apply();
195 + }
196 + if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
197 + lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
198 + } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
199 + lastChild = this.dummy();
200 + } else if (isObject(val) && isEmpty(val)) {
201 + lastChild = this.element(key);
202 + } else if (!this.options.keepNullNodes && (val == null)) {
203 + lastChild = this.dummy();
204 + } else if (!this.options.separateArrayItems && Array.isArray(val)) {
205 + for (k = 0, len1 = val.length; k < len1; k++) {
206 + item = val[k];
207 + childNode = {};
208 + childNode[key] = item;
209 + lastChild = this.element(childNode);
210 + }
211 + } else if (isObject(val)) {
212 + if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
213 + lastChild = this.element(val);
214 + } else {
215 + lastChild = this.element(key);
216 + lastChild.element(val);
217 + }
218 + } else {
219 + lastChild = this.element(key, val);
220 + }
221 + }
222 + } else if (!this.options.keepNullNodes && text === null) {
223 + lastChild = this.dummy();
224 + } else {
225 + if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
226 + lastChild = this.text(text);
227 + } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
228 + lastChild = this.cdata(text);
229 + } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
230 + lastChild = this.comment(text);
231 + } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
232 + lastChild = this.raw(text);
233 + } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
234 + lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
235 + } else {
236 + lastChild = this.node(name, attributes, text);
237 + }
238 + }
239 + if (lastChild == null) {
240 + throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
241 + }
242 + return lastChild;
243 + };
244 +
245 + XMLNode.prototype.insertBefore = function(name, attributes, text) {
246 + var child, i, newChild, refChild, removed;
247 + if (name != null ? name.type : void 0) {
248 + newChild = name;
249 + refChild = attributes;
250 + newChild.setParent(this);
251 + if (refChild) {
252 + i = children.indexOf(refChild);
253 + removed = children.splice(i);
254 + children.push(newChild);
255 + Array.prototype.push.apply(children, removed);
256 + } else {
257 + children.push(newChild);
258 + }
259 + return newChild;
260 + } else {
261 + if (this.isRoot) {
262 + throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
263 + }
264 + i = this.parent.children.indexOf(this);
265 + removed = this.parent.children.splice(i);
266 + child = this.parent.element(name, attributes, text);
267 + Array.prototype.push.apply(this.parent.children, removed);
268 + return child;
269 + }
270 + };
271 +
272 + XMLNode.prototype.insertAfter = function(name, attributes, text) {
273 + var child, i, removed;
274 + if (this.isRoot) {
275 + throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
276 + }
277 + i = this.parent.children.indexOf(this);
278 + removed = this.parent.children.splice(i + 1);
279 + child = this.parent.element(name, attributes, text);
280 + Array.prototype.push.apply(this.parent.children, removed);
281 + return child;
282 + };
283 +
284 + XMLNode.prototype.remove = function() {
285 + var i, ref2;
286 + if (this.isRoot) {
287 + throw new Error("Cannot remove the root element. " + this.debugInfo());
288 + }
289 + i = this.parent.children.indexOf(this);
290 + [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2;
291 + return this.parent;
292 + };
293 +
294 + XMLNode.prototype.node = function(name, attributes, text) {
295 + var child, ref2;
296 + if (name != null) {
297 + name = getValue(name);
298 + }
299 + attributes || (attributes = {});
300 + attributes = getValue(attributes);
301 + if (!isObject(attributes)) {
302 + ref2 = [attributes, text], text = ref2[0], attributes = ref2[1];
303 + }
304 + child = new XMLElement(this, name, attributes);
305 + if (text != null) {
306 + child.text(text);
307 + }
308 + this.children.push(child);
309 + return child;
310 + };
311 +
312 + XMLNode.prototype.text = function(value) {
313 + var child;
314 + if (isObject(value)) {
315 + this.element(value);
316 + }
317 + child = new XMLText(this, value);
318 + this.children.push(child);
319 + return this;
320 + };
321 +
322 + XMLNode.prototype.cdata = function(value) {
323 + var child;
324 + child = new XMLCData(this, value);
325 + this.children.push(child);
326 + return this;
327 + };
328 +
329 + XMLNode.prototype.comment = function(value) {
330 + var child;
331 + child = new XMLComment(this, value);
332 + this.children.push(child);
333 + return this;
334 + };
335 +
336 + XMLNode.prototype.commentBefore = function(value) {
337 + var child, i, removed;
338 + i = this.parent.children.indexOf(this);
339 + removed = this.parent.children.splice(i);
340 + child = this.parent.comment(value);
341 + Array.prototype.push.apply(this.parent.children, removed);
342 + return this;
343 + };
344 +
345 + XMLNode.prototype.commentAfter = function(value) {
346 + var child, i, removed;
347 + i = this.parent.children.indexOf(this);
348 + removed = this.parent.children.splice(i + 1);
349 + child = this.parent.comment(value);
350 + Array.prototype.push.apply(this.parent.children, removed);
351 + return this;
352 + };
353 +
354 + XMLNode.prototype.raw = function(value) {
355 + var child;
356 + child = new XMLRaw(this, value);
357 + this.children.push(child);
358 + return this;
359 + };
360 +
361 + XMLNode.prototype.dummy = function() {
362 + var child;
363 + child = new XMLDummy(this);
364 + return child;
365 + };
366 +
367 + XMLNode.prototype.instruction = function(target, value) {
368 + var insTarget, insValue, instruction, j, len;
369 + if (target != null) {
370 + target = getValue(target);
371 + }
372 + if (value != null) {
373 + value = getValue(value);
374 + }
375 + if (Array.isArray(target)) {
376 + for (j = 0, len = target.length; j < len; j++) {
377 + insTarget = target[j];
378 + this.instruction(insTarget);
379 + }
380 + } else if (isObject(target)) {
381 + for (insTarget in target) {
382 + if (!hasProp.call(target, insTarget)) continue;
383 + insValue = target[insTarget];
384 + this.instruction(insTarget, insValue);
385 + }
386 + } else {
387 + if (isFunction(value)) {
388 + value = value.apply();
389 + }
390 + instruction = new XMLProcessingInstruction(this, target, value);
391 + this.children.push(instruction);
392 + }
393 + return this;
394 + };
395 +
396 + XMLNode.prototype.instructionBefore = function(target, value) {
397 + var child, i, removed;
398 + i = this.parent.children.indexOf(this);
399 + removed = this.parent.children.splice(i);
400 + child = this.parent.instruction(target, value);
401 + Array.prototype.push.apply(this.parent.children, removed);
402 + return this;
403 + };
404 +
405 + XMLNode.prototype.instructionAfter = function(target, value) {
406 + var child, i, removed;
407 + i = this.parent.children.indexOf(this);
408 + removed = this.parent.children.splice(i + 1);
409 + child = this.parent.instruction(target, value);
410 + Array.prototype.push.apply(this.parent.children, removed);
411 + return this;
412 + };
413 +
414 + XMLNode.prototype.declaration = function(version, encoding, standalone) {
415 + var doc, xmldec;
416 + doc = this.document();
417 + xmldec = new XMLDeclaration(doc, version, encoding, standalone);
418 + if (doc.children.length === 0) {
419 + doc.children.unshift(xmldec);
420 + } else if (doc.children[0].type === NodeType.Declaration) {
421 + doc.children[0] = xmldec;
422 + } else {
423 + doc.children.unshift(xmldec);
424 + }
425 + return doc.root() || doc;
426 + };
427 +
428 + XMLNode.prototype.dtd = function(pubID, sysID) {
429 + var child, doc, doctype, i, j, k, len, len1, ref2, ref3;
430 + doc = this.document();
431 + doctype = new XMLDocType(doc, pubID, sysID);
432 + ref2 = doc.children;
433 + for (i = j = 0, len = ref2.length; j < len; i = ++j) {
434 + child = ref2[i];
435 + if (child.type === NodeType.DocType) {
436 + doc.children[i] = doctype;
437 + return doctype;
438 + }
439 + }
440 + ref3 = doc.children;
441 + for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
442 + child = ref3[i];
443 + if (child.isRoot) {
444 + doc.children.splice(i, 0, doctype);
445 + return doctype;
446 + }
447 + }
448 + doc.children.push(doctype);
449 + return doctype;
450 + };
451 +
452 + XMLNode.prototype.up = function() {
453 + if (this.isRoot) {
454 + throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
455 + }
456 + return this.parent;
457 + };
458 +
459 + XMLNode.prototype.root = function() {
460 + var node;
461 + node = this;
462 + while (node) {
463 + if (node.type === NodeType.Document) {
464 + return node.rootObject;
465 + } else if (node.isRoot) {
466 + return node;
467 + } else {
468 + node = node.parent;
469 + }
470 + }
471 + };
472 +
473 + XMLNode.prototype.document = function() {
474 + var node;
475 + node = this;
476 + while (node) {
477 + if (node.type === NodeType.Document) {
478 + return node;
479 + } else {
480 + node = node.parent;
481 + }
482 + }
483 + };
484 +
485 + XMLNode.prototype.end = function(options) {
486 + return this.document().end(options);
487 + };
488 +
489 + XMLNode.prototype.prev = function() {
490 + var i;
491 + i = this.parent.children.indexOf(this);
492 + if (i < 1) {
493 + throw new Error("Already at the first node. " + this.debugInfo());
494 + }
495 + return this.parent.children[i - 1];
496 + };
497 +
498 + XMLNode.prototype.next = function() {
499 + var i;
500 + i = this.parent.children.indexOf(this);
501 + if (i === -1 || i === this.parent.children.length - 1) {
502 + throw new Error("Already at the last node. " + this.debugInfo());
503 + }
504 + return this.parent.children[i + 1];
505 + };
506 +
507 + XMLNode.prototype.importDocument = function(doc) {
508 + var clonedRoot;
509 + clonedRoot = doc.root().clone();
510 + clonedRoot.parent = this;
511 + clonedRoot.isRoot = false;
512 + this.children.push(clonedRoot);
513 + return this;
514 + };
515 +
516 + XMLNode.prototype.debugInfo = function(name) {
517 + var ref2, ref3;
518 + name = name || this.name;
519 + if ((name == null) && !((ref2 = this.parent) != null ? ref2.name : void 0)) {
520 + return "";
521 + } else if (name == null) {
522 + return "parent: <" + this.parent.name + ">";
523 + } else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) {
524 + return "node: <" + name + ">";
525 + } else {
526 + return "node: <" + name + ">, parent: <" + this.parent.name + ">";
527 + }
528 + };
529 +
530 + XMLNode.prototype.ele = function(name, attributes, text) {
531 + return this.element(name, attributes, text);
532 + };
533 +
534 + XMLNode.prototype.nod = function(name, attributes, text) {
535 + return this.node(name, attributes, text);
536 + };
537 +
538 + XMLNode.prototype.txt = function(value) {
539 + return this.text(value);
540 + };
541 +
542 + XMLNode.prototype.dat = function(value) {
543 + return this.cdata(value);
544 + };
545 +
546 + XMLNode.prototype.com = function(value) {
547 + return this.comment(value);
548 + };
549 +
550 + XMLNode.prototype.ins = function(target, value) {
551 + return this.instruction(target, value);
552 + };
553 +
554 + XMLNode.prototype.doc = function() {
555 + return this.document();
556 + };
557 +
558 + XMLNode.prototype.dec = function(version, encoding, standalone) {
559 + return this.declaration(version, encoding, standalone);
560 + };
561 +
562 + XMLNode.prototype.e = function(name, attributes, text) {
563 + return this.element(name, attributes, text);
564 + };
565 +
566 + XMLNode.prototype.n = function(name, attributes, text) {
567 + return this.node(name, attributes, text);
568 + };
569 +
570 + XMLNode.prototype.t = function(value) {
571 + return this.text(value);
572 + };
573 +
574 + XMLNode.prototype.d = function(value) {
575 + return this.cdata(value);
576 + };
577 +
578 + XMLNode.prototype.c = function(value) {
579 + return this.comment(value);
580 + };
581 +
582 + XMLNode.prototype.r = function(value) {
583 + return this.raw(value);
584 + };
585 +
586 + XMLNode.prototype.i = function(target, value) {
587 + return this.instruction(target, value);
588 + };
589 +
590 + XMLNode.prototype.u = function() {
591 + return this.up();
592 + };
593 +
594 + XMLNode.prototype.importXMLBuilder = function(doc) {
595 + return this.importDocument(doc);
596 + };
597 +
598 + XMLNode.prototype.replaceChild = function(newChild, oldChild) {
599 + throw new Error("This DOM method is not implemented." + this.debugInfo());
600 + };
601 +
602 + XMLNode.prototype.removeChild = function(oldChild) {
603 + throw new Error("This DOM method is not implemented." + this.debugInfo());
604 + };
605 +
606 + XMLNode.prototype.appendChild = function(newChild) {
607 + throw new Error("This DOM method is not implemented." + this.debugInfo());
608 + };
609 +
610 + XMLNode.prototype.hasChildNodes = function() {
611 + return this.children.length !== 0;
612 + };
613 +
614 + XMLNode.prototype.cloneNode = function(deep) {
615 + throw new Error("This DOM method is not implemented." + this.debugInfo());
616 + };
617 +
618 + XMLNode.prototype.normalize = function() {
619 + throw new Error("This DOM method is not implemented." + this.debugInfo());
620 + };
621 +
622 + XMLNode.prototype.isSupported = function(feature, version) {
623 + return true;
624 + };
625 +
626 + XMLNode.prototype.hasAttributes = function() {
627 + return this.attribs.length !== 0;
628 + };
629 +
630 + XMLNode.prototype.compareDocumentPosition = function(other) {
631 + var ref, res;
632 + ref = this;
633 + if (ref === other) {
634 + return 0;
635 + } else if (this.document() !== other.document()) {
636 + res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
637 + if (Math.random() < 0.5) {
638 + res |= DocumentPosition.Preceding;
639 + } else {
640 + res |= DocumentPosition.Following;
641 + }
642 + return res;
643 + } else if (ref.isAncestor(other)) {
644 + return DocumentPosition.Contains | DocumentPosition.Preceding;
645 + } else if (ref.isDescendant(other)) {
646 + return DocumentPosition.Contains | DocumentPosition.Following;
647 + } else if (ref.isPreceding(other)) {
648 + return DocumentPosition.Preceding;
649 + } else {
650 + return DocumentPosition.Following;
651 + }
652 + };
653 +
654 + XMLNode.prototype.isSameNode = function(other) {
655 + throw new Error("This DOM method is not implemented." + this.debugInfo());
656 + };
657 +
658 + XMLNode.prototype.lookupPrefix = function(namespaceURI) {
659 + throw new Error("This DOM method is not implemented." + this.debugInfo());
660 + };
661 +
662 + XMLNode.prototype.isDefaultNamespace = function(namespaceURI) {
663 + throw new Error("This DOM method is not implemented." + this.debugInfo());
664 + };
665 +
666 + XMLNode.prototype.lookupNamespaceURI = function(prefix) {
667 + throw new Error("This DOM method is not implemented." + this.debugInfo());
668 + };
669 +
670 + XMLNode.prototype.isEqualNode = function(node) {
671 + var i, j, ref2;
672 + if (node.nodeType !== this.nodeType) {
673 + return false;
674 + }
675 + if (node.children.length !== this.children.length) {
676 + return false;
677 + }
678 + for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) {
679 + if (!this.children[i].isEqualNode(node.children[i])) {
680 + return false;
681 + }
682 + }
683 + return true;
684 + };
685 +
686 + XMLNode.prototype.getFeature = function(feature, version) {
687 + throw new Error("This DOM method is not implemented." + this.debugInfo());
688 + };
689 +
690 + XMLNode.prototype.setUserData = function(key, data, handler) {
691 + throw new Error("This DOM method is not implemented." + this.debugInfo());
692 + };
693 +
694 + XMLNode.prototype.getUserData = function(key) {
695 + throw new Error("This DOM method is not implemented." + this.debugInfo());
696 + };
697 +
698 + XMLNode.prototype.contains = function(other) {
699 + if (!other) {
700 + return false;
701 + }
702 + return other === this || this.isDescendant(other);
703 + };
704 +
705 + XMLNode.prototype.isDescendant = function(node) {
706 + var child, isDescendantChild, j, len, ref2;
707 + ref2 = this.children;
708 + for (j = 0, len = ref2.length; j < len; j++) {
709 + child = ref2[j];
710 + if (node === child) {
711 + return true;
712 + }
713 + isDescendantChild = child.isDescendant(node);
714 + if (isDescendantChild) {
715 + return true;
716 + }
717 + }
718 + return false;
719 + };
720 +
721 + XMLNode.prototype.isAncestor = function(node) {
722 + return node.isDescendant(this);
723 + };
724 +
725 + XMLNode.prototype.isPreceding = function(node) {
726 + var nodePos, thisPos;
727 + nodePos = this.treePosition(node);
728 + thisPos = this.treePosition(this);
729 + if (nodePos === -1 || thisPos === -1) {
730 + return false;
731 + } else {
732 + return nodePos < thisPos;
733 + }
734 + };
735 +
736 + XMLNode.prototype.isFollowing = function(node) {
737 + var nodePos, thisPos;
738 + nodePos = this.treePosition(node);
739 + thisPos = this.treePosition(this);
740 + if (nodePos === -1 || thisPos === -1) {
741 + return false;
742 + } else {
743 + return nodePos > thisPos;
744 + }
745 + };
746 +
747 + XMLNode.prototype.treePosition = function(node) {
748 + var found, pos;
749 + pos = 0;
750 + found = false;
751 + this.foreachTreeNode(this.document(), function(childNode) {
752 + pos++;
753 + if (!found && childNode === node) {
754 + return found = true;
755 + }
756 + });
757 + if (found) {
758 + return pos;
759 + } else {
760 + return -1;
761 + }
762 + };
763 +
764 + XMLNode.prototype.foreachTreeNode = function(node, func) {
765 + var child, j, len, ref2, res;
766 + node || (node = this.document());
767 + ref2 = node.children;
768 + for (j = 0, len = ref2.length; j < len; j++) {
769 + child = ref2[j];
770 + if (res = func(child)) {
771 + return res;
772 + } else {
773 + res = this.foreachTreeNode(child, func);
774 + if (res) {
775 + return res;
776 + }
777 + }
778 + }
779 + };
780 +
781 + return XMLNode;
782 +
783 + })();
784 +
785 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var XMLNodeFilter;
4 +
5 + module.exports = XMLNodeFilter = (function() {
6 + function XMLNodeFilter() {}
7 +
8 + XMLNodeFilter.prototype.FilterAccept = 1;
9 +
10 + XMLNodeFilter.prototype.FilterReject = 2;
11 +
12 + XMLNodeFilter.prototype.FilterSkip = 3;
13 +
14 + XMLNodeFilter.prototype.ShowAll = 0xffffffff;
15 +
16 + XMLNodeFilter.prototype.ShowElement = 0x1;
17 +
18 + XMLNodeFilter.prototype.ShowAttribute = 0x2;
19 +
20 + XMLNodeFilter.prototype.ShowText = 0x4;
21 +
22 + XMLNodeFilter.prototype.ShowCDataSection = 0x8;
23 +
24 + XMLNodeFilter.prototype.ShowEntityReference = 0x10;
25 +
26 + XMLNodeFilter.prototype.ShowEntity = 0x20;
27 +
28 + XMLNodeFilter.prototype.ShowProcessingInstruction = 0x40;
29 +
30 + XMLNodeFilter.prototype.ShowComment = 0x80;
31 +
32 + XMLNodeFilter.prototype.ShowDocument = 0x100;
33 +
34 + XMLNodeFilter.prototype.ShowDocumentType = 0x200;
35 +
36 + XMLNodeFilter.prototype.ShowDocumentFragment = 0x400;
37 +
38 + XMLNodeFilter.prototype.ShowNotation = 0x800;
39 +
40 + XMLNodeFilter.prototype.acceptNode = function(node) {
41 + throw new Error("This DOM method is not implemented.");
42 + };
43 +
44 + return XMLNodeFilter;
45 +
46 + })();
47 +
48 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var XMLNodeList;
4 +
5 + module.exports = XMLNodeList = (function() {
6 + function XMLNodeList(nodes) {
7 + this.nodes = nodes;
8 + }
9 +
10 + Object.defineProperty(XMLNodeList.prototype, 'length', {
11 + get: function() {
12 + return this.nodes.length || 0;
13 + }
14 + });
15 +
16 + XMLNodeList.prototype.clone = function() {
17 + return this.nodes = null;
18 + };
19 +
20 + XMLNodeList.prototype.item = function(index) {
21 + return this.nodes[index] || null;
22 + };
23 +
24 + return XMLNodeList;
25 +
26 + })();
27 +
28 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLCharacterData, XMLProcessingInstruction,
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 +
7 + NodeType = require('./NodeType');
8 +
9 + XMLCharacterData = require('./XMLCharacterData');
10 +
11 + module.exports = XMLProcessingInstruction = (function(superClass) {
12 + extend(XMLProcessingInstruction, superClass);
13 +
14 + function XMLProcessingInstruction(parent, target, value) {
15 + XMLProcessingInstruction.__super__.constructor.call(this, parent);
16 + if (target == null) {
17 + throw new Error("Missing instruction target. " + this.debugInfo());
18 + }
19 + this.type = NodeType.ProcessingInstruction;
20 + this.target = this.stringify.insTarget(target);
21 + this.name = this.target;
22 + if (value) {
23 + this.value = this.stringify.insValue(value);
24 + }
25 + }
26 +
27 + XMLProcessingInstruction.prototype.clone = function() {
28 + return Object.create(this);
29 + };
30 +
31 + XMLProcessingInstruction.prototype.toString = function(options) {
32 + return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
33 + };
34 +
35 + XMLProcessingInstruction.prototype.isEqualNode = function(node) {
36 + if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
37 + return false;
38 + }
39 + if (node.target !== this.target) {
40 + return false;
41 + }
42 + return true;
43 + };
44 +
45 + return XMLProcessingInstruction;
46 +
47 + })(XMLCharacterData);
48 +
49 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLNode, XMLRaw,
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 +
7 + NodeType = require('./NodeType');
8 +
9 + XMLNode = require('./XMLNode');
10 +
11 + module.exports = XMLRaw = (function(superClass) {
12 + extend(XMLRaw, superClass);
13 +
14 + function XMLRaw(parent, text) {
15 + XMLRaw.__super__.constructor.call(this, parent);
16 + if (text == null) {
17 + throw new Error("Missing raw text. " + this.debugInfo());
18 + }
19 + this.type = NodeType.Raw;
20 + this.value = this.stringify.raw(text);
21 + }
22 +
23 + XMLRaw.prototype.clone = function() {
24 + return Object.create(this);
25 + };
26 +
27 + XMLRaw.prototype.toString = function(options) {
28 + return this.options.writer.raw(this, this.options.writer.filterOptions(options));
29 + };
30 +
31 + return XMLRaw;
32 +
33 + })(XMLNode);
34 +
35 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, WriterState, XMLStreamWriter, XMLWriterBase,
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 +
7 + NodeType = require('./NodeType');
8 +
9 + XMLWriterBase = require('./XMLWriterBase');
10 +
11 + WriterState = require('./WriterState');
12 +
13 + module.exports = XMLStreamWriter = (function(superClass) {
14 + extend(XMLStreamWriter, superClass);
15 +
16 + function XMLStreamWriter(stream, options) {
17 + this.stream = stream;
18 + XMLStreamWriter.__super__.constructor.call(this, options);
19 + }
20 +
21 + XMLStreamWriter.prototype.endline = function(node, options, level) {
22 + if (node.isLastRootNode && options.state === WriterState.CloseTag) {
23 + return '';
24 + } else {
25 + return XMLStreamWriter.__super__.endline.call(this, node, options, level);
26 + }
27 + };
28 +
29 + XMLStreamWriter.prototype.document = function(doc, options) {
30 + var child, i, j, k, len, len1, ref, ref1, results;
31 + ref = doc.children;
32 + for (i = j = 0, len = ref.length; j < len; i = ++j) {
33 + child = ref[i];
34 + child.isLastRootNode = i === doc.children.length - 1;
35 + }
36 + options = this.filterOptions(options);
37 + ref1 = doc.children;
38 + results = [];
39 + for (k = 0, len1 = ref1.length; k < len1; k++) {
40 + child = ref1[k];
41 + results.push(this.writeChildNode(child, options, 0));
42 + }
43 + return results;
44 + };
45 +
46 + XMLStreamWriter.prototype.attribute = function(att, options, level) {
47 + return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level));
48 + };
49 +
50 + XMLStreamWriter.prototype.cdata = function(node, options, level) {
51 + return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level));
52 + };
53 +
54 + XMLStreamWriter.prototype.comment = function(node, options, level) {
55 + return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level));
56 + };
57 +
58 + XMLStreamWriter.prototype.declaration = function(node, options, level) {
59 + return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level));
60 + };
61 +
62 + XMLStreamWriter.prototype.docType = function(node, options, level) {
63 + var child, j, len, ref;
64 + level || (level = 0);
65 + this.openNode(node, options, level);
66 + options.state = WriterState.OpenTag;
67 + this.stream.write(this.indent(node, options, level));
68 + this.stream.write('<!DOCTYPE ' + node.root().name);
69 + if (node.pubID && node.sysID) {
70 + this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
71 + } else if (node.sysID) {
72 + this.stream.write(' SYSTEM "' + node.sysID + '"');
73 + }
74 + if (node.children.length > 0) {
75 + this.stream.write(' [');
76 + this.stream.write(this.endline(node, options, level));
77 + options.state = WriterState.InsideTag;
78 + ref = node.children;
79 + for (j = 0, len = ref.length; j < len; j++) {
80 + child = ref[j];
81 + this.writeChildNode(child, options, level + 1);
82 + }
83 + options.state = WriterState.CloseTag;
84 + this.stream.write(']');
85 + }
86 + options.state = WriterState.CloseTag;
87 + this.stream.write(options.spaceBeforeSlash + '>');
88 + this.stream.write(this.endline(node, options, level));
89 + options.state = WriterState.None;
90 + return this.closeNode(node, options, level);
91 + };
92 +
93 + XMLStreamWriter.prototype.element = function(node, options, level) {
94 + var att, child, childNodeCount, firstChildNode, j, len, name, prettySuppressed, ref, ref1;
95 + level || (level = 0);
96 + this.openNode(node, options, level);
97 + options.state = WriterState.OpenTag;
98 + this.stream.write(this.indent(node, options, level) + '<' + node.name);
99 + ref = node.attribs;
100 + for (name in ref) {
101 + if (!hasProp.call(ref, name)) continue;
102 + att = ref[name];
103 + this.attribute(att, options, level);
104 + }
105 + childNodeCount = node.children.length;
106 + firstChildNode = childNodeCount === 0 ? null : node.children[0];
107 + if (childNodeCount === 0 || node.children.every(function(e) {
108 + return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
109 + })) {
110 + if (options.allowEmpty) {
111 + this.stream.write('>');
112 + options.state = WriterState.CloseTag;
113 + this.stream.write('</' + node.name + '>');
114 + } else {
115 + options.state = WriterState.CloseTag;
116 + this.stream.write(options.spaceBeforeSlash + '/>');
117 + }
118 + } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
119 + this.stream.write('>');
120 + options.state = WriterState.InsideTag;
121 + options.suppressPrettyCount++;
122 + prettySuppressed = true;
123 + this.writeChildNode(firstChildNode, options, level + 1);
124 + options.suppressPrettyCount--;
125 + prettySuppressed = false;
126 + options.state = WriterState.CloseTag;
127 + this.stream.write('</' + node.name + '>');
128 + } else {
129 + this.stream.write('>' + this.endline(node, options, level));
130 + options.state = WriterState.InsideTag;
131 + ref1 = node.children;
132 + for (j = 0, len = ref1.length; j < len; j++) {
133 + child = ref1[j];
134 + this.writeChildNode(child, options, level + 1);
135 + }
136 + options.state = WriterState.CloseTag;
137 + this.stream.write(this.indent(node, options, level) + '</' + node.name + '>');
138 + }
139 + this.stream.write(this.endline(node, options, level));
140 + options.state = WriterState.None;
141 + return this.closeNode(node, options, level);
142 + };
143 +
144 + XMLStreamWriter.prototype.processingInstruction = function(node, options, level) {
145 + return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level));
146 + };
147 +
148 + XMLStreamWriter.prototype.raw = function(node, options, level) {
149 + return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level));
150 + };
151 +
152 + XMLStreamWriter.prototype.text = function(node, options, level) {
153 + return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level));
154 + };
155 +
156 + XMLStreamWriter.prototype.dtdAttList = function(node, options, level) {
157 + return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level));
158 + };
159 +
160 + XMLStreamWriter.prototype.dtdElement = function(node, options, level) {
161 + return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level));
162 + };
163 +
164 + XMLStreamWriter.prototype.dtdEntity = function(node, options, level) {
165 + return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level));
166 + };
167 +
168 + XMLStreamWriter.prototype.dtdNotation = function(node, options, level) {
169 + return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level));
170 + };
171 +
172 + return XMLStreamWriter;
173 +
174 + })(XMLWriterBase);
175 +
176 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var XMLStringWriter, XMLWriterBase,
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 +
7 + XMLWriterBase = require('./XMLWriterBase');
8 +
9 + module.exports = XMLStringWriter = (function(superClass) {
10 + extend(XMLStringWriter, superClass);
11 +
12 + function XMLStringWriter(options) {
13 + XMLStringWriter.__super__.constructor.call(this, options);
14 + }
15 +
16 + XMLStringWriter.prototype.document = function(doc, options) {
17 + var child, i, len, r, ref;
18 + options = this.filterOptions(options);
19 + r = '';
20 + ref = doc.children;
21 + for (i = 0, len = ref.length; i < len; i++) {
22 + child = ref[i];
23 + r += this.writeChildNode(child, options, 0);
24 + }
25 + if (options.pretty && r.slice(-options.newline.length) === options.newline) {
26 + r = r.slice(0, -options.newline.length);
27 + }
28 + return r;
29 + };
30 +
31 + return XMLStringWriter;
32 +
33 + })(XMLWriterBase);
34 +
35 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var XMLStringifier,
4 + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
5 + hasProp = {}.hasOwnProperty;
6 +
7 + module.exports = XMLStringifier = (function() {
8 + function XMLStringifier(options) {
9 + this.assertLegalName = bind(this.assertLegalName, this);
10 + this.assertLegalChar = bind(this.assertLegalChar, this);
11 + var key, ref, value;
12 + options || (options = {});
13 + this.options = options;
14 + if (!this.options.version) {
15 + this.options.version = '1.0';
16 + }
17 + ref = options.stringify || {};
18 + for (key in ref) {
19 + if (!hasProp.call(ref, key)) continue;
20 + value = ref[key];
21 + this[key] = value;
22 + }
23 + }
24 +
25 + XMLStringifier.prototype.name = function(val) {
26 + if (this.options.noValidation) {
27 + return val;
28 + }
29 + return this.assertLegalName('' + val || '');
30 + };
31 +
32 + XMLStringifier.prototype.text = function(val) {
33 + if (this.options.noValidation) {
34 + return val;
35 + }
36 + return this.assertLegalChar(this.textEscape('' + val || ''));
37 + };
38 +
39 + XMLStringifier.prototype.cdata = function(val) {
40 + if (this.options.noValidation) {
41 + return val;
42 + }
43 + val = '' + val || '';
44 + val = val.replace(']]>', ']]]]><![CDATA[>');
45 + return this.assertLegalChar(val);
46 + };
47 +
48 + XMLStringifier.prototype.comment = function(val) {
49 + if (this.options.noValidation) {
50 + return val;
51 + }
52 + val = '' + val || '';
53 + if (val.match(/--/)) {
54 + throw new Error("Comment text cannot contain double-hypen: " + val);
55 + }
56 + return this.assertLegalChar(val);
57 + };
58 +
59 + XMLStringifier.prototype.raw = function(val) {
60 + if (this.options.noValidation) {
61 + return val;
62 + }
63 + return '' + val || '';
64 + };
65 +
66 + XMLStringifier.prototype.attValue = function(val) {
67 + if (this.options.noValidation) {
68 + return val;
69 + }
70 + return this.assertLegalChar(this.attEscape(val = '' + val || ''));
71 + };
72 +
73 + XMLStringifier.prototype.insTarget = function(val) {
74 + if (this.options.noValidation) {
75 + return val;
76 + }
77 + return this.assertLegalChar('' + val || '');
78 + };
79 +
80 + XMLStringifier.prototype.insValue = function(val) {
81 + if (this.options.noValidation) {
82 + return val;
83 + }
84 + val = '' + val || '';
85 + if (val.match(/\?>/)) {
86 + throw new Error("Invalid processing instruction value: " + val);
87 + }
88 + return this.assertLegalChar(val);
89 + };
90 +
91 + XMLStringifier.prototype.xmlVersion = function(val) {
92 + if (this.options.noValidation) {
93 + return val;
94 + }
95 + val = '' + val || '';
96 + if (!val.match(/1\.[0-9]+/)) {
97 + throw new Error("Invalid version number: " + val);
98 + }
99 + return val;
100 + };
101 +
102 + XMLStringifier.prototype.xmlEncoding = function(val) {
103 + if (this.options.noValidation) {
104 + return val;
105 + }
106 + val = '' + val || '';
107 + if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
108 + throw new Error("Invalid encoding: " + val);
109 + }
110 + return this.assertLegalChar(val);
111 + };
112 +
113 + XMLStringifier.prototype.xmlStandalone = function(val) {
114 + if (this.options.noValidation) {
115 + return val;
116 + }
117 + if (val) {
118 + return "yes";
119 + } else {
120 + return "no";
121 + }
122 + };
123 +
124 + XMLStringifier.prototype.dtdPubID = function(val) {
125 + if (this.options.noValidation) {
126 + return val;
127 + }
128 + return this.assertLegalChar('' + val || '');
129 + };
130 +
131 + XMLStringifier.prototype.dtdSysID = function(val) {
132 + if (this.options.noValidation) {
133 + return val;
134 + }
135 + return this.assertLegalChar('' + val || '');
136 + };
137 +
138 + XMLStringifier.prototype.dtdElementValue = function(val) {
139 + if (this.options.noValidation) {
140 + return val;
141 + }
142 + return this.assertLegalChar('' + val || '');
143 + };
144 +
145 + XMLStringifier.prototype.dtdAttType = function(val) {
146 + if (this.options.noValidation) {
147 + return val;
148 + }
149 + return this.assertLegalChar('' + val || '');
150 + };
151 +
152 + XMLStringifier.prototype.dtdAttDefault = function(val) {
153 + if (this.options.noValidation) {
154 + return val;
155 + }
156 + return this.assertLegalChar('' + val || '');
157 + };
158 +
159 + XMLStringifier.prototype.dtdEntityValue = function(val) {
160 + if (this.options.noValidation) {
161 + return val;
162 + }
163 + return this.assertLegalChar('' + val || '');
164 + };
165 +
166 + XMLStringifier.prototype.dtdNData = function(val) {
167 + if (this.options.noValidation) {
168 + return val;
169 + }
170 + return this.assertLegalChar('' + val || '');
171 + };
172 +
173 + XMLStringifier.prototype.convertAttKey = '@';
174 +
175 + XMLStringifier.prototype.convertPIKey = '?';
176 +
177 + XMLStringifier.prototype.convertTextKey = '#text';
178 +
179 + XMLStringifier.prototype.convertCDataKey = '#cdata';
180 +
181 + XMLStringifier.prototype.convertCommentKey = '#comment';
182 +
183 + XMLStringifier.prototype.convertRawKey = '#raw';
184 +
185 + XMLStringifier.prototype.assertLegalChar = function(str) {
186 + var regex, res;
187 + if (this.options.noValidation) {
188 + return str;
189 + }
190 + regex = '';
191 + if (this.options.version === '1.0') {
192 + regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
193 + if (res = str.match(regex)) {
194 + throw new Error("Invalid character in string: " + str + " at index " + res.index);
195 + }
196 + } else if (this.options.version === '1.1') {
197 + regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
198 + if (res = str.match(regex)) {
199 + throw new Error("Invalid character in string: " + str + " at index " + res.index);
200 + }
201 + }
202 + return str;
203 + };
204 +
205 + XMLStringifier.prototype.assertLegalName = function(str) {
206 + var regex;
207 + if (this.options.noValidation) {
208 + return str;
209 + }
210 + this.assertLegalChar(str);
211 + regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/;
212 + if (!str.match(regex)) {
213 + throw new Error("Invalid character in name");
214 + }
215 + return str;
216 + };
217 +
218 + XMLStringifier.prototype.textEscape = function(str) {
219 + var ampregex;
220 + if (this.options.noValidation) {
221 + return str;
222 + }
223 + ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
224 + return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
225 + };
226 +
227 + XMLStringifier.prototype.attEscape = function(str) {
228 + var ampregex;
229 + if (this.options.noValidation) {
230 + return str;
231 + }
232 + ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
233 + return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
234 + };
235 +
236 + return XMLStringifier;
237 +
238 + })();
239 +
240 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, XMLCharacterData, XMLText,
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 +
7 + NodeType = require('./NodeType');
8 +
9 + XMLCharacterData = require('./XMLCharacterData');
10 +
11 + module.exports = XMLText = (function(superClass) {
12 + extend(XMLText, superClass);
13 +
14 + function XMLText(parent, text) {
15 + XMLText.__super__.constructor.call(this, parent);
16 + if (text == null) {
17 + throw new Error("Missing element text. " + this.debugInfo());
18 + }
19 + this.name = "#text";
20 + this.type = NodeType.Text;
21 + this.value = this.stringify.text(text);
22 + }
23 +
24 + Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', {
25 + get: function() {
26 + throw new Error("This DOM method is not implemented." + this.debugInfo());
27 + }
28 + });
29 +
30 + Object.defineProperty(XMLText.prototype, 'wholeText', {
31 + get: function() {
32 + var next, prev, str;
33 + str = '';
34 + prev = this.previousSibling;
35 + while (prev) {
36 + str = prev.data + str;
37 + prev = prev.previousSibling;
38 + }
39 + str += this.data;
40 + next = this.nextSibling;
41 + while (next) {
42 + str = str + next.data;
43 + next = next.nextSibling;
44 + }
45 + return str;
46 + }
47 + });
48 +
49 + XMLText.prototype.clone = function() {
50 + return Object.create(this);
51 + };
52 +
53 + XMLText.prototype.toString = function(options) {
54 + return this.options.writer.text(this, this.options.writer.filterOptions(options));
55 + };
56 +
57 + XMLText.prototype.splitText = function(offset) {
58 + throw new Error("This DOM method is not implemented." + this.debugInfo());
59 + };
60 +
61 + XMLText.prototype.replaceWholeText = function(content) {
62 + throw new Error("This DOM method is not implemented." + this.debugInfo());
63 + };
64 +
65 + return XMLText;
66 +
67 + })(XMLCharacterData);
68 +
69 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var Derivation, XMLTypeInfo;
4 +
5 + Derivation = require('./Derivation');
6 +
7 + module.exports = XMLTypeInfo = (function() {
8 + function XMLTypeInfo(typeName, typeNamespace) {
9 + this.typeName = typeName;
10 + this.typeNamespace = typeNamespace;
11 + }
12 +
13 + XMLTypeInfo.prototype.isDerivedFrom = function(typeNamespaceArg, typeNameArg, derivationMethod) {
14 + throw new Error("This DOM method is not implemented.");
15 + };
16 +
17 + return XMLTypeInfo;
18 +
19 + })();
20 +
21 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var OperationType, XMLUserDataHandler;
4 +
5 + OperationType = require('./OperationType');
6 +
7 + module.exports = XMLUserDataHandler = (function() {
8 + function XMLUserDataHandler() {}
9 +
10 + XMLUserDataHandler.prototype.handle = function(operation, key, data, src, dst) {};
11 +
12 + return XMLUserDataHandler;
13 +
14 + })();
15 +
16 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign,
4 + hasProp = {}.hasOwnProperty;
5 +
6 + assign = require('./Utility').assign;
7 +
8 + NodeType = require('./NodeType');
9 +
10 + XMLDeclaration = require('./XMLDeclaration');
11 +
12 + XMLDocType = require('./XMLDocType');
13 +
14 + XMLCData = require('./XMLCData');
15 +
16 + XMLComment = require('./XMLComment');
17 +
18 + XMLElement = require('./XMLElement');
19 +
20 + XMLRaw = require('./XMLRaw');
21 +
22 + XMLText = require('./XMLText');
23 +
24 + XMLProcessingInstruction = require('./XMLProcessingInstruction');
25 +
26 + XMLDummy = require('./XMLDummy');
27 +
28 + XMLDTDAttList = require('./XMLDTDAttList');
29 +
30 + XMLDTDElement = require('./XMLDTDElement');
31 +
32 + XMLDTDEntity = require('./XMLDTDEntity');
33 +
34 + XMLDTDNotation = require('./XMLDTDNotation');
35 +
36 + WriterState = require('./WriterState');
37 +
38 + module.exports = XMLWriterBase = (function() {
39 + function XMLWriterBase(options) {
40 + var key, ref, value;
41 + options || (options = {});
42 + this.options = options;
43 + ref = options.writer || {};
44 + for (key in ref) {
45 + if (!hasProp.call(ref, key)) continue;
46 + value = ref[key];
47 + this["_" + key] = this[key];
48 + this[key] = value;
49 + }
50 + }
51 +
52 + XMLWriterBase.prototype.filterOptions = function(options) {
53 + var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6;
54 + options || (options = {});
55 + options = assign({}, this.options, options);
56 + filteredOptions = {
57 + writer: this
58 + };
59 + filteredOptions.pretty = options.pretty || false;
60 + filteredOptions.allowEmpty = options.allowEmpty || false;
61 + filteredOptions.indent = (ref = options.indent) != null ? ref : ' ';
62 + filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n';
63 + filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0;
64 + filteredOptions.dontPrettyTextNodes = (ref3 = (ref4 = options.dontPrettyTextNodes) != null ? ref4 : options.dontprettytextnodes) != null ? ref3 : 0;
65 + filteredOptions.spaceBeforeSlash = (ref5 = (ref6 = options.spaceBeforeSlash) != null ? ref6 : options.spacebeforeslash) != null ? ref5 : '';
66 + if (filteredOptions.spaceBeforeSlash === true) {
67 + filteredOptions.spaceBeforeSlash = ' ';
68 + }
69 + filteredOptions.suppressPrettyCount = 0;
70 + filteredOptions.user = {};
71 + filteredOptions.state = WriterState.None;
72 + return filteredOptions;
73 + };
74 +
75 + XMLWriterBase.prototype.indent = function(node, options, level) {
76 + var indentLevel;
77 + if (!options.pretty || options.suppressPrettyCount) {
78 + return '';
79 + } else if (options.pretty) {
80 + indentLevel = (level || 0) + options.offset + 1;
81 + if (indentLevel > 0) {
82 + return new Array(indentLevel).join(options.indent);
83 + }
84 + }
85 + return '';
86 + };
87 +
88 + XMLWriterBase.prototype.endline = function(node, options, level) {
89 + if (!options.pretty || options.suppressPrettyCount) {
90 + return '';
91 + } else {
92 + return options.newline;
93 + }
94 + };
95 +
96 + XMLWriterBase.prototype.attribute = function(att, options, level) {
97 + var r;
98 + this.openAttribute(att, options, level);
99 + r = ' ' + att.name + '="' + att.value + '"';
100 + this.closeAttribute(att, options, level);
101 + return r;
102 + };
103 +
104 + XMLWriterBase.prototype.cdata = function(node, options, level) {
105 + var r;
106 + this.openNode(node, options, level);
107 + options.state = WriterState.OpenTag;
108 + r = this.indent(node, options, level) + '<![CDATA[';
109 + options.state = WriterState.InsideTag;
110 + r += node.value;
111 + options.state = WriterState.CloseTag;
112 + r += ']]>' + this.endline(node, options, level);
113 + options.state = WriterState.None;
114 + this.closeNode(node, options, level);
115 + return r;
116 + };
117 +
118 + XMLWriterBase.prototype.comment = function(node, options, level) {
119 + var r;
120 + this.openNode(node, options, level);
121 + options.state = WriterState.OpenTag;
122 + r = this.indent(node, options, level) + '<!-- ';
123 + options.state = WriterState.InsideTag;
124 + r += node.value;
125 + options.state = WriterState.CloseTag;
126 + r += ' -->' + this.endline(node, options, level);
127 + options.state = WriterState.None;
128 + this.closeNode(node, options, level);
129 + return r;
130 + };
131 +
132 + XMLWriterBase.prototype.declaration = function(node, options, level) {
133 + var r;
134 + this.openNode(node, options, level);
135 + options.state = WriterState.OpenTag;
136 + r = this.indent(node, options, level) + '<?xml';
137 + options.state = WriterState.InsideTag;
138 + r += ' version="' + node.version + '"';
139 + if (node.encoding != null) {
140 + r += ' encoding="' + node.encoding + '"';
141 + }
142 + if (node.standalone != null) {
143 + r += ' standalone="' + node.standalone + '"';
144 + }
145 + options.state = WriterState.CloseTag;
146 + r += options.spaceBeforeSlash + '?>';
147 + r += this.endline(node, options, level);
148 + options.state = WriterState.None;
149 + this.closeNode(node, options, level);
150 + return r;
151 + };
152 +
153 + XMLWriterBase.prototype.docType = function(node, options, level) {
154 + var child, i, len, r, ref;
155 + level || (level = 0);
156 + this.openNode(node, options, level);
157 + options.state = WriterState.OpenTag;
158 + r = this.indent(node, options, level);
159 + r += '<!DOCTYPE ' + node.root().name;
160 + if (node.pubID && node.sysID) {
161 + r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
162 + } else if (node.sysID) {
163 + r += ' SYSTEM "' + node.sysID + '"';
164 + }
165 + if (node.children.length > 0) {
166 + r += ' [';
167 + r += this.endline(node, options, level);
168 + options.state = WriterState.InsideTag;
169 + ref = node.children;
170 + for (i = 0, len = ref.length; i < len; i++) {
171 + child = ref[i];
172 + r += this.writeChildNode(child, options, level + 1);
173 + }
174 + options.state = WriterState.CloseTag;
175 + r += ']';
176 + }
177 + options.state = WriterState.CloseTag;
178 + r += options.spaceBeforeSlash + '>';
179 + r += this.endline(node, options, level);
180 + options.state = WriterState.None;
181 + this.closeNode(node, options, level);
182 + return r;
183 + };
184 +
185 + XMLWriterBase.prototype.element = function(node, options, level) {
186 + var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2;
187 + level || (level = 0);
188 + prettySuppressed = false;
189 + r = '';
190 + this.openNode(node, options, level);
191 + options.state = WriterState.OpenTag;
192 + r += this.indent(node, options, level) + '<' + node.name;
193 + ref = node.attribs;
194 + for (name in ref) {
195 + if (!hasProp.call(ref, name)) continue;
196 + att = ref[name];
197 + r += this.attribute(att, options, level);
198 + }
199 + childNodeCount = node.children.length;
200 + firstChildNode = childNodeCount === 0 ? null : node.children[0];
201 + if (childNodeCount === 0 || node.children.every(function(e) {
202 + return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
203 + })) {
204 + if (options.allowEmpty) {
205 + r += '>';
206 + options.state = WriterState.CloseTag;
207 + r += '</' + node.name + '>' + this.endline(node, options, level);
208 + } else {
209 + options.state = WriterState.CloseTag;
210 + r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
211 + }
212 + } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
213 + r += '>';
214 + options.state = WriterState.InsideTag;
215 + options.suppressPrettyCount++;
216 + prettySuppressed = true;
217 + r += this.writeChildNode(firstChildNode, options, level + 1);
218 + options.suppressPrettyCount--;
219 + prettySuppressed = false;
220 + options.state = WriterState.CloseTag;
221 + r += '</' + node.name + '>' + this.endline(node, options, level);
222 + } else {
223 + if (options.dontPrettyTextNodes) {
224 + ref1 = node.children;
225 + for (i = 0, len = ref1.length; i < len; i++) {
226 + child = ref1[i];
227 + if ((child.type === NodeType.Text || child.type === NodeType.Raw) && (child.value != null)) {
228 + options.suppressPrettyCount++;
229 + prettySuppressed = true;
230 + break;
231 + }
232 + }
233 + }
234 + r += '>' + this.endline(node, options, level);
235 + options.state = WriterState.InsideTag;
236 + ref2 = node.children;
237 + for (j = 0, len1 = ref2.length; j < len1; j++) {
238 + child = ref2[j];
239 + r += this.writeChildNode(child, options, level + 1);
240 + }
241 + options.state = WriterState.CloseTag;
242 + r += this.indent(node, options, level) + '</' + node.name + '>';
243 + if (prettySuppressed) {
244 + options.suppressPrettyCount--;
245 + }
246 + r += this.endline(node, options, level);
247 + options.state = WriterState.None;
248 + }
249 + this.closeNode(node, options, level);
250 + return r;
251 + };
252 +
253 + XMLWriterBase.prototype.writeChildNode = function(node, options, level) {
254 + switch (node.type) {
255 + case NodeType.CData:
256 + return this.cdata(node, options, level);
257 + case NodeType.Comment:
258 + return this.comment(node, options, level);
259 + case NodeType.Element:
260 + return this.element(node, options, level);
261 + case NodeType.Raw:
262 + return this.raw(node, options, level);
263 + case NodeType.Text:
264 + return this.text(node, options, level);
265 + case NodeType.ProcessingInstruction:
266 + return this.processingInstruction(node, options, level);
267 + case NodeType.Dummy:
268 + return '';
269 + case NodeType.Declaration:
270 + return this.declaration(node, options, level);
271 + case NodeType.DocType:
272 + return this.docType(node, options, level);
273 + case NodeType.AttributeDeclaration:
274 + return this.dtdAttList(node, options, level);
275 + case NodeType.ElementDeclaration:
276 + return this.dtdElement(node, options, level);
277 + case NodeType.EntityDeclaration:
278 + return this.dtdEntity(node, options, level);
279 + case NodeType.NotationDeclaration:
280 + return this.dtdNotation(node, options, level);
281 + default:
282 + throw new Error("Unknown XML node type: " + node.constructor.name);
283 + }
284 + };
285 +
286 + XMLWriterBase.prototype.processingInstruction = function(node, options, level) {
287 + var r;
288 + this.openNode(node, options, level);
289 + options.state = WriterState.OpenTag;
290 + r = this.indent(node, options, level) + '<?';
291 + options.state = WriterState.InsideTag;
292 + r += node.target;
293 + if (node.value) {
294 + r += ' ' + node.value;
295 + }
296 + options.state = WriterState.CloseTag;
297 + r += options.spaceBeforeSlash + '?>';
298 + r += this.endline(node, options, level);
299 + options.state = WriterState.None;
300 + this.closeNode(node, options, level);
301 + return r;
302 + };
303 +
304 + XMLWriterBase.prototype.raw = function(node, options, level) {
305 + var r;
306 + this.openNode(node, options, level);
307 + options.state = WriterState.OpenTag;
308 + r = this.indent(node, options, level);
309 + options.state = WriterState.InsideTag;
310 + r += node.value;
311 + options.state = WriterState.CloseTag;
312 + r += this.endline(node, options, level);
313 + options.state = WriterState.None;
314 + this.closeNode(node, options, level);
315 + return r;
316 + };
317 +
318 + XMLWriterBase.prototype.text = function(node, options, level) {
319 + var r;
320 + this.openNode(node, options, level);
321 + options.state = WriterState.OpenTag;
322 + r = this.indent(node, options, level);
323 + options.state = WriterState.InsideTag;
324 + r += node.value;
325 + options.state = WriterState.CloseTag;
326 + r += this.endline(node, options, level);
327 + options.state = WriterState.None;
328 + this.closeNode(node, options, level);
329 + return r;
330 + };
331 +
332 + XMLWriterBase.prototype.dtdAttList = function(node, options, level) {
333 + var r;
334 + this.openNode(node, options, level);
335 + options.state = WriterState.OpenTag;
336 + r = this.indent(node, options, level) + '<!ATTLIST';
337 + options.state = WriterState.InsideTag;
338 + r += ' ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
339 + if (node.defaultValueType !== '#DEFAULT') {
340 + r += ' ' + node.defaultValueType;
341 + }
342 + if (node.defaultValue) {
343 + r += ' "' + node.defaultValue + '"';
344 + }
345 + options.state = WriterState.CloseTag;
346 + r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
347 + options.state = WriterState.None;
348 + this.closeNode(node, options, level);
349 + return r;
350 + };
351 +
352 + XMLWriterBase.prototype.dtdElement = function(node, options, level) {
353 + var r;
354 + this.openNode(node, options, level);
355 + options.state = WriterState.OpenTag;
356 + r = this.indent(node, options, level) + '<!ELEMENT';
357 + options.state = WriterState.InsideTag;
358 + r += ' ' + node.name + ' ' + node.value;
359 + options.state = WriterState.CloseTag;
360 + r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
361 + options.state = WriterState.None;
362 + this.closeNode(node, options, level);
363 + return r;
364 + };
365 +
366 + XMLWriterBase.prototype.dtdEntity = function(node, options, level) {
367 + var r;
368 + this.openNode(node, options, level);
369 + options.state = WriterState.OpenTag;
370 + r = this.indent(node, options, level) + '<!ENTITY';
371 + options.state = WriterState.InsideTag;
372 + if (node.pe) {
373 + r += ' %';
374 + }
375 + r += ' ' + node.name;
376 + if (node.value) {
377 + r += ' "' + node.value + '"';
378 + } else {
379 + if (node.pubID && node.sysID) {
380 + r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
381 + } else if (node.sysID) {
382 + r += ' SYSTEM "' + node.sysID + '"';
383 + }
384 + if (node.nData) {
385 + r += ' NDATA ' + node.nData;
386 + }
387 + }
388 + options.state = WriterState.CloseTag;
389 + r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
390 + options.state = WriterState.None;
391 + this.closeNode(node, options, level);
392 + return r;
393 + };
394 +
395 + XMLWriterBase.prototype.dtdNotation = function(node, options, level) {
396 + var r;
397 + this.openNode(node, options, level);
398 + options.state = WriterState.OpenTag;
399 + r = this.indent(node, options, level) + '<!NOTATION';
400 + options.state = WriterState.InsideTag;
401 + r += ' ' + node.name;
402 + if (node.pubID && node.sysID) {
403 + r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
404 + } else if (node.pubID) {
405 + r += ' PUBLIC "' + node.pubID + '"';
406 + } else if (node.sysID) {
407 + r += ' SYSTEM "' + node.sysID + '"';
408 + }
409 + options.state = WriterState.CloseTag;
410 + r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
411 + options.state = WriterState.None;
412 + this.closeNode(node, options, level);
413 + return r;
414 + };
415 +
416 + XMLWriterBase.prototype.openNode = function(node, options, level) {};
417 +
418 + XMLWriterBase.prototype.closeNode = function(node, options, level) {};
419 +
420 + XMLWriterBase.prototype.openAttribute = function(att, options, level) {};
421 +
422 + XMLWriterBase.prototype.closeAttribute = function(att, options, level) {};
423 +
424 + return XMLWriterBase;
425 +
426 + })();
427 +
428 +}).call(this);
1 +// Generated by CoffeeScript 1.12.7
2 +(function() {
3 + var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
4 +
5 + ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
6 +
7 + XMLDOMImplementation = require('./XMLDOMImplementation');
8 +
9 + XMLDocument = require('./XMLDocument');
10 +
11 + XMLDocumentCB = require('./XMLDocumentCB');
12 +
13 + XMLStringWriter = require('./XMLStringWriter');
14 +
15 + XMLStreamWriter = require('./XMLStreamWriter');
16 +
17 + NodeType = require('./NodeType');
18 +
19 + WriterState = require('./WriterState');
20 +
21 + module.exports.create = function(name, xmldec, doctype, options) {
22 + var doc, root;
23 + if (name == null) {
24 + throw new Error("Root element needs a name.");
25 + }
26 + options = assign({}, xmldec, doctype, options);
27 + doc = new XMLDocument(options);
28 + root = doc.element(name);
29 + if (!options.headless) {
30 + doc.declaration(options);
31 + if ((options.pubID != null) || (options.sysID != null)) {
32 + doc.dtd(options);
33 + }
34 + }
35 + return root;
36 + };
37 +
38 + module.exports.begin = function(options, onData, onEnd) {
39 + var ref1;
40 + if (isFunction(options)) {
41 + ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
42 + options = {};
43 + }
44 + if (onData) {
45 + return new XMLDocumentCB(options, onData, onEnd);
46 + } else {
47 + return new XMLDocument(options);
48 + }
49 + };
50 +
51 + module.exports.stringWriter = function(options) {
52 + return new XMLStringWriter(options);
53 + };
54 +
55 + module.exports.streamWriter = function(stream, options) {
56 + return new XMLStreamWriter(stream, options);
57 + };
58 +
59 + module.exports.implementation = new XMLDOMImplementation();
60 +
61 + module.exports.nodeType = NodeType;
62 +
63 + module.exports.writerState = WriterState;
64 +
65 +}).call(this);
1 +{
2 + "name": "xmlbuilder",
3 + "version": "11.0.1",
4 + "keywords": [
5 + "xml",
6 + "xmlbuilder"
7 + ],
8 + "homepage": "http://github.com/oozcitak/xmlbuilder-js",
9 + "description": "An XML builder for node.js",
10 + "author": "Ozgur Ozcitak <oozcitak@gmail.com>",
11 + "contributors": [],
12 + "license": "MIT",
13 + "repository": {
14 + "type": "git",
15 + "url": "git://github.com/oozcitak/xmlbuilder-js.git"
16 + },
17 + "bugs": {
18 + "url": "http://github.com/oozcitak/xmlbuilder-js/issues"
19 + },
20 + "main": "./lib/index",
21 + "typings": "./typings/index.d.ts",
22 + "engines": {
23 + "node": ">=4.0"
24 + },
25 + "dependencies": {},
26 + "devDependencies": {
27 + "coffeescript": "1.*",
28 + "mocha": "*",
29 + "coffee-coverage": "2.*",
30 + "istanbul": "*",
31 + "coveralls": "*",
32 + "xpath": "*"
33 + },
34 + "scripts": {
35 + "prepublishOnly": "coffee -co lib src",
36 + "postpublish": "rm -rf lib",
37 + "test": "mocha \"test/**/*.coffee\" && istanbul report text lcov"
38 + }
39 +}
1 +// Type definitions for xmlbuilder
2 +// Project: https://github.com/oozcitak/xmlbuilder-js
3 +// Definitions by: Wallymathieu <https://github.com/wallymathieu>
4 +// : GaikwadPratik <https://github.com/GaikwadPratik>
5 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6 +
7 +export = xmlbuilder;
8 +
9 +declare namespace xmlbuilder {
10 +
11 + class XMLDocType {
12 + clone(): XMLDocType;
13 + element(name: string, value?: Object): XMLDocType;
14 + attList(elementName: string, attributeName: string, attributeType: string, defaultValueType?: string, defaultValue?: any): XMLDocType;
15 + entity(name: string, value: any): XMLDocType;
16 + pEntity(name: string, value: any): XMLDocType;
17 + notation(name: string, value: any): XMLDocType;
18 + cdata(value: string): XMLDocType;
19 + comment(value: string): XMLDocType;
20 + instruction(target: string, value: any): XMLDocType;
21 + root(): XMLDocType;
22 + document(): any;
23 + toString(options?: XMLToStringOptions, level?: Number): string;
24 +
25 + ele(name: string, value?: Object): XMLDocType;
26 + att(elementName: string, attributeName: string, attributeType: string, defaultValueType?: string, defaultValue?: any): XMLDocType;
27 + ent(name: string, value: any): XMLDocType;
28 + pent(name: string, value: any): XMLDocType;
29 + not(name: string, value: any): XMLDocType;
30 + dat(value: string): XMLDocType;
31 + com(value: string): XMLDocType;
32 + ins(target: string, value: any): XMLDocType;
33 + up(): XMLDocType;
34 + doc(): any;
35 + }
36 +
37 + class XMLElementOrXMLNode {
38 + // XMLElement:
39 + clone(): XMLElementOrXMLNode;
40 + attribute(name: any, value?: any): XMLElementOrXMLNode;
41 + att(name: any, value?: any): XMLElementOrXMLNode;
42 + removeAttribute(name: string): XMLElementOrXMLNode;
43 + instruction(target: string, value: any): XMLElementOrXMLNode;
44 + instruction(array: Array<any>): XMLElementOrXMLNode;
45 + instruction(obj: Object): XMLElementOrXMLNode;
46 + ins(target: string, value: any): XMLElementOrXMLNode;
47 + ins(array: Array<any>): XMLElementOrXMLNode;
48 + ins(obj: Object): XMLElementOrXMLNode;
49 + a(name: any, value?: any): XMLElementOrXMLNode;
50 + i(target: string, value: any): XMLElementOrXMLNode;
51 + i(array: Array<any>): XMLElementOrXMLNode;
52 + i(obj: Object): XMLElementOrXMLNode;
53 + toString(options?: XMLToStringOptions, level?: Number): string;
54 + // XMLNode:
55 + element(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
56 + ele(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
57 + insertBefore(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
58 + insertAfter(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
59 + remove(): XMLElementOrXMLNode;
60 + node(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
61 + text(value: string): XMLElementOrXMLNode;
62 + cdata(value: string): XMLElementOrXMLNode;
63 + comment(value: string): XMLElementOrXMLNode;
64 + raw(value: string): XMLElementOrXMLNode;
65 + declaration(version: string, encoding: string, standalone: boolean): XMLElementOrXMLNode;
66 + doctype(pubID: string, sysID: string): XMLDocType;
67 + up(): XMLElementOrXMLNode;
68 + importDocument(input: XMLElementOrXMLNode): XMLElementOrXMLNode;
69 + root(): XMLElementOrXMLNode;
70 + document(): any;
71 + end(options?: XMLEndOptions): string;
72 + prev(): XMLElementOrXMLNode;
73 + next(): XMLElementOrXMLNode;
74 + nod(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
75 + txt(value: string): XMLElementOrXMLNode;
76 + dat(value: string): XMLElementOrXMLNode;
77 + com(value: string): XMLElementOrXMLNode;
78 + doc(): XMLElementOrXMLNode;
79 + dec(version: string, encoding: string, standalone: boolean): XMLElementOrXMLNode;
80 + dtd(pubID: string, sysID: string): XMLDocType;
81 + e(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
82 + n(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
83 + t(value: string): XMLElementOrXMLNode;
84 + d(value: string): XMLElementOrXMLNode;
85 + c(value: string): XMLElementOrXMLNode;
86 + r(value: string): XMLElementOrXMLNode;
87 + u(): XMLElementOrXMLNode;
88 + }
89 +
90 + interface XMLDec {
91 + version?: string;
92 + encoding?: string;
93 + standalone?: boolean;
94 + }
95 +
96 + interface XMLDtd {
97 + pubID?: string;
98 + sysID?: string;
99 + }
100 +
101 + interface XMLStringifier {
102 + [x: string]: ((v: any) => string) | string;
103 + }
104 +
105 + interface XMLWriter {
106 + [x: string]: ((e: XMLElementOrXMLNode, options: WriterOptions, level?: number) => void);
107 + }
108 +
109 + interface XMLCreateOptions {
110 + headless?: boolean;
111 + keepNullNodes?: boolean;
112 + keepNullAttributes?: boolean;
113 + ignoreDecorators?: boolean;
114 + separateArrayItems?: boolean;
115 + noDoubleEncoding?: boolean;
116 + stringify?: XMLStringifier;
117 + }
118 +
119 + interface XMLToStringOptions {
120 + pretty?: boolean;
121 + indent?: string;
122 + offset?: number;
123 + newline?: string;
124 + allowEmpty?: boolean;
125 + spacebeforeslash?: string;
126 + }
127 +
128 + interface XMLEndOptions extends XMLToStringOptions {
129 + writer?: XMLWriter;
130 + }
131 +
132 + interface WriterOptions {
133 + pretty?: boolean;
134 + indent?: string;
135 + newline?: string;
136 + offset?: number;
137 + allowEmpty?: boolean;
138 + dontPrettyTextNodes?: boolean;
139 + spaceBeforeSlash?: string | boolean;
140 + user? :any;
141 + state?: WriterState;
142 + }
143 +
144 + enum WriterState {
145 + None = 0,
146 + OpenTag = 1,
147 + InsideTag = 2,
148 + CloseTag = 3
149 + }
150 +
151 + function create(nameOrObjSpec: string | { [name: string]: Object }, xmldecOrOptions?: XMLDec | XMLCreateOptions, doctypeOrOptions?: XMLDtd | XMLCreateOptions, options?: XMLCreateOptions): XMLElementOrXMLNode;
152 + function begin(): XMLElementOrXMLNode;
153 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
12 "express": "^4.18.1", 12 "express": "^4.18.1",
13 "fs": "^0.0.1-security", 13 "fs": "^0.0.1-security",
14 "request": "^2.88.2", 14 "request": "^2.88.2",
15 - "xml-js": "^1.6.11" 15 + "xml-js": "^1.6.11",
16 + "xml2js": "^0.4.23"
16 } 17 }
17 }, 18 },
18 "node_modules/accepts": { 19 "node_modules/accepts": {
...@@ -995,6 +996,26 @@ ...@@ -995,6 +996,26 @@
995 "bin": { 996 "bin": {
996 "xml-js": "bin/cli.js" 997 "xml-js": "bin/cli.js"
997 } 998 }
999 + },
1000 + "node_modules/xml2js": {
1001 + "version": "0.4.23",
1002 + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
1003 + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
1004 + "dependencies": {
1005 + "sax": ">=0.6.0",
1006 + "xmlbuilder": "~11.0.0"
1007 + },
1008 + "engines": {
1009 + "node": ">=4.0.0"
1010 + }
1011 + },
1012 + "node_modules/xmlbuilder": {
1013 + "version": "11.0.1",
1014 + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
1015 + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
1016 + "engines": {
1017 + "node": ">=4.0"
1018 + }
998 } 1019 }
999 }, 1020 },
1000 "dependencies": { 1021 "dependencies": {
...@@ -1749,6 +1770,20 @@ ...@@ -1749,6 +1770,20 @@
1749 "requires": { 1770 "requires": {
1750 "sax": "^1.2.4" 1771 "sax": "^1.2.4"
1751 } 1772 }
1773 + },
1774 + "xml2js": {
1775 + "version": "0.4.23",
1776 + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
1777 + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
1778 + "requires": {
1779 + "sax": ">=0.6.0",
1780 + "xmlbuilder": "~11.0.0"
1781 + }
1782 + },
1783 + "xmlbuilder": {
1784 + "version": "11.0.1",
1785 + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
1786 + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA=="
1752 } 1787 }
1753 } 1788 }
1754 } 1789 }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 "express": "^4.18.1", 17 "express": "^4.18.1",
18 "fs": "^0.0.1-security", 18 "fs": "^0.0.1-security",
19 "request": "^2.88.2", 19 "request": "^2.88.2",
20 - "xml-js": "^1.6.11" 20 + "xml-js": "^1.6.11",
21 + "xml2js": "^0.4.23"
21 } 22 }
22 } 23 }
......
...@@ -3,6 +3,7 @@ const app = express(); ...@@ -3,6 +3,7 @@ const app = express();
3 const request = require("request"); 3 const request = require("request");
4 const convert = require("xml-js"); 4 const convert = require("xml-js");
5 const fs = require("fs"); 5 const fs = require("fs");
6 +const xml2js = require("xml2js");
6 7
7 // http://apis.data.go.kr/B090041/openapi/service/SpcdeInfoService/getHoliDeInfo?solYear=2019&solMonth=03&ServiceKey=서비스키 8 // http://apis.data.go.kr/B090041/openapi/service/SpcdeInfoService/getHoliDeInfo?solYear=2019&solMonth=03&ServiceKey=서비스키
8 9
...@@ -15,9 +16,10 @@ var url = ...@@ -15,9 +16,10 @@ var url =
15 var queryParams = "?" + "solYear" + "=" + "2022"; 16 var queryParams = "?" + "solYear" + "=" + "2022";
16 queryParams += "&" + "solMonth" + "=" + "05"; 17 queryParams += "&" + "solMonth" + "=" + "05";
17 queryParams += "&" + "ServiceKey" + "=" + SERVEICE_KEY; 18 queryParams += "&" + "ServiceKey" + "=" + SERVEICE_KEY;
19 +let requestUrl = url + queryParams;
20 +var text = "";
18 21
19 app.get("/", function (req, res) { 22 app.get("/", function (req, res) {
20 - let requestUrl = url + queryParams;
21 request.get(requestUrl, (err, res, body) => { 23 request.get(requestUrl, (err, res, body) => {
22 if (err) { 24 if (err) {
23 console.log("err => " + err); 25 console.log("err => " + err);
...@@ -25,12 +27,20 @@ app.get("/", function (req, res) { ...@@ -25,12 +27,20 @@ app.get("/", function (req, res) {
25 if (res.statusCode == 200) { 27 if (res.statusCode == 200) {
26 var result = body; 28 var result = body;
27 var xmlToJson = convert.xml2json(result, { compact: true, spaces: 4 }); 29 var xmlToJson = convert.xml2json(result, { compact: true, spaces: 4 });
30 + console.log(result);
28 console.log(xmlToJson); 31 console.log(xmlToJson);
29 fs.writeFileSync("holi.json", xmlToJson); 32 fs.writeFileSync("holi.json", xmlToJson);
33 + fs.writeFileSync("holi.xml", result);
34 + var parser = new xml2js.Parser();
35 + parser.parseString(result, function (err, res) {
36 + console.log(res);
37 + text = JSON.stringify(res);
38 + console.log(text);
39 + });
30 } 40 }
31 } 41 }
32 }); 42 });
33 - res.send("OK"); 43 + res.send(text);
34 }); 44 });
35 45
36 const port = 8080; 46 const port = 8080;
......