mirror of
https://github.com/sstent/node.git
synced 2026-03-15 09:26:06 +00:00
added todo and studff to test in app for tempdir detection
This commit is contained in:
2
app/node_modules/xml2js/.npmignore
generated
vendored
Normal file
2
app/node_modules/xml2js/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.swp
|
||||
node_modules
|
||||
12
app/node_modules/xml2js/Cakefile
generated
vendored
Normal file
12
app/node_modules/xml2js/Cakefile
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{spawn, exec} = require 'child_process'
|
||||
|
||||
task 'build', 'continually build the JavaScript code', ->
|
||||
coffee = spawn 'coffee', ['-cw', '-o', 'lib', 'src']
|
||||
coffee.stdout.on 'data', (data) -> console.log data.toString().trim()
|
||||
|
||||
task 'doc', 'rebuild the Docco documentation', ->
|
||||
exec([
|
||||
'docco src/xml2js.coffee'
|
||||
].join(' && '), (err) ->
|
||||
throw err if err
|
||||
)
|
||||
19
app/node_modules/xml2js/LICENSE
generated
vendored
Normal file
19
app/node_modules/xml2js/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright 2010, 2011. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
142
app/node_modules/xml2js/README.md
generated
vendored
Normal file
142
app/node_modules/xml2js/README.md
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
node-xml2js
|
||||
===========
|
||||
|
||||
Ever had the urge to parse XML? And wanted to access the data in some sane,
|
||||
easy way? Don't want to compile a C parser, for whatever reason? Then xml2js is
|
||||
what you're looking for!
|
||||
|
||||
Description
|
||||
===========
|
||||
|
||||
Simple XML to JavaScript object converter. Uses
|
||||
[sax-js](https://github.com/isaacs/sax-js/).
|
||||
|
||||
Note: If you're looking for a full DOM parser, you probably want
|
||||
[JSDom](https://github.com/tmpvar/jsdom).
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Simplest way to install `xml2js` is to use [npm](http://npmjs.org), just `npm
|
||||
install xml2js` which will download xml2js and all dependencies.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
This will have to do, unless you're looking for some fancy extensive
|
||||
documentation. If you're looking for every single option and usage, see the
|
||||
unit tests.
|
||||
|
||||
Simple as pie usage
|
||||
-------------------
|
||||
|
||||
The simplest way to use it, is to use the optional callback interface added in
|
||||
0.1.11. That's right, if you have been using xml-simple or a home-grown
|
||||
wrapper, this is for you:
|
||||
|
||||
```javascript
|
||||
var fs = require('fs'),
|
||||
xml2js = require('xml2js');
|
||||
|
||||
var parser = new xml2js.Parser();
|
||||
fs.readFile(__dirname + '/foo.xml', function(err, data) {
|
||||
parser.parseString(data, function (err, result) {
|
||||
console.dir(result);
|
||||
console.log('Done');
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
Look ma, no event listeners! Alternatively you can still use the traditional
|
||||
`addListener` variant:
|
||||
|
||||
```javascript
|
||||
var fs = require('fs'),
|
||||
xml2js = require('xml2js');
|
||||
|
||||
var parser = new xml2js.Parser();
|
||||
parser.addListener('end', function(result) {
|
||||
console.dir(result);
|
||||
console.log('Done.');
|
||||
});
|
||||
fs.readFile(__dirname + '/foo.xml', function(err, data) {
|
||||
parser.parseString(data);
|
||||
});
|
||||
```
|
||||
|
||||
You can also use xml2js from
|
||||
[CoffeeScript](http://jashkenas.github.com/coffee-script/), further reducing
|
||||
the clutter:
|
||||
|
||||
```coffeescript
|
||||
fs = require 'fs',
|
||||
xml2js = require 'xml2js'
|
||||
|
||||
parser = new xml2js.Parser()
|
||||
fs.readFile __dirname + '/foo.xml', (err, data) ->
|
||||
parser.parseString data, (err, result) ->
|
||||
console.dir result
|
||||
console.log 'Done.'
|
||||
```
|
||||
|
||||
So you wanna some JSON?
|
||||
-----------------------
|
||||
|
||||
Just wrap the `result` object in a call to `JSON.stringify` like this
|
||||
`JSON.stringify(result)`. You get a string containing the JSON representation
|
||||
of the parsed object that you can feed to JSON-hungry consumers.
|
||||
|
||||
Displaying results
|
||||
------------------
|
||||
|
||||
You might wonder why, using `console.dir` or `console.log` the output at some
|
||||
level is only `[Object]`. Don't worry, this is not because xml2js got lazy.
|
||||
That's because Node uses `util.inspect` to convert the object into strings and
|
||||
that function stops after `depth=2` which is a bit low for most XML.
|
||||
|
||||
To display the whole deal, you can use `console.log(util.inspect(result, false,
|
||||
null))`, which displays the whole result.
|
||||
|
||||
So much for that, but what if you use
|
||||
[eyes](https://github.com/cloudhead/eyes.js) for nice colored output and it
|
||||
truncates the output with `…`? Don't fear, there's also a solution for that,
|
||||
you just need to increase the `maxLength` limit by creating a custom inspector
|
||||
`var inspect = require('eyes').inspector({maxLength: false})` and then you can
|
||||
easily `inspect(result)`.
|
||||
|
||||
Options
|
||||
=======
|
||||
|
||||
Apart from the default settings, there is a number of options that can be
|
||||
specified for the parser. Options are specified by ``new Parser({optionName:
|
||||
value})``. Possible options are:
|
||||
|
||||
* `explicitCharkey` (default: `false`)
|
||||
* `trim` (default: `true`): Trim the whitespace at the beginning and end of
|
||||
text nodes.
|
||||
* `normalize` (default: `true`): Trim whitespaces inside text nodes.
|
||||
* `explicitRoot` (default: `false`): Set this if you want to get the root
|
||||
node in the resulting object.
|
||||
* `emptyTag` (default: `undefined`): what will the value of empty nodes be.
|
||||
Default is `{}`.
|
||||
* `explicitArray` (default: `false`): Always put child nodes in an array if
|
||||
true; otherwise an array is created only if there is more than one.
|
||||
* `ignoreAttrs` (default: `false`): Ignore all XML attributes and only create
|
||||
text nodes.
|
||||
* `mergeAttrs` (default: `false`): Merge attributes and child elements as
|
||||
properties of the parent, instead of keying attributes off a child
|
||||
attribute object. This option is ignored if `ignoreAttrs` is `false`.
|
||||
* `validator` (default `null`): You can specify a callable that validates
|
||||
the resulting structure somehow, however you want. See unit tests
|
||||
for an example.
|
||||
|
||||
These default settings are for backward-compatibility (and might change in the
|
||||
future). For the most 'clean' parsing, you should disable `normalize` and
|
||||
`trimming` and enable `explicitRoot`.
|
||||
|
||||
Running tests, development
|
||||
==========================
|
||||
|
||||
The development requirements are handled by npm, you just need to install
|
||||
them. We also have a number of unit tests, they can be run using `zap`
|
||||
directly from the project root.
|
||||
225
app/node_modules/xml2js/lib/xml2js.js
generated
vendored
Normal file
225
app/node_modules/xml2js/lib/xml2js.js
generated
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
// Generated by CoffeeScript 1.3.1
|
||||
(function() {
|
||||
var events, isEmpty, sax,
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__extends = 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; },
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
sax = require('sax');
|
||||
|
||||
events = require('events');
|
||||
|
||||
isEmpty = function(thing) {
|
||||
return typeof thing === "object" && (thing != null) && Object.keys(thing).length === 0;
|
||||
};
|
||||
|
||||
exports.defaults = {
|
||||
"0.1": {
|
||||
explicitCharkey: false,
|
||||
trim: true,
|
||||
normalize: true,
|
||||
attrkey: "@",
|
||||
charkey: "#",
|
||||
explicitArray: false,
|
||||
ignoreAttrs: false,
|
||||
mergeAttrs: false,
|
||||
explicitRoot: false,
|
||||
validator: null
|
||||
},
|
||||
"0.2": {
|
||||
explicitCharkey: false,
|
||||
trim: false,
|
||||
normalize: false,
|
||||
attrkey: "$",
|
||||
charkey: "_",
|
||||
explicitArray: true,
|
||||
ignoreAttrs: false,
|
||||
mergeAttrs: false,
|
||||
explicitRoot: true,
|
||||
validator: null
|
||||
}
|
||||
};
|
||||
|
||||
exports.ValidationError = (function(_super) {
|
||||
|
||||
__extends(ValidationError, _super);
|
||||
|
||||
ValidationError.name = 'ValidationError';
|
||||
|
||||
function ValidationError(message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
return ValidationError;
|
||||
|
||||
})(Error);
|
||||
|
||||
exports.Parser = (function(_super) {
|
||||
|
||||
__extends(Parser, _super);
|
||||
|
||||
Parser.name = 'Parser';
|
||||
|
||||
function Parser(opts) {
|
||||
this.parseString = __bind(this.parseString, this);
|
||||
|
||||
this.reset = __bind(this.reset, this);
|
||||
|
||||
var key, value, _ref;
|
||||
this.options = {};
|
||||
_ref = exports.defaults["0.1"];
|
||||
for (key in _ref) {
|
||||
if (!__hasProp.call(_ref, key)) continue;
|
||||
value = _ref[key];
|
||||
this.options[key] = value;
|
||||
}
|
||||
for (key in opts) {
|
||||
if (!__hasProp.call(opts, key)) continue;
|
||||
value = opts[key];
|
||||
this.options[key] = value;
|
||||
}
|
||||
this.reset();
|
||||
}
|
||||
|
||||
Parser.prototype.reset = function() {
|
||||
var attrkey, charkey, err, stack,
|
||||
_this = this;
|
||||
this.removeAllListeners();
|
||||
this.saxParser = sax.parser(true, {
|
||||
trim: false,
|
||||
normalize: false
|
||||
});
|
||||
err = false;
|
||||
this.saxParser.onerror = function(error) {
|
||||
if (!err) {
|
||||
err = true;
|
||||
return _this.emit("error", error);
|
||||
}
|
||||
};
|
||||
this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
|
||||
this.resultObject = null;
|
||||
stack = [];
|
||||
attrkey = this.options.attrkey;
|
||||
charkey = this.options.charkey;
|
||||
this.saxParser.onopentag = function(node) {
|
||||
var key, obj, _ref;
|
||||
obj = {};
|
||||
obj[charkey] = "";
|
||||
if (!_this.options.ignoreAttrs) {
|
||||
_ref = node.attributes;
|
||||
for (key in _ref) {
|
||||
if (!__hasProp.call(_ref, key)) continue;
|
||||
if (!(attrkey in obj) && !_this.options.mergeAttrs) {
|
||||
obj[attrkey] = {};
|
||||
}
|
||||
if (_this.options.mergeAttrs) {
|
||||
obj[key] = node.attributes[key];
|
||||
} else {
|
||||
obj[attrkey][key] = node.attributes[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
obj["#name"] = node.name;
|
||||
return stack.push(obj);
|
||||
};
|
||||
this.saxParser.onclosetag = function() {
|
||||
var node, nodeName, obj, old, s, xpath;
|
||||
obj = stack.pop();
|
||||
nodeName = obj["#name"];
|
||||
delete obj["#name"];
|
||||
s = stack[stack.length - 1];
|
||||
if (obj[charkey].match(/^\s*$/)) {
|
||||
delete obj[charkey];
|
||||
} else {
|
||||
if (_this.options.trim) {
|
||||
obj[charkey] = obj[charkey].trim();
|
||||
}
|
||||
if (_this.options.normalize) {
|
||||
obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
|
||||
}
|
||||
if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
|
||||
obj = obj[charkey];
|
||||
}
|
||||
}
|
||||
if (_this.options.emptyTag !== void 0 && isEmpty(obj)) {
|
||||
obj = _this.options.emptyTag;
|
||||
}
|
||||
if (_this.options.validator != null) {
|
||||
xpath = "/" + ((function() {
|
||||
var _i, _len, _results;
|
||||
_results = [];
|
||||
for (_i = 0, _len = stack.length; _i < _len; _i++) {
|
||||
node = stack[_i];
|
||||
_results.push(node["#name"]);
|
||||
}
|
||||
return _results;
|
||||
})()).concat(nodeName).join("/");
|
||||
obj = _this.options.validator(xpath, s && s[nodeName], obj);
|
||||
}
|
||||
if (stack.length > 0) {
|
||||
if (!_this.options.explicitArray) {
|
||||
if (!(nodeName in s)) {
|
||||
return s[nodeName] = obj;
|
||||
} else if (s[nodeName] instanceof Array) {
|
||||
return s[nodeName].push(obj);
|
||||
} else {
|
||||
old = s[nodeName];
|
||||
s[nodeName] = [old];
|
||||
return s[nodeName].push(obj);
|
||||
}
|
||||
} else {
|
||||
if (!(s[nodeName] instanceof Array)) {
|
||||
s[nodeName] = [];
|
||||
}
|
||||
return s[nodeName].push(obj);
|
||||
}
|
||||
} else {
|
||||
if (_this.options.explicitRoot) {
|
||||
old = obj;
|
||||
obj = {};
|
||||
obj[nodeName] = old;
|
||||
}
|
||||
_this.resultObject = obj;
|
||||
return _this.emit("end", _this.resultObject);
|
||||
}
|
||||
};
|
||||
return this.saxParser.ontext = this.saxParser.oncdata = function(text) {
|
||||
var s;
|
||||
s = stack[stack.length - 1];
|
||||
if (s) {
|
||||
return s[charkey] += text;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Parser.prototype.parseString = function(str, cb) {
|
||||
if ((cb != null) && typeof cb === "function") {
|
||||
this.on("end", function(result) {
|
||||
this.reset();
|
||||
return cb(null, result);
|
||||
});
|
||||
this.on("error", function(err) {
|
||||
this.reset();
|
||||
return cb(err);
|
||||
});
|
||||
}
|
||||
if (str.toString().trim() === '') {
|
||||
this.emit("end", null);
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
return this.saxParser.write(str.toString());
|
||||
} catch (ex) {
|
||||
if (ex instanceof exports.ValidationError) {
|
||||
return this.emit("error", ex.message);
|
||||
} else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return Parser;
|
||||
|
||||
})(events.EventEmitter);
|
||||
|
||||
}).call(this);
|
||||
9
app/node_modules/xml2js/node_modules/sax/AUTHORS
generated
vendored
Normal file
9
app/node_modules/xml2js/node_modules/sax/AUTHORS
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# contributors sorted by whether or not they're me.
|
||||
Isaac Z. Schlueter <i@izs.me>
|
||||
Stein Martin Hustad <stein@hustad.com>
|
||||
Mikeal Rogers <mikeal.rogers@gmail.com>
|
||||
Laurie Harper <laurie@holoweb.net>
|
||||
Jann Horn <jann@Jann-PC.fritz.box>
|
||||
Elijah Insua <tmpvar@gmail.com>
|
||||
Henry Rawas <henryr@schakra.com>
|
||||
Justin Makeig <jmpublic@makeig.com>
|
||||
23
app/node_modules/xml2js/node_modules/sax/LICENSE
generated
vendored
Normal file
23
app/node_modules/xml2js/node_modules/sax/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
215
app/node_modules/xml2js/node_modules/sax/README.md
generated
vendored
Normal file
215
app/node_modules/xml2js/node_modules/sax/README.md
generated
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
# sax js
|
||||
|
||||
A sax-style parser for XML and HTML.
|
||||
|
||||
Designed with [node](http://nodejs.org/) in mind, but should work fine in
|
||||
the browser or other CommonJS implementations.
|
||||
|
||||
## What This Is
|
||||
|
||||
* A very simple tool to parse through an XML string.
|
||||
* A stepping stone to a streaming HTML parser.
|
||||
* A handy way to deal with RSS and other mostly-ok-but-kinda-broken XML
|
||||
docs.
|
||||
|
||||
## What This Is (probably) Not
|
||||
|
||||
* An HTML Parser - That's a fine goal, but this isn't it. It's just
|
||||
XML.
|
||||
* A DOM Builder - You can use it to build an object model out of XML,
|
||||
but it doesn't do that out of the box.
|
||||
* XSLT - No DOM = no querying.
|
||||
* 100% Compliant with (some other SAX implementation) - Most SAX
|
||||
implementations are in Java and do a lot more than this does.
|
||||
* An XML Validator - It does a little validation when in strict mode, but
|
||||
not much.
|
||||
* A Schema-Aware XSD Thing - Schemas are an exercise in fetishistic
|
||||
masochism.
|
||||
* A DTD-aware Thing - Fetching DTDs is a much bigger job.
|
||||
|
||||
## Regarding `<!DOCTYPE`s and `<!ENTITY`s
|
||||
|
||||
The parser will handle the basic XML entities in text nodes and attribute
|
||||
values: `& < > ' "`. It's possible to define additional
|
||||
entities in XML by putting them in the DTD. This parser doesn't do anything
|
||||
with that. If you want to listen to the `ondoctype` event, and then fetch
|
||||
the doctypes, and read the entities and add them to `parser.ENTITIES`, then
|
||||
be my guest.
|
||||
|
||||
Unknown entities will fail in strict mode, and in loose mode, will pass
|
||||
through unmolested.
|
||||
|
||||
## Usage
|
||||
|
||||
var sax = require("./lib/sax"),
|
||||
strict = true, // set to false for html-mode
|
||||
parser = sax.parser(strict);
|
||||
|
||||
parser.onerror = function (e) {
|
||||
// an error happened.
|
||||
};
|
||||
parser.ontext = function (t) {
|
||||
// got some text. t is the string of text.
|
||||
};
|
||||
parser.onopentag = function (node) {
|
||||
// opened a tag. node has "name" and "attributes"
|
||||
};
|
||||
parser.onattribute = function (attr) {
|
||||
// an attribute. attr has "name" and "value"
|
||||
};
|
||||
parser.onend = function () {
|
||||
// parser stream is done, and ready to have more stuff written to it.
|
||||
};
|
||||
|
||||
parser.write('<xml>Hello, <who name="world">world</who>!</xml>').close();
|
||||
|
||||
// stream usage
|
||||
// takes the same options as the parser
|
||||
var saxStream = require("sax").createStream(strict, options)
|
||||
saxStream.on("error", function (e) {
|
||||
// unhandled errors will throw, since this is a proper node
|
||||
// event emitter.
|
||||
console.error("error!", e)
|
||||
// clear the error
|
||||
this._parser.error = null
|
||||
this._parser.resume()
|
||||
})
|
||||
saxStream.on("opentag", function (node) {
|
||||
// same object as above
|
||||
})
|
||||
// pipe is supported, and it's readable/writable
|
||||
// same chunks coming in also go out.
|
||||
fs.createReadStream("file.xml")
|
||||
.pipe(saxStream)
|
||||
.pipe(fs.createReadStream("file-copy.xml"))
|
||||
|
||||
|
||||
|
||||
## Arguments
|
||||
|
||||
Pass the following arguments to the parser function. All are optional.
|
||||
|
||||
`strict` - Boolean. Whether or not to be a jerk. Default: `false`.
|
||||
|
||||
`opt` - Object bag of settings regarding string formatting. All default to `false`.
|
||||
|
||||
Settings supported:
|
||||
|
||||
* `trim` - Boolean. Whether or not to trim text and comment nodes.
|
||||
* `normalize` - Boolean. If true, then turn any whitespace into a single
|
||||
space.
|
||||
* `lowercase` - Boolean. If true, then lowercase tag names and attribute names
|
||||
in loose mode, rather than uppercasing them.
|
||||
* `xmlns` - Boolean. If true, then namespaces are supported.
|
||||
|
||||
## Methods
|
||||
|
||||
`write` - Write bytes onto the stream. You don't have to do this all at
|
||||
once. You can keep writing as much as you want.
|
||||
|
||||
`close` - Close the stream. Once closed, no more data may be written until
|
||||
it is done processing the buffer, which is signaled by the `end` event.
|
||||
|
||||
`resume` - To gracefully handle errors, assign a listener to the `error`
|
||||
event. Then, when the error is taken care of, you can call `resume` to
|
||||
continue parsing. Otherwise, the parser will not continue while in an error
|
||||
state.
|
||||
|
||||
## Members
|
||||
|
||||
At all times, the parser object will have the following members:
|
||||
|
||||
`line`, `column`, `position` - Indications of the position in the XML
|
||||
document where the parser currently is looking.
|
||||
|
||||
`startTagPosition` - Indicates the position where the current tag starts.
|
||||
|
||||
`closed` - Boolean indicating whether or not the parser can be written to.
|
||||
If it's `true`, then wait for the `ready` event to write again.
|
||||
|
||||
`strict` - Boolean indicating whether or not the parser is a jerk.
|
||||
|
||||
`opt` - Any options passed into the constructor.
|
||||
|
||||
`tag` - The current tag being dealt with.
|
||||
|
||||
And a bunch of other stuff that you probably shouldn't touch.
|
||||
|
||||
## Events
|
||||
|
||||
All events emit with a single argument. To listen to an event, assign a
|
||||
function to `on<eventname>`. Functions get executed in the this-context of
|
||||
the parser object. The list of supported events are also in the exported
|
||||
`EVENTS` array.
|
||||
|
||||
When using the stream interface, assign handlers using the EventEmitter
|
||||
`on` function in the normal fashion.
|
||||
|
||||
`error` - Indication that something bad happened. The error will be hanging
|
||||
out on `parser.error`, and must be deleted before parsing can continue. By
|
||||
listening to this event, you can keep an eye on that kind of stuff. Note:
|
||||
this happens *much* more in strict mode. Argument: instance of `Error`.
|
||||
|
||||
`text` - Text node. Argument: string of text.
|
||||
|
||||
`doctype` - The `<!DOCTYPE` declaration. Argument: doctype string.
|
||||
|
||||
`processinginstruction` - Stuff like `<?xml foo="blerg" ?>`. Argument:
|
||||
object with `name` and `body` members. Attributes are not parsed, as
|
||||
processing instructions have implementation dependent semantics.
|
||||
|
||||
`sgmldeclaration` - Random SGML declarations. Stuff like `<!ENTITY p>`
|
||||
would trigger this kind of event. This is a weird thing to support, so it
|
||||
might go away at some point. SAX isn't intended to be used to parse SGML,
|
||||
after all.
|
||||
|
||||
`opentag` - An opening tag. Argument: object with `name` and `attributes`.
|
||||
In non-strict mode, tag names are uppercased, unless the `lowercase`
|
||||
option is set. If the `xmlns` option is set, then it will contain
|
||||
namespace binding information on the `ns` member, and will have a
|
||||
`local`, `prefix`, and `uri` member.
|
||||
|
||||
`closetag` - A closing tag. In loose mode, tags are auto-closed if their
|
||||
parent closes. In strict mode, well-formedness is enforced. Note that
|
||||
self-closing tags will have `closeTag` emitted immediately after `openTag`.
|
||||
Argument: tag name.
|
||||
|
||||
`attribute` - An attribute node. Argument: object with `name` and `value`.
|
||||
In non-strict mode, attribute names are uppercased, unless the `lowercase`
|
||||
option is set. If the `xmlns` option is set, it will also contains namespace
|
||||
information.
|
||||
|
||||
`comment` - A comment node. Argument: the string of the comment.
|
||||
|
||||
`opencdata` - The opening tag of a `<![CDATA[` block.
|
||||
|
||||
`cdata` - The text of a `<![CDATA[` block. Since `<![CDATA[` blocks can get
|
||||
quite large, this event may fire multiple times for a single block, if it
|
||||
is broken up into multiple `write()`s. Argument: the string of random
|
||||
character data.
|
||||
|
||||
`closecdata` - The closing tag (`]]>`) of a `<![CDATA[` block.
|
||||
|
||||
`opennamespace` - If the `xmlns` option is set, then this event will
|
||||
signal the start of a new namespace binding.
|
||||
|
||||
`closenamespace` - If the `xmlns` option is set, then this event will
|
||||
signal the end of a namespace binding.
|
||||
|
||||
`end` - Indication that the closed stream has ended.
|
||||
|
||||
`ready` - Indication that the stream has reset, and is ready to be written
|
||||
to.
|
||||
|
||||
`noscript` - In non-strict mode, `<script>` tags trigger a `"script"`
|
||||
event, and their contents are not checked for special xml characters.
|
||||
If you pass `noscript: true`, then this behavior is suppressed.
|
||||
|
||||
## Reporting Problems
|
||||
|
||||
It's best to write a failing test if you find an issue. I will always
|
||||
accept pull requests with failing tests if they demonstrate intended
|
||||
behavior, but it is very hard to figure out what issue you're describing
|
||||
without a test. Writing a test is also the best way for you yourself
|
||||
to figure out if you really understand the issue you think you have with
|
||||
sax-js.
|
||||
8002
app/node_modules/xml2js/node_modules/sax/examples/big-not-pretty.xml
generated
vendored
Normal file
8002
app/node_modules/xml2js/node_modules/sax/examples/big-not-pretty.xml
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
41
app/node_modules/xml2js/node_modules/sax/examples/example.js
generated
vendored
Normal file
41
app/node_modules/xml2js/node_modules/sax/examples/example.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
var fs = require("fs"),
|
||||
sys = require("sys"),
|
||||
path = require("path"),
|
||||
xml = fs.cat(path.join(__dirname, "test.xml")),
|
||||
sax = require("../lib/sax"),
|
||||
strict = sax.parser(true),
|
||||
loose = sax.parser(false, {trim:true}),
|
||||
inspector = function (ev) { return function (data) {
|
||||
// sys.error("");
|
||||
// sys.error(ev+": "+sys.inspect(data));
|
||||
// for (var i in data) sys.error(i+ " "+sys.inspect(data[i]));
|
||||
// sys.error(this.line+":"+this.column);
|
||||
}};
|
||||
|
||||
xml.addCallback(function (xml) {
|
||||
// strict.write(xml);
|
||||
|
||||
sax.EVENTS.forEach(function (ev) {
|
||||
loose["on"+ev] = inspector(ev);
|
||||
});
|
||||
loose.onend = function () {
|
||||
// sys.error("end");
|
||||
// sys.error(sys.inspect(loose));
|
||||
};
|
||||
|
||||
// do this one char at a time to verify that it works.
|
||||
// (function () {
|
||||
// if (xml) {
|
||||
// loose.write(xml.substr(0,1000));
|
||||
// xml = xml.substr(1000);
|
||||
// process.nextTick(arguments.callee);
|
||||
// } else loose.close();
|
||||
// })();
|
||||
|
||||
for (var i = 0; i < 1000; i ++) {
|
||||
loose.write(xml);
|
||||
loose.close();
|
||||
}
|
||||
|
||||
});
|
||||
58
app/node_modules/xml2js/node_modules/sax/examples/get-products.js
generated
vendored
Normal file
58
app/node_modules/xml2js/node_modules/sax/examples/get-products.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
// pull out /GeneralSearchResponse/categories/category/items/product tags
|
||||
// the rest we don't care about.
|
||||
|
||||
var sax = require("../lib/sax.js")
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
var xmlFile = path.resolve(__dirname, "shopping.xml")
|
||||
var util = require("util")
|
||||
var http = require("http")
|
||||
|
||||
fs.readFile(xmlFile, function (er, d) {
|
||||
http.createServer(function (req, res) {
|
||||
if (er) throw er
|
||||
var xmlstr = d.toString("utf8")
|
||||
|
||||
var parser = sax.parser(true)
|
||||
var products = []
|
||||
var product = null
|
||||
var currentTag = null
|
||||
|
||||
parser.onclosetag = function (tagName) {
|
||||
if (tagName === "product") {
|
||||
products.push(product)
|
||||
currentTag = product = null
|
||||
return
|
||||
}
|
||||
if (currentTag && currentTag.parent) {
|
||||
var p = currentTag.parent
|
||||
delete currentTag.parent
|
||||
currentTag = p
|
||||
}
|
||||
}
|
||||
|
||||
parser.onopentag = function (tag) {
|
||||
if (tag.name !== "product" && !product) return
|
||||
if (tag.name === "product") {
|
||||
product = tag
|
||||
}
|
||||
tag.parent = currentTag
|
||||
tag.children = []
|
||||
tag.parent && tag.parent.children.push(tag)
|
||||
currentTag = tag
|
||||
}
|
||||
|
||||
parser.ontext = function (text) {
|
||||
if (currentTag) currentTag.children.push(text)
|
||||
}
|
||||
|
||||
parser.onend = function () {
|
||||
var out = util.inspect(products, false, 3, true)
|
||||
res.writeHead(200, {"content-type":"application/json"})
|
||||
res.end("{\"ok\":true}")
|
||||
// res.end(JSON.stringify(products))
|
||||
}
|
||||
|
||||
parser.write(xmlstr).end()
|
||||
}).listen(1337)
|
||||
})
|
||||
4
app/node_modules/xml2js/node_modules/sax/examples/hello-world.js
generated
vendored
Normal file
4
app/node_modules/xml2js/node_modules/sax/examples/hello-world.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
require("http").createServer(function (req, res) {
|
||||
res.writeHead(200, {"content-type":"application/json"})
|
||||
res.end(JSON.stringify({ok: true}))
|
||||
}).listen(1337)
|
||||
8
app/node_modules/xml2js/node_modules/sax/examples/not-pretty.xml
generated
vendored
Normal file
8
app/node_modules/xml2js/node_modules/sax/examples/not-pretty.xml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<root>
|
||||
something<else> blerm <slurm
|
||||
|
||||
|
||||
attrib =
|
||||
"blorg" ></else><!-- COMMENT!
|
||||
|
||||
--><![CDATA[processing...]]> <selfclosing tag="blr>""/> a bit down here</root>
|
||||
74
app/node_modules/xml2js/node_modules/sax/examples/pretty-print.js
generated
vendored
Normal file
74
app/node_modules/xml2js/node_modules/sax/examples/pretty-print.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
var sax = require("../lib/sax")
|
||||
, printer = sax.createStream(false, {lowercasetags:true, trim:true})
|
||||
, fs = require("fs")
|
||||
|
||||
function entity (str) {
|
||||
return str.replace('"', '"')
|
||||
}
|
||||
|
||||
printer.tabstop = 2
|
||||
printer.level = 0
|
||||
printer.indent = function () {
|
||||
print("\n")
|
||||
for (var i = this.level; i > 0; i --) {
|
||||
for (var j = this.tabstop; j > 0; j --) {
|
||||
print(" ")
|
||||
}
|
||||
}
|
||||
}
|
||||
printer.on("opentag", function (tag) {
|
||||
this.indent()
|
||||
this.level ++
|
||||
print("<"+tag.name)
|
||||
for (var i in tag.attributes) {
|
||||
print(" "+i+"=\""+entity(tag.attributes[i])+"\"")
|
||||
}
|
||||
print(">")
|
||||
})
|
||||
|
||||
printer.on("text", ontext)
|
||||
printer.on("doctype", ontext)
|
||||
function ontext (text) {
|
||||
this.indent()
|
||||
print(text)
|
||||
}
|
||||
|
||||
printer.on("closetag", function (tag) {
|
||||
this.level --
|
||||
this.indent()
|
||||
print("</"+tag+">")
|
||||
})
|
||||
|
||||
printer.on("cdata", function (data) {
|
||||
this.indent()
|
||||
print("<![CDATA["+data+"]]>")
|
||||
})
|
||||
|
||||
printer.on("comment", function (comment) {
|
||||
this.indent()
|
||||
print("<!--"+comment+"-->")
|
||||
})
|
||||
|
||||
printer.on("error", function (error) {
|
||||
console.error(error)
|
||||
throw error
|
||||
})
|
||||
|
||||
if (!process.argv[2]) {
|
||||
throw new Error("Please provide an xml file to prettify\n"+
|
||||
"TODO: read from stdin or take a file")
|
||||
}
|
||||
var xmlfile = require("path").join(process.cwd(), process.argv[2])
|
||||
var fstr = fs.createReadStream(xmlfile, { encoding: "utf8" })
|
||||
|
||||
function print (c) {
|
||||
if (!process.stdout.write(c)) {
|
||||
fstr.pause()
|
||||
}
|
||||
}
|
||||
|
||||
process.stdout.on("drain", function () {
|
||||
fstr.resume()
|
||||
})
|
||||
|
||||
fstr.pipe(printer)
|
||||
2
app/node_modules/xml2js/node_modules/sax/examples/shopping.xml
generated
vendored
Normal file
2
app/node_modules/xml2js/node_modules/sax/examples/shopping.xml
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
870
app/node_modules/xml2js/node_modules/sax/examples/strict.dtd
generated
vendored
Normal file
870
app/node_modules/xml2js/node_modules/sax/examples/strict.dtd
generated
vendored
Normal file
@@ -0,0 +1,870 @@
|
||||
<!--
|
||||
This is HTML 4.01 Strict DTD, which excludes the presentation
|
||||
attributes and elements that W3C expects to phase out as
|
||||
support for style sheets matures. Authors should use the Strict
|
||||
DTD when possible, but may use the Transitional DTD when support
|
||||
for presentation attribute and elements is required.
|
||||
|
||||
HTML 4 includes mechanisms for style sheets, scripting,
|
||||
embedding objects, improved support for right to left and mixed
|
||||
direction text, and enhancements to forms for improved
|
||||
accessibility for people with disabilities.
|
||||
|
||||
Draft: $Date: 1999/12/24 23:37:48 $
|
||||
|
||||
Authors:
|
||||
Dave Raggett <dsr@w3.org>
|
||||
Arnaud Le Hors <lehors@w3.org>
|
||||
Ian Jacobs <ij@w3.org>
|
||||
|
||||
Further information about HTML 4.01 is available at:
|
||||
|
||||
http://www.w3.org/TR/1999/REC-html401-19991224
|
||||
|
||||
|
||||
The HTML 4.01 specification includes additional
|
||||
syntactic constraints that cannot be expressed within
|
||||
the DTDs.
|
||||
|
||||
-->
|
||||
<!--
|
||||
Typical usage:
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
...
|
||||
</head>
|
||||
<body>
|
||||
...
|
||||
</body>
|
||||
</html>
|
||||
|
||||
The URI used as a system identifier with the public identifier allows
|
||||
the user agent to download the DTD and entity sets as needed.
|
||||
|
||||
The FPI for the Transitional HTML 4.01 DTD is:
|
||||
|
||||
"-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
|
||||
This version of the transitional DTD is:
|
||||
|
||||
http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd
|
||||
|
||||
If you are writing a document that includes frames, use
|
||||
the following FPI:
|
||||
|
||||
"-//W3C//DTD HTML 4.01 Frameset//EN"
|
||||
|
||||
This version of the frameset DTD is:
|
||||
|
||||
http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd
|
||||
|
||||
Use the following (relative) URIs to refer to
|
||||
the DTDs and entity definitions of this specification:
|
||||
|
||||
"strict.dtd"
|
||||
"loose.dtd"
|
||||
"frameset.dtd"
|
||||
"HTMLlat1.ent"
|
||||
"HTMLsymbol.ent"
|
||||
"HTMLspecial.ent"
|
||||
|
||||
-->
|
||||
|
||||
<!--================== Imported Names ====================================-->
|
||||
<!-- Feature Switch for frameset documents -->
|
||||
<!ENTITY % HTML.Frameset "IGNORE">
|
||||
|
||||
<!ENTITY % ContentType "CDATA"
|
||||
-- media type, as per [RFC2045]
|
||||
-->
|
||||
|
||||
<!ENTITY % ContentTypes "CDATA"
|
||||
-- comma-separated list of media types, as per [RFC2045]
|
||||
-->
|
||||
|
||||
<!ENTITY % Charset "CDATA"
|
||||
-- a character encoding, as per [RFC2045]
|
||||
-->
|
||||
|
||||
<!ENTITY % Charsets "CDATA"
|
||||
-- a space-separated list of character encodings, as per [RFC2045]
|
||||
-->
|
||||
|
||||
<!ENTITY % LanguageCode "NAME"
|
||||
-- a language code, as per [RFC1766]
|
||||
-->
|
||||
|
||||
<!ENTITY % Character "CDATA"
|
||||
-- a single character from [ISO10646]
|
||||
-->
|
||||
|
||||
<!ENTITY % LinkTypes "CDATA"
|
||||
-- space-separated list of link types
|
||||
-->
|
||||
|
||||
<!ENTITY % MediaDesc "CDATA"
|
||||
-- single or comma-separated list of media descriptors
|
||||
-->
|
||||
|
||||
<!ENTITY % URI "CDATA"
|
||||
-- a Uniform Resource Identifier,
|
||||
see [URI]
|
||||
-->
|
||||
|
||||
<!ENTITY % Datetime "CDATA" -- date and time information. ISO date format -->
|
||||
|
||||
|
||||
<!ENTITY % Script "CDATA" -- script expression -->
|
||||
|
||||
<!ENTITY % StyleSheet "CDATA" -- style sheet data -->
|
||||
|
||||
|
||||
|
||||
<!ENTITY % Text "CDATA">
|
||||
|
||||
|
||||
<!-- Parameter Entities -->
|
||||
|
||||
<!ENTITY % head.misc "SCRIPT|STYLE|META|LINK|OBJECT" -- repeatable head elements -->
|
||||
|
||||
<!ENTITY % heading "H1|H2|H3|H4|H5|H6">
|
||||
|
||||
<!ENTITY % list "UL | OL">
|
||||
|
||||
<!ENTITY % preformatted "PRE">
|
||||
|
||||
|
||||
<!--================ Character mnemonic entities =========================-->
|
||||
|
||||
<!ENTITY % HTMLlat1 PUBLIC
|
||||
"-//W3C//ENTITIES Latin1//EN//HTML"
|
||||
"HTMLlat1.ent">
|
||||
%HTMLlat1;
|
||||
|
||||
<!ENTITY % HTMLsymbol PUBLIC
|
||||
"-//W3C//ENTITIES Symbols//EN//HTML"
|
||||
"HTMLsymbol.ent">
|
||||
%HTMLsymbol;
|
||||
|
||||
<!ENTITY % HTMLspecial PUBLIC
|
||||
"-//W3C//ENTITIES Special//EN//HTML"
|
||||
"HTMLspecial.ent">
|
||||
%HTMLspecial;
|
||||
<!--=================== Generic Attributes ===============================-->
|
||||
|
||||
<!ENTITY % coreattrs
|
||||
"id ID #IMPLIED -- document-wide unique id --
|
||||
class CDATA #IMPLIED -- space-separated list of classes --
|
||||
style %StyleSheet; #IMPLIED -- associated style info --
|
||||
title %Text; #IMPLIED -- advisory title --"
|
||||
>
|
||||
|
||||
<!ENTITY % i18n
|
||||
"lang %LanguageCode; #IMPLIED -- language code --
|
||||
dir (ltr|rtl) #IMPLIED -- direction for weak/neutral text --"
|
||||
>
|
||||
|
||||
<!ENTITY % events
|
||||
"onclick %Script; #IMPLIED -- a pointer button was clicked --
|
||||
ondblclick %Script; #IMPLIED -- a pointer button was double clicked--
|
||||
onmousedown %Script; #IMPLIED -- a pointer button was pressed down --
|
||||
onmouseup %Script; #IMPLIED -- a pointer button was released --
|
||||
onmouseover %Script; #IMPLIED -- a pointer was moved onto --
|
||||
onmousemove %Script; #IMPLIED -- a pointer was moved within --
|
||||
onmouseout %Script; #IMPLIED -- a pointer was moved away --
|
||||
onkeypress %Script; #IMPLIED -- a key was pressed and released --
|
||||
onkeydown %Script; #IMPLIED -- a key was pressed down --
|
||||
onkeyup %Script; #IMPLIED -- a key was released --"
|
||||
>
|
||||
|
||||
<!-- Reserved Feature Switch -->
|
||||
<!ENTITY % HTML.Reserved "IGNORE">
|
||||
|
||||
<!-- The following attributes are reserved for possible future use -->
|
||||
<![ %HTML.Reserved; [
|
||||
<!ENTITY % reserved
|
||||
"datasrc %URI; #IMPLIED -- a single or tabular Data Source --
|
||||
datafld CDATA #IMPLIED -- the property or column name --
|
||||
dataformatas (plaintext|html) plaintext -- text or html --"
|
||||
>
|
||||
]]>
|
||||
|
||||
<!ENTITY % reserved "">
|
||||
|
||||
<!ENTITY % attrs "%coreattrs; %i18n; %events;">
|
||||
|
||||
|
||||
<!--=================== Text Markup ======================================-->
|
||||
|
||||
<!ENTITY % fontstyle
|
||||
"TT | I | B | BIG | SMALL">
|
||||
|
||||
<!ENTITY % phrase "EM | STRONG | DFN | CODE |
|
||||
SAMP | KBD | VAR | CITE | ABBR | ACRONYM" >
|
||||
|
||||
<!ENTITY % special
|
||||
"A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO">
|
||||
|
||||
<!ENTITY % formctrl "INPUT | SELECT | TEXTAREA | LABEL | BUTTON">
|
||||
|
||||
<!-- %inline; covers inline or "text-level" elements -->
|
||||
<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">
|
||||
|
||||
<!ELEMENT (%fontstyle;|%phrase;) - - (%inline;)*>
|
||||
<!ATTLIST (%fontstyle;|%phrase;)
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!ELEMENT (SUB|SUP) - - (%inline;)* -- subscript, superscript -->
|
||||
<!ATTLIST (SUB|SUP)
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!ELEMENT SPAN - - (%inline;)* -- generic language/style container -->
|
||||
<!ATTLIST SPAN
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!ELEMENT BDO - - (%inline;)* -- I18N BiDi over-ride -->
|
||||
<!ATTLIST BDO
|
||||
%coreattrs; -- id, class, style, title --
|
||||
lang %LanguageCode; #IMPLIED -- language code --
|
||||
dir (ltr|rtl) #REQUIRED -- directionality --
|
||||
>
|
||||
|
||||
|
||||
<!ELEMENT BR - O EMPTY -- forced line break -->
|
||||
<!ATTLIST BR
|
||||
%coreattrs; -- id, class, style, title --
|
||||
>
|
||||
|
||||
<!--================== HTML content models ===============================-->
|
||||
|
||||
<!--
|
||||
HTML has two basic content models:
|
||||
|
||||
%inline; character level elements and text strings
|
||||
%block; block-like elements e.g. paragraphs and lists
|
||||
-->
|
||||
|
||||
<!ENTITY % block
|
||||
"P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
|
||||
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">
|
||||
|
||||
<!ENTITY % flow "%block; | %inline;">
|
||||
|
||||
<!--=================== Document Body ====================================-->
|
||||
|
||||
<!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body -->
|
||||
<!ATTLIST BODY
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
onload %Script; #IMPLIED -- the document has been loaded --
|
||||
onunload %Script; #IMPLIED -- the document has been removed --
|
||||
>
|
||||
|
||||
<!ELEMENT ADDRESS - - (%inline;)* -- information on author -->
|
||||
<!ATTLIST ADDRESS
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!ELEMENT DIV - - (%flow;)* -- generic language/style container -->
|
||||
<!ATTLIST DIV
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
|
||||
<!--================== The Anchor Element ================================-->
|
||||
|
||||
<!ENTITY % Shape "(rect|circle|poly|default)">
|
||||
<!ENTITY % Coords "CDATA" -- comma-separated list of lengths -->
|
||||
|
||||
<!ELEMENT A - - (%inline;)* -(A) -- anchor -->
|
||||
<!ATTLIST A
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
charset %Charset; #IMPLIED -- char encoding of linked resource --
|
||||
type %ContentType; #IMPLIED -- advisory content type --
|
||||
name CDATA #IMPLIED -- named link end --
|
||||
href %URI; #IMPLIED -- URI for linked resource --
|
||||
hreflang %LanguageCode; #IMPLIED -- language code --
|
||||
rel %LinkTypes; #IMPLIED -- forward link types --
|
||||
rev %LinkTypes; #IMPLIED -- reverse link types --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
shape %Shape; rect -- for use with client-side image maps --
|
||||
coords %Coords; #IMPLIED -- for use with client-side image maps --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
>
|
||||
|
||||
<!--================== Client-side image maps ============================-->
|
||||
|
||||
<!-- These can be placed in the same document or grouped in a
|
||||
separate document although this isn't yet widely supported -->
|
||||
|
||||
<!ELEMENT MAP - - ((%block;) | AREA)+ -- client-side image map -->
|
||||
<!ATTLIST MAP
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
name CDATA #REQUIRED -- for reference by usemap --
|
||||
>
|
||||
|
||||
<!ELEMENT AREA - O EMPTY -- client-side image map area -->
|
||||
<!ATTLIST AREA
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
shape %Shape; rect -- controls interpretation of coords --
|
||||
coords %Coords; #IMPLIED -- comma-separated list of lengths --
|
||||
href %URI; #IMPLIED -- URI for linked resource --
|
||||
nohref (nohref) #IMPLIED -- this region has no action --
|
||||
alt %Text; #REQUIRED -- short description --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
>
|
||||
|
||||
<!--================== The LINK Element ==================================-->
|
||||
|
||||
<!--
|
||||
Relationship values can be used in principle:
|
||||
|
||||
a) for document specific toolbars/menus when used
|
||||
with the LINK element in document head e.g.
|
||||
start, contents, previous, next, index, end, help
|
||||
b) to link to a separate style sheet (rel=stylesheet)
|
||||
c) to make a link to a script (rel=script)
|
||||
d) by stylesheets to control how collections of
|
||||
html nodes are rendered into printed documents
|
||||
e) to make a link to a printable version of this document
|
||||
e.g. a postscript or pdf version (rel=alternate media=print)
|
||||
-->
|
||||
|
||||
<!ELEMENT LINK - O EMPTY -- a media-independent link -->
|
||||
<!ATTLIST LINK
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
charset %Charset; #IMPLIED -- char encoding of linked resource --
|
||||
href %URI; #IMPLIED -- URI for linked resource --
|
||||
hreflang %LanguageCode; #IMPLIED -- language code --
|
||||
type %ContentType; #IMPLIED -- advisory content type --
|
||||
rel %LinkTypes; #IMPLIED -- forward link types --
|
||||
rev %LinkTypes; #IMPLIED -- reverse link types --
|
||||
media %MediaDesc; #IMPLIED -- for rendering on these media --
|
||||
>
|
||||
|
||||
<!--=================== Images ===========================================-->
|
||||
|
||||
<!-- Length defined in strict DTD for cellpadding/cellspacing -->
|
||||
<!ENTITY % Length "CDATA" -- nn for pixels or nn% for percentage length -->
|
||||
<!ENTITY % MultiLength "CDATA" -- pixel, percentage, or relative -->
|
||||
|
||||
<![ %HTML.Frameset; [
|
||||
<!ENTITY % MultiLengths "CDATA" -- comma-separated list of MultiLength -->
|
||||
]]>
|
||||
|
||||
<!ENTITY % Pixels "CDATA" -- integer representing length in pixels -->
|
||||
|
||||
|
||||
<!-- To avoid problems with text-only UAs as well as
|
||||
to make image content understandable and navigable
|
||||
to users of non-visual UAs, you need to provide
|
||||
a description with ALT, and avoid server-side image maps -->
|
||||
<!ELEMENT IMG - O EMPTY -- Embedded image -->
|
||||
<!ATTLIST IMG
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
src %URI; #REQUIRED -- URI of image to embed --
|
||||
alt %Text; #REQUIRED -- short description --
|
||||
longdesc %URI; #IMPLIED -- link to long description
|
||||
(complements alt) --
|
||||
name CDATA #IMPLIED -- name of image for scripting --
|
||||
height %Length; #IMPLIED -- override height --
|
||||
width %Length; #IMPLIED -- override width --
|
||||
usemap %URI; #IMPLIED -- use client-side image map --
|
||||
ismap (ismap) #IMPLIED -- use server-side image map --
|
||||
>
|
||||
|
||||
<!-- USEMAP points to a MAP element which may be in this document
|
||||
or an external document, although the latter is not widely supported -->
|
||||
|
||||
<!--==================== OBJECT ======================================-->
|
||||
<!--
|
||||
OBJECT is used to embed objects as part of HTML pages
|
||||
PARAM elements should precede other content. SGML mixed content
|
||||
model technicality precludes specifying this formally ...
|
||||
-->
|
||||
|
||||
<!ELEMENT OBJECT - - (PARAM | %flow;)*
|
||||
-- generic embedded object -->
|
||||
<!ATTLIST OBJECT
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
declare (declare) #IMPLIED -- declare but don't instantiate flag --
|
||||
classid %URI; #IMPLIED -- identifies an implementation --
|
||||
codebase %URI; #IMPLIED -- base URI for classid, data, archive--
|
||||
data %URI; #IMPLIED -- reference to object's data --
|
||||
type %ContentType; #IMPLIED -- content type for data --
|
||||
codetype %ContentType; #IMPLIED -- content type for code --
|
||||
archive CDATA #IMPLIED -- space-separated list of URIs --
|
||||
standby %Text; #IMPLIED -- message to show while loading --
|
||||
height %Length; #IMPLIED -- override height --
|
||||
width %Length; #IMPLIED -- override width --
|
||||
usemap %URI; #IMPLIED -- use client-side image map --
|
||||
name CDATA #IMPLIED -- submit as part of form --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!ELEMENT PARAM - O EMPTY -- named property value -->
|
||||
<!ATTLIST PARAM
|
||||
id ID #IMPLIED -- document-wide unique id --
|
||||
name CDATA #REQUIRED -- property name --
|
||||
value CDATA #IMPLIED -- property value --
|
||||
valuetype (DATA|REF|OBJECT) DATA -- How to interpret value --
|
||||
type %ContentType; #IMPLIED -- content type for value
|
||||
when valuetype=ref --
|
||||
>
|
||||
|
||||
|
||||
<!--=================== Horizontal Rule ==================================-->
|
||||
|
||||
<!ELEMENT HR - O EMPTY -- horizontal rule -->
|
||||
<!ATTLIST HR
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--=================== Paragraphs =======================================-->
|
||||
|
||||
<!ELEMENT P - O (%inline;)* -- paragraph -->
|
||||
<!ATTLIST P
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--=================== Headings =========================================-->
|
||||
|
||||
<!--
|
||||
There are six levels of headings from H1 (the most important)
|
||||
to H6 (the least important).
|
||||
-->
|
||||
|
||||
<!ELEMENT (%heading;) - - (%inline;)* -- heading -->
|
||||
<!ATTLIST (%heading;)
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--=================== Preformatted Text ================================-->
|
||||
|
||||
<!-- excludes markup for images and changes in font size -->
|
||||
<!ENTITY % pre.exclusion "IMG|OBJECT|BIG|SMALL|SUB|SUP">
|
||||
|
||||
<!ELEMENT PRE - - (%inline;)* -(%pre.exclusion;) -- preformatted text -->
|
||||
<!ATTLIST PRE
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--===================== Inline Quotes ==================================-->
|
||||
|
||||
<!ELEMENT Q - - (%inline;)* -- short inline quotation -->
|
||||
<!ATTLIST Q
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
cite %URI; #IMPLIED -- URI for source document or msg --
|
||||
>
|
||||
|
||||
<!--=================== Block-like Quotes ================================-->
|
||||
|
||||
<!ELEMENT BLOCKQUOTE - - (%block;|SCRIPT)+ -- long quotation -->
|
||||
<!ATTLIST BLOCKQUOTE
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
cite %URI; #IMPLIED -- URI for source document or msg --
|
||||
>
|
||||
|
||||
<!--=================== Inserted/Deleted Text ============================-->
|
||||
|
||||
|
||||
<!-- INS/DEL are handled by inclusion on BODY -->
|
||||
<!ELEMENT (INS|DEL) - - (%flow;)* -- inserted text, deleted text -->
|
||||
<!ATTLIST (INS|DEL)
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
cite %URI; #IMPLIED -- info on reason for change --
|
||||
datetime %Datetime; #IMPLIED -- date and time of change --
|
||||
>
|
||||
|
||||
<!--=================== Lists ============================================-->
|
||||
|
||||
<!-- definition lists - DT for term, DD for its definition -->
|
||||
|
||||
<!ELEMENT DL - - (DT|DD)+ -- definition list -->
|
||||
<!ATTLIST DL
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!ELEMENT DT - O (%inline;)* -- definition term -->
|
||||
<!ELEMENT DD - O (%flow;)* -- definition description -->
|
||||
<!ATTLIST (DT|DD)
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
|
||||
<!ELEMENT OL - - (LI)+ -- ordered list -->
|
||||
<!ATTLIST OL
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!-- Unordered Lists (UL) bullet styles -->
|
||||
<!ELEMENT UL - - (LI)+ -- unordered list -->
|
||||
<!ATTLIST UL
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
|
||||
|
||||
<!ELEMENT LI - O (%flow;)* -- list item -->
|
||||
<!ATTLIST LI
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--================ Forms ===============================================-->
|
||||
<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->
|
||||
<!ATTLIST FORM
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
action %URI; #REQUIRED -- server-side form handler --
|
||||
method (GET|POST) GET -- HTTP method used to submit the form--
|
||||
enctype %ContentType; "application/x-www-form-urlencoded"
|
||||
accept %ContentTypes; #IMPLIED -- list of MIME types for file upload --
|
||||
name CDATA #IMPLIED -- name of form for scripting --
|
||||
onsubmit %Script; #IMPLIED -- the form was submitted --
|
||||
onreset %Script; #IMPLIED -- the form was reset --
|
||||
accept-charset %Charsets; #IMPLIED -- list of supported charsets --
|
||||
>
|
||||
|
||||
<!-- Each label must not contain more than ONE field -->
|
||||
<!ELEMENT LABEL - - (%inline;)* -(LABEL) -- form field label text -->
|
||||
<!ATTLIST LABEL
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
for IDREF #IMPLIED -- matches field ID value --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
>
|
||||
|
||||
<!ENTITY % InputType
|
||||
"(TEXT | PASSWORD | CHECKBOX |
|
||||
RADIO | SUBMIT | RESET |
|
||||
FILE | HIDDEN | IMAGE | BUTTON)"
|
||||
>
|
||||
|
||||
<!-- attribute name required for all but submit and reset -->
|
||||
<!ELEMENT INPUT - O EMPTY -- form control -->
|
||||
<!ATTLIST INPUT
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
type %InputType; TEXT -- what kind of widget is needed --
|
||||
name CDATA #IMPLIED -- submit as part of form --
|
||||
value CDATA #IMPLIED -- Specify for radio buttons and checkboxes --
|
||||
checked (checked) #IMPLIED -- for radio buttons and check boxes --
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
readonly (readonly) #IMPLIED -- for text and passwd --
|
||||
size CDATA #IMPLIED -- specific to each type of field --
|
||||
maxlength NUMBER #IMPLIED -- max chars for text fields --
|
||||
src %URI; #IMPLIED -- for fields with images --
|
||||
alt CDATA #IMPLIED -- short description --
|
||||
usemap %URI; #IMPLIED -- use client-side image map --
|
||||
ismap (ismap) #IMPLIED -- use server-side image map --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
onselect %Script; #IMPLIED -- some text was selected --
|
||||
onchange %Script; #IMPLIED -- the element value was changed --
|
||||
accept %ContentTypes; #IMPLIED -- list of MIME types for file upload --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector -->
|
||||
<!ATTLIST SELECT
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
name CDATA #IMPLIED -- field name --
|
||||
size NUMBER #IMPLIED -- rows visible --
|
||||
multiple (multiple) #IMPLIED -- default is single selection --
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
onchange %Script; #IMPLIED -- the element value was changed --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!ELEMENT OPTGROUP - - (OPTION)+ -- option group -->
|
||||
<!ATTLIST OPTGROUP
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
label %Text; #REQUIRED -- for use in hierarchical menus --
|
||||
>
|
||||
|
||||
<!ELEMENT OPTION - O (#PCDATA) -- selectable choice -->
|
||||
<!ATTLIST OPTION
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
selected (selected) #IMPLIED
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
label %Text; #IMPLIED -- for use in hierarchical menus --
|
||||
value CDATA #IMPLIED -- defaults to element content --
|
||||
>
|
||||
|
||||
<!ELEMENT TEXTAREA - - (#PCDATA) -- multi-line text field -->
|
||||
<!ATTLIST TEXTAREA
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
name CDATA #IMPLIED
|
||||
rows NUMBER #REQUIRED
|
||||
cols NUMBER #REQUIRED
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
readonly (readonly) #IMPLIED
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
onselect %Script; #IMPLIED -- some text was selected --
|
||||
onchange %Script; #IMPLIED -- the element value was changed --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!--
|
||||
#PCDATA is to solve the mixed content problem,
|
||||
per specification only whitespace is allowed there!
|
||||
-->
|
||||
<!ELEMENT FIELDSET - - (#PCDATA,LEGEND,(%flow;)*) -- form control group -->
|
||||
<!ATTLIST FIELDSET
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!ELEMENT LEGEND - - (%inline;)* -- fieldset legend -->
|
||||
|
||||
<!ATTLIST LEGEND
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
>
|
||||
|
||||
<!ELEMENT BUTTON - -
|
||||
(%flow;)* -(A|%formctrl;|FORM|FIELDSET)
|
||||
-- push button -->
|
||||
<!ATTLIST BUTTON
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
name CDATA #IMPLIED
|
||||
value CDATA #IMPLIED -- sent to server when submitted --
|
||||
type (button|submit|reset) submit -- for use as form button --
|
||||
disabled (disabled) #IMPLIED -- unavailable in this context --
|
||||
tabindex NUMBER #IMPLIED -- position in tabbing order --
|
||||
accesskey %Character; #IMPLIED -- accessibility key character --
|
||||
onfocus %Script; #IMPLIED -- the element got the focus --
|
||||
onblur %Script; #IMPLIED -- the element lost the focus --
|
||||
%reserved; -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!--======================= Tables =======================================-->
|
||||
|
||||
<!-- IETF HTML table standard, see [RFC1942] -->
|
||||
|
||||
<!--
|
||||
The BORDER attribute sets the thickness of the frame around the
|
||||
table. The default units are screen pixels.
|
||||
|
||||
The FRAME attribute specifies which parts of the frame around
|
||||
the table should be rendered. The values are not the same as
|
||||
CALS to avoid a name clash with the VALIGN attribute.
|
||||
|
||||
The value "border" is included for backwards compatibility with
|
||||
<TABLE BORDER> which yields frame=border and border=implied
|
||||
For <TABLE BORDER=1> you get border=1 and frame=implied. In this
|
||||
case, it is appropriate to treat this as frame=border for backwards
|
||||
compatibility with deployed browsers.
|
||||
-->
|
||||
<!ENTITY % TFrame "(void|above|below|hsides|lhs|rhs|vsides|box|border)">
|
||||
|
||||
<!--
|
||||
The RULES attribute defines which rules to draw between cells:
|
||||
|
||||
If RULES is absent then assume:
|
||||
"none" if BORDER is absent or BORDER=0 otherwise "all"
|
||||
-->
|
||||
|
||||
<!ENTITY % TRules "(none | groups | rows | cols | all)">
|
||||
|
||||
<!-- horizontal placement of table relative to document -->
|
||||
<!ENTITY % TAlign "(left|center|right)">
|
||||
|
||||
<!-- horizontal alignment attributes for cell contents -->
|
||||
<!ENTITY % cellhalign
|
||||
"align (left|center|right|justify|char) #IMPLIED
|
||||
char %Character; #IMPLIED -- alignment char, e.g. char=':' --
|
||||
charoff %Length; #IMPLIED -- offset for alignment char --"
|
||||
>
|
||||
|
||||
<!-- vertical alignment attributes for cell contents -->
|
||||
<!ENTITY % cellvalign
|
||||
"valign (top|middle|bottom|baseline) #IMPLIED"
|
||||
>
|
||||
|
||||
<!ELEMENT TABLE - -
|
||||
(CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>
|
||||
<!ELEMENT CAPTION - - (%inline;)* -- table caption -->
|
||||
<!ELEMENT THEAD - O (TR)+ -- table header -->
|
||||
<!ELEMENT TFOOT - O (TR)+ -- table footer -->
|
||||
<!ELEMENT TBODY O O (TR)+ -- table body -->
|
||||
<!ELEMENT COLGROUP - O (COL)* -- table column group -->
|
||||
<!ELEMENT COL - O EMPTY -- table column -->
|
||||
<!ELEMENT TR - O (TH|TD)+ -- table row -->
|
||||
<!ELEMENT (TH|TD) - O (%flow;)* -- table header cell, table data cell-->
|
||||
|
||||
<!ATTLIST TABLE -- table element --
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
summary %Text; #IMPLIED -- purpose/structure for speech output--
|
||||
width %Length; #IMPLIED -- table width --
|
||||
border %Pixels; #IMPLIED -- controls frame width around table --
|
||||
frame %TFrame; #IMPLIED -- which parts of frame to render --
|
||||
rules %TRules; #IMPLIED -- rulings between rows and cols --
|
||||
cellspacing %Length; #IMPLIED -- spacing between cells --
|
||||
cellpadding %Length; #IMPLIED -- spacing within cells --
|
||||
%reserved; -- reserved for possible future use --
|
||||
datapagesize CDATA #IMPLIED -- reserved for possible future use --
|
||||
>
|
||||
|
||||
|
||||
<!ATTLIST CAPTION
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--
|
||||
COLGROUP groups a set of COL elements. It allows you to group
|
||||
several semantically related columns together.
|
||||
-->
|
||||
<!ATTLIST COLGROUP
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
span NUMBER 1 -- default number of columns in group --
|
||||
width %MultiLength; #IMPLIED -- default width for enclosed COLs --
|
||||
%cellhalign; -- horizontal alignment in cells --
|
||||
%cellvalign; -- vertical alignment in cells --
|
||||
>
|
||||
|
||||
<!--
|
||||
COL elements define the alignment properties for cells in
|
||||
one or more columns.
|
||||
|
||||
The WIDTH attribute specifies the width of the columns, e.g.
|
||||
|
||||
width=64 width in screen pixels
|
||||
width=0.5* relative width of 0.5
|
||||
|
||||
The SPAN attribute causes the attributes of one
|
||||
COL element to apply to more than one column.
|
||||
-->
|
||||
<!ATTLIST COL -- column groups and properties --
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
span NUMBER 1 -- COL attributes affect N columns --
|
||||
width %MultiLength; #IMPLIED -- column width specification --
|
||||
%cellhalign; -- horizontal alignment in cells --
|
||||
%cellvalign; -- vertical alignment in cells --
|
||||
>
|
||||
|
||||
<!--
|
||||
Use THEAD to duplicate headers when breaking table
|
||||
across page boundaries, or for static headers when
|
||||
TBODY sections are rendered in scrolling panel.
|
||||
|
||||
Use TFOOT to duplicate footers when breaking table
|
||||
across page boundaries, or for static footers when
|
||||
TBODY sections are rendered in scrolling panel.
|
||||
|
||||
Use multiple TBODY sections when rules are needed
|
||||
between groups of table rows.
|
||||
-->
|
||||
<!ATTLIST (THEAD|TBODY|TFOOT) -- table section --
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
%cellhalign; -- horizontal alignment in cells --
|
||||
%cellvalign; -- vertical alignment in cells --
|
||||
>
|
||||
|
||||
<!ATTLIST TR -- table row --
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
%cellhalign; -- horizontal alignment in cells --
|
||||
%cellvalign; -- vertical alignment in cells --
|
||||
>
|
||||
|
||||
|
||||
<!-- Scope is simpler than headers attribute for common tables -->
|
||||
<!ENTITY % Scope "(row|col|rowgroup|colgroup)">
|
||||
|
||||
<!-- TH is for headers, TD for data, but for cells acting as both use TD -->
|
||||
<!ATTLIST (TH|TD) -- header or data cell --
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
abbr %Text; #IMPLIED -- abbreviation for header cell --
|
||||
axis CDATA #IMPLIED -- comma-separated list of related headers--
|
||||
headers IDREFS #IMPLIED -- list of id's for header cells --
|
||||
scope %Scope; #IMPLIED -- scope covered by header cells --
|
||||
rowspan NUMBER 1 -- number of rows spanned by cell --
|
||||
colspan NUMBER 1 -- number of cols spanned by cell --
|
||||
%cellhalign; -- horizontal alignment in cells --
|
||||
%cellvalign; -- vertical alignment in cells --
|
||||
>
|
||||
|
||||
|
||||
<!--================ Document Head =======================================-->
|
||||
<!-- %head.misc; defined earlier on as "SCRIPT|STYLE|META|LINK|OBJECT" -->
|
||||
<!ENTITY % head.content "TITLE & BASE?">
|
||||
|
||||
<!ELEMENT HEAD O O (%head.content;) +(%head.misc;) -- document head -->
|
||||
<!ATTLIST HEAD
|
||||
%i18n; -- lang, dir --
|
||||
profile %URI; #IMPLIED -- named dictionary of meta info --
|
||||
>
|
||||
|
||||
<!-- The TITLE element is not considered part of the flow of text.
|
||||
It should be displayed, for example as the page header or
|
||||
window title. Exactly one title is required per document.
|
||||
-->
|
||||
<!ELEMENT TITLE - - (#PCDATA) -(%head.misc;) -- document title -->
|
||||
<!ATTLIST TITLE %i18n>
|
||||
|
||||
|
||||
<!ELEMENT BASE - O EMPTY -- document base URI -->
|
||||
<!ATTLIST BASE
|
||||
href %URI; #REQUIRED -- URI that acts as base URI --
|
||||
>
|
||||
|
||||
<!ELEMENT META - O EMPTY -- generic metainformation -->
|
||||
<!ATTLIST META
|
||||
%i18n; -- lang, dir, for use with content --
|
||||
http-equiv NAME #IMPLIED -- HTTP response header name --
|
||||
name NAME #IMPLIED -- metainformation name --
|
||||
content CDATA #REQUIRED -- associated information --
|
||||
scheme CDATA #IMPLIED -- select form of content --
|
||||
>
|
||||
|
||||
<!ELEMENT STYLE - - %StyleSheet -- style info -->
|
||||
<!ATTLIST STYLE
|
||||
%i18n; -- lang, dir, for use with title --
|
||||
type %ContentType; #REQUIRED -- content type of style language --
|
||||
media %MediaDesc; #IMPLIED -- designed for use with these media --
|
||||
title %Text; #IMPLIED -- advisory title --
|
||||
>
|
||||
|
||||
<!ELEMENT SCRIPT - - %Script; -- script statements -->
|
||||
<!ATTLIST SCRIPT
|
||||
charset %Charset; #IMPLIED -- char encoding of linked resource --
|
||||
type %ContentType; #REQUIRED -- content type of script language --
|
||||
src %URI; #IMPLIED -- URI for an external script --
|
||||
defer (defer) #IMPLIED -- UA may defer execution of script --
|
||||
event CDATA #IMPLIED -- reserved for possible future use --
|
||||
for %URI; #IMPLIED -- reserved for possible future use --
|
||||
>
|
||||
|
||||
<!ELEMENT NOSCRIPT - - (%block;)+
|
||||
-- alternate content container for non script-based rendering -->
|
||||
<!ATTLIST NOSCRIPT
|
||||
%attrs; -- %coreattrs, %i18n, %events --
|
||||
>
|
||||
|
||||
<!--================ Document Structure ==================================-->
|
||||
<!ENTITY % html.content "HEAD, BODY">
|
||||
|
||||
<!ELEMENT HTML O O (%html.content;) -- document root element -->
|
||||
<!ATTLIST HTML
|
||||
%i18n; -- lang, dir --
|
||||
>
|
||||
45
app/node_modules/xml2js/node_modules/sax/examples/switch-bench.js
generated
vendored
Normal file
45
app/node_modules/xml2js/node_modules/sax/examples/switch-bench.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/local/bin/node-bench
|
||||
|
||||
var Promise = require("events").Promise;
|
||||
|
||||
var xml = require("posix").cat("test.xml").wait(),
|
||||
path = require("path"),
|
||||
sax = require("../lib/sax"),
|
||||
saxT = require("../lib/sax-trampoline"),
|
||||
|
||||
parser = sax.parser(false, {trim:true}),
|
||||
parserT = saxT.parser(false, {trim:true}),
|
||||
|
||||
sys = require("sys");
|
||||
|
||||
|
||||
var count = exports.stepsPerLap = 500,
|
||||
l = xml.length,
|
||||
runs = 0;
|
||||
exports.countPerLap = 1000;
|
||||
exports.compare = {
|
||||
"switch" : function () {
|
||||
// sys.debug("switch runs: "+runs++);
|
||||
// for (var x = 0; x < l; x += 1000) {
|
||||
// parser.write(xml.substr(x, 1000))
|
||||
// }
|
||||
// for (var i = 0; i < count; i ++) {
|
||||
parser.write(xml);
|
||||
parser.close();
|
||||
// }
|
||||
// done();
|
||||
},
|
||||
trampoline : function () {
|
||||
// sys.debug("trampoline runs: "+runs++);
|
||||
// for (var x = 0; x < l; x += 1000) {
|
||||
// parserT.write(xml.substr(x, 1000))
|
||||
// }
|
||||
// for (var i = 0; i < count; i ++) {
|
||||
parserT.write(xml);
|
||||
parserT.close();
|
||||
// }
|
||||
// done();
|
||||
},
|
||||
};
|
||||
|
||||
sys.debug("rock and roll...");
|
||||
15
app/node_modules/xml2js/node_modules/sax/examples/test.html
generated
vendored
Normal file
15
app/node_modules/xml2js/node_modules/sax/examples/test.html
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>testing the parser</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>hello
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1254
app/node_modules/xml2js/node_modules/sax/examples/test.xml
generated
vendored
Normal file
1254
app/node_modules/xml2js/node_modules/sax/examples/test.xml
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1007
app/node_modules/xml2js/node_modules/sax/lib/sax.js
generated
vendored
Normal file
1007
app/node_modules/xml2js/node_modules/sax/lib/sax.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
68
app/node_modules/xml2js/node_modules/sax/package.json
generated
vendored
Normal file
68
app/node_modules/xml2js/node_modules/sax/package.json
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"name": "sax",
|
||||
"description": "An evented streaming XML parser in JavaScript",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"version": "0.4.0",
|
||||
"main": "lib/sax.js",
|
||||
"license": {
|
||||
"type": "MIT",
|
||||
"url": "https://raw.github.com/isaacs/sax-js/master/LICENSE"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/sax-js.git"
|
||||
},
|
||||
"_id": "sax@0.4.0",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me"
|
||||
},
|
||||
{
|
||||
"name": "Stein Martin Hustad",
|
||||
"email": "stein@hustad.com"
|
||||
},
|
||||
{
|
||||
"name": "Mikeal Rogers",
|
||||
"email": "mikeal.rogers@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Laurie Harper",
|
||||
"email": "laurie@holoweb.net"
|
||||
},
|
||||
{
|
||||
"name": "Jann Horn",
|
||||
"email": "jann@Jann-PC.fritz.box"
|
||||
},
|
||||
{
|
||||
"name": "Elijah Insua",
|
||||
"email": "tmpvar@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Henry Rawas",
|
||||
"email": "henryr@schakra.com"
|
||||
},
|
||||
{
|
||||
"name": "Justin Makeig",
|
||||
"email": "jmpublic@makeig.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"_engineSupported": true,
|
||||
"_npmVersion": "1.1.21",
|
||||
"_nodeVersion": "v0.6.18",
|
||||
"_defaultsLoaded": true,
|
||||
"_from": "sax@>=0.1.1"
|
||||
}
|
||||
25
app/node_modules/xml2js/node_modules/sax/test/buffer-overrun.js
generated
vendored
Normal file
25
app/node_modules/xml2js/node_modules/sax/test/buffer-overrun.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// set this really low so that I don't have to put 64 MB of xml in here.
|
||||
var sax = require("../lib/sax")
|
||||
var bl = sax.MAX_BUFFER_LENGTH
|
||||
sax.MAX_BUFFER_LENGTH = 5;
|
||||
|
||||
require(__dirname).test({
|
||||
expect : [
|
||||
["error", "Max buffer length exceeded: tagName\nLine: 0\nColumn: 15\nChar: "],
|
||||
["error", "Max buffer length exceeded: tagName\nLine: 0\nColumn: 30\nChar: "],
|
||||
["error", "Max buffer length exceeded: tagName\nLine: 0\nColumn: 45\nChar: "],
|
||||
["opentag", {
|
||||
"name": "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
"attributes": {}
|
||||
}],
|
||||
["text", "yo"],
|
||||
["closetag", "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"]
|
||||
]
|
||||
}).write("<abcdefghijklmn")
|
||||
.write("opqrstuvwxyzABC")
|
||||
.write("DEFGHIJKLMNOPQR")
|
||||
.write("STUVWXYZ>")
|
||||
.write("yo")
|
||||
.write("</abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ>")
|
||||
.close();
|
||||
sax.MAX_BUFFER_LENGTH = bl
|
||||
47
app/node_modules/xml2js/node_modules/sax/test/case.js
generated
vendored
Normal file
47
app/node_modules/xml2js/node_modules/sax/test/case.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// default to uppercase
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<span class=\"test\" hello=\"world\"></span>"
|
||||
, expect :
|
||||
[ [ "attribute", { name: "CLASS", value: "test" } ]
|
||||
, [ "attribute", { name: "HELLO", value: "world" } ]
|
||||
, [ "opentag", { name: "SPAN",
|
||||
attributes: { CLASS: "test", HELLO: "world" } } ]
|
||||
, [ "closetag", "SPAN" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
// lowercase option : lowercase tag/attribute names
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<span class=\"test\" hello=\"world\"></span>"
|
||||
, expect :
|
||||
[ [ "attribute", { name: "class", value: "test" } ]
|
||||
, [ "attribute", { name: "hello", value: "world" } ]
|
||||
, [ "opentag", { name: "span",
|
||||
attributes: { class: "test", hello: "world" } } ]
|
||||
, [ "closetag", "span" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {lowercase:true}
|
||||
}
|
||||
)
|
||||
|
||||
// backward compatibility with old lowercasetags opt
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<span class=\"test\" hello=\"world\"></span>"
|
||||
, expect :
|
||||
[ [ "attribute", { name: "class", value: "test" } ]
|
||||
, [ "attribute", { name: "hello", value: "world" } ]
|
||||
, [ "opentag", { name: "span",
|
||||
attributes: { class: "test", hello: "world" } } ]
|
||||
, [ "closetag", "span" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {lowercasetags:true}
|
||||
}
|
||||
)
|
||||
11
app/node_modules/xml2js/node_modules/sax/test/cdata-chunked.js
generated
vendored
Normal file
11
app/node_modules/xml2js/node_modules/sax/test/cdata-chunked.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
require(__dirname).test({
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}}],
|
||||
["opencdata", undefined],
|
||||
["cdata", " this is character data "],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
}).write("<r><![CDATA[ this is ").write("character data ").write("]]></r>").close();
|
||||
|
||||
15
app/node_modules/xml2js/node_modules/sax/test/cdata-end-split.js
generated
vendored
Normal file
15
app/node_modules/xml2js/node_modules/sax/test/cdata-end-split.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
require(__dirname).test({
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}}],
|
||||
["opencdata", undefined],
|
||||
["cdata", " this is "],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
})
|
||||
.write("<r><![CDATA[ this is ]")
|
||||
.write("]>")
|
||||
.write("</r>")
|
||||
.close();
|
||||
|
||||
28
app/node_modules/xml2js/node_modules/sax/test/cdata-fake-end.js
generated
vendored
Normal file
28
app/node_modules/xml2js/node_modules/sax/test/cdata-fake-end.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
var p = require(__dirname).test({
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}}],
|
||||
["opencdata", undefined],
|
||||
["cdata", "[[[[[[[[]]]]]]]]"],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
})
|
||||
var x = "<r><![CDATA[[[[[[[[[]]]]]]]]]]></r>"
|
||||
for (var i = 0; i < x.length ; i ++) {
|
||||
p.write(x.charAt(i))
|
||||
}
|
||||
p.close();
|
||||
|
||||
|
||||
var p2 = require(__dirname).test({
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}}],
|
||||
["opencdata", undefined],
|
||||
["cdata", "[[[[[[[[]]]]]]]]"],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
})
|
||||
var x = "<r><![CDATA[[[[[[[[[]]]]]]]]]]></r>"
|
||||
p2.write(x).close();
|
||||
15
app/node_modules/xml2js/node_modules/sax/test/cdata-multiple.js
generated
vendored
Normal file
15
app/node_modules/xml2js/node_modules/sax/test/cdata-multiple.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
require(__dirname).test({
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}}],
|
||||
["opencdata", undefined],
|
||||
["cdata", " this is "],
|
||||
["closecdata", undefined],
|
||||
["opencdata", undefined],
|
||||
["cdata", "character data "],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
}).write("<r><![CDATA[ this is ]]>").write("<![CDA").write("T").write("A[")
|
||||
.write("character data ").write("]]></r>").close();
|
||||
|
||||
10
app/node_modules/xml2js/node_modules/sax/test/cdata.js
generated
vendored
Normal file
10
app/node_modules/xml2js/node_modules/sax/test/cdata.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
require(__dirname).test({
|
||||
xml : "<r><![CDATA[ this is character data ]]></r>",
|
||||
expect : [
|
||||
["opentag", {"name": "R","attributes": {}}],
|
||||
["opencdata", undefined],
|
||||
["cdata", " this is character data "],
|
||||
["closecdata", undefined],
|
||||
["closetag", "R"]
|
||||
]
|
||||
});
|
||||
86
app/node_modules/xml2js/node_modules/sax/test/index.js
generated
vendored
Normal file
86
app/node_modules/xml2js/node_modules/sax/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
var globalsBefore = JSON.stringify(Object.keys(global))
|
||||
, util = require("util")
|
||||
, assert = require("assert")
|
||||
, fs = require("fs")
|
||||
, path = require("path")
|
||||
, sax = require("../lib/sax")
|
||||
|
||||
exports.sax = sax
|
||||
|
||||
// handy way to do simple unit tests
|
||||
// if the options contains an xml string, it'll be written and the parser closed.
|
||||
// otherwise, it's assumed that the test will write and close.
|
||||
exports.test = function test (options) {
|
||||
var xml = options.xml
|
||||
, parser = sax.parser(options.strict, options.opt)
|
||||
, expect = options.expect
|
||||
, e = 0
|
||||
sax.EVENTS.forEach(function (ev) {
|
||||
parser["on" + ev] = function (n) {
|
||||
if (process.env.DEBUG) {
|
||||
console.error({ expect: expect[e]
|
||||
, actual: [ev, n] })
|
||||
}
|
||||
if (e >= expect.length && (ev === "end" || ev === "ready")) return
|
||||
assert.ok( e < expect.length,
|
||||
"expectation #"+e+" "+util.inspect(expect[e])+"\n"+
|
||||
"Unexpected event: "+ev+" "+(n ? util.inspect(n) : ""))
|
||||
var inspected = n instanceof Error ? "\n"+ n.message : util.inspect(n)
|
||||
assert.equal(ev, expect[e][0],
|
||||
"expectation #"+e+"\n"+
|
||||
"Didn't get expected event\n"+
|
||||
"expect: "+expect[e][0] + " " +util.inspect(expect[e][1])+"\n"+
|
||||
"actual: "+ev+" "+inspected+"\n")
|
||||
if (ev === "error") assert.equal(n.message, expect[e][1])
|
||||
else assert.deepEqual(n, expect[e][1],
|
||||
"expectation #"+e+"\n"+
|
||||
"Didn't get expected argument\n"+
|
||||
"expect: "+expect[e][0] + " " +util.inspect(expect[e][1])+"\n"+
|
||||
"actual: "+ev+" "+inspected+"\n")
|
||||
e++
|
||||
if (ev === "error") parser.resume()
|
||||
}
|
||||
})
|
||||
if (xml) parser.write(xml).close()
|
||||
return parser
|
||||
}
|
||||
|
||||
if (module === require.main) {
|
||||
var running = true
|
||||
, failures = 0
|
||||
|
||||
function fail (file, er) {
|
||||
util.error("Failed: "+file)
|
||||
util.error(er.stack || er.message)
|
||||
failures ++
|
||||
}
|
||||
|
||||
fs.readdir(__dirname, function (error, files) {
|
||||
files = files.filter(function (file) {
|
||||
return (/\.js$/.exec(file) && file !== 'index.js')
|
||||
})
|
||||
var n = files.length
|
||||
, i = 0
|
||||
console.log("0.." + n)
|
||||
files.forEach(function (file) {
|
||||
// run this test.
|
||||
try {
|
||||
require(path.resolve(__dirname, file))
|
||||
var globalsAfter = JSON.stringify(Object.keys(global))
|
||||
if (globalsAfter !== globalsBefore) {
|
||||
var er = new Error("new globals introduced\n"+
|
||||
"expected: "+globalsBefore+"\n"+
|
||||
"actual: "+globalsAfter)
|
||||
globalsBefore = globalsAfter
|
||||
throw er
|
||||
}
|
||||
console.log("ok " + (++i) + " - " + file)
|
||||
} catch (er) {
|
||||
console.log("not ok "+ (++i) + " - " + file)
|
||||
fail(file, er)
|
||||
}
|
||||
})
|
||||
if (!failures) return console.log("#all pass")
|
||||
else return console.error(failures + " failure" + (failures > 1 ? "s" : ""))
|
||||
})
|
||||
}
|
||||
43
app/node_modules/xml2js/node_modules/sax/test/issue-23.js
generated
vendored
Normal file
43
app/node_modules/xml2js/node_modules/sax/test/issue-23.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<compileClassesResponse>"+
|
||||
"<result>"+
|
||||
"<bodyCrc>653724009</bodyCrc>"+
|
||||
"<column>-1</column>"+
|
||||
"<id>01pG0000002KoSUIA0</id>"+
|
||||
"<line>-1</line>"+
|
||||
"<name>CalendarController</name>"+
|
||||
"<success>true</success>"+
|
||||
"</result>"+
|
||||
"</compileClassesResponse>"
|
||||
|
||||
, expect :
|
||||
[ [ "opentag", { name: "COMPILECLASSESRESPONSE", attributes: {} } ]
|
||||
, [ "opentag", { name : "RESULT", attributes: {} } ]
|
||||
, [ "opentag", { name: "BODYCRC", attributes: {} } ]
|
||||
, [ "text", "653724009" ]
|
||||
, [ "closetag", "BODYCRC" ]
|
||||
, [ "opentag", { name: "COLUMN", attributes: {} } ]
|
||||
, [ "text", "-1" ]
|
||||
, [ "closetag", "COLUMN" ]
|
||||
, [ "opentag", { name: "ID", attributes: {} } ]
|
||||
, [ "text", "01pG0000002KoSUIA0" ]
|
||||
, [ "closetag", "ID" ]
|
||||
, [ "opentag", {name: "LINE", attributes: {} } ]
|
||||
, [ "text", "-1" ]
|
||||
, [ "closetag", "LINE" ]
|
||||
, [ "opentag", {name: "NAME", attributes: {} } ]
|
||||
, [ "text", "CalendarController" ]
|
||||
, [ "closetag", "NAME" ]
|
||||
, [ "opentag", {name: "SUCCESS", attributes: {} } ]
|
||||
, [ "text", "true" ]
|
||||
, [ "closetag", "SUCCESS" ]
|
||||
, [ "closetag", "RESULT" ]
|
||||
, [ "closetag", "COMPILECLASSESRESPONSE" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
24
app/node_modules/xml2js/node_modules/sax/test/issue-30.js
generated
vendored
Normal file
24
app/node_modules/xml2js/node_modules/sax/test/issue-30.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// https://github.com/isaacs/sax-js/issues/33
|
||||
require(__dirname).test
|
||||
( { xml : "<xml>\n"+
|
||||
"<!-- \n"+
|
||||
" comment with a single dash- in it\n"+
|
||||
"-->\n"+
|
||||
"<data/>\n"+
|
||||
"</xml>"
|
||||
|
||||
, expect :
|
||||
[ [ "opentag", { name: "xml", attributes: {} } ]
|
||||
, [ "text", "\n" ]
|
||||
, [ "comment", " \n comment with a single dash- in it\n" ]
|
||||
, [ "text", "\n" ]
|
||||
, [ "opentag", { name: "data", attributes: {} } ]
|
||||
, [ "closetag", "data" ]
|
||||
, [ "text", "\n" ]
|
||||
, [ "closetag", "xml" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
15
app/node_modules/xml2js/node_modules/sax/test/issue-35.js
generated
vendored
Normal file
15
app/node_modules/xml2js/node_modules/sax/test/issue-35.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// https://github.com/isaacs/sax-js/issues/35
|
||||
require(__dirname).test
|
||||
( { xml : "<xml>

\n"+
|
||||
"</xml>"
|
||||
|
||||
, expect :
|
||||
[ [ "opentag", { name: "xml", attributes: {} } ]
|
||||
, [ "text", "\r\r\n" ]
|
||||
, [ "closetag", "xml" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
13
app/node_modules/xml2js/node_modules/sax/test/issue-47.js
generated
vendored
Normal file
13
app/node_modules/xml2js/node_modules/sax/test/issue-47.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// https://github.com/isaacs/sax-js/issues/47
|
||||
require(__dirname).test
|
||||
( { xml : '<a href="query.svc?x=1&y=2&z=3"/>'
|
||||
, expect : [
|
||||
[ "attribute", { name:'href', value:"query.svc?x=1&y=2&z=3"} ],
|
||||
[ "opentag", { name: "a", attributes: { href:"query.svc?x=1&y=2&z=3"} } ],
|
||||
[ "closetag", "a" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
31
app/node_modules/xml2js/node_modules/sax/test/issue-49.js
generated
vendored
Normal file
31
app/node_modules/xml2js/node_modules/sax/test/issue-49.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// https://github.com/isaacs/sax-js/issues/49
|
||||
require(__dirname).test
|
||||
( { xml : "<xml><script>hello world</script></xml>"
|
||||
, expect :
|
||||
[ [ "opentag", { name: "xml", attributes: {} } ]
|
||||
, [ "opentag", { name: "script", attributes: {} } ]
|
||||
, [ "text", "hello world" ]
|
||||
, [ "closetag", "script" ]
|
||||
, [ "closetag", "xml" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : { lowercasetags: true, noscript: true }
|
||||
}
|
||||
)
|
||||
|
||||
require(__dirname).test
|
||||
( { xml : "<xml><script><![CDATA[hello world]]></script></xml>"
|
||||
, expect :
|
||||
[ [ "opentag", { name: "xml", attributes: {} } ]
|
||||
, [ "opentag", { name: "script", attributes: {} } ]
|
||||
, [ "opencdata", undefined ]
|
||||
, [ "cdata", "hello world" ]
|
||||
, [ "closecdata", undefined ]
|
||||
, [ "closetag", "script" ]
|
||||
, [ "closetag", "xml" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : { lowercasetags: true, noscript: true }
|
||||
}
|
||||
)
|
||||
|
||||
28
app/node_modules/xml2js/node_modules/sax/test/parser-position.js
generated
vendored
Normal file
28
app/node_modules/xml2js/node_modules/sax/test/parser-position.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
var sax = require("../lib/sax"),
|
||||
assert = require("assert")
|
||||
|
||||
function testPosition(chunks, expectedEvents) {
|
||||
var parser = sax.parser();
|
||||
expectedEvents.forEach(function(expectation) {
|
||||
parser['on' + expectation[0]] = function() {
|
||||
for (var prop in expectation[1]) {
|
||||
assert.equal(parser[prop], expectation[1][prop]);
|
||||
}
|
||||
}
|
||||
});
|
||||
chunks.forEach(function(chunk) {
|
||||
parser.write(chunk);
|
||||
});
|
||||
};
|
||||
|
||||
testPosition(['<div>abcdefgh</div>'],
|
||||
[ ['opentag', { position: 5, startTagPosition: 1 }]
|
||||
, ['text', { position: 19, startTagPosition: 14 }]
|
||||
, ['closetag', { position: 19, startTagPosition: 14 }]
|
||||
]);
|
||||
|
||||
testPosition(['<div>abcde','fgh</div>'],
|
||||
[ ['opentag', { position: 5, startTagPosition: 1 }]
|
||||
, ['text', { position: 19, startTagPosition: 14 }]
|
||||
, ['closetag', { position: 19, startTagPosition: 14 }]
|
||||
]);
|
||||
12
app/node_modules/xml2js/node_modules/sax/test/script.js
generated
vendored
Normal file
12
app/node_modules/xml2js/node_modules/sax/test/script.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
require(__dirname).test({
|
||||
xml : "<html><head><script>if (1 < 0) { console.log('elo there'); }</script></head></html>",
|
||||
expect : [
|
||||
["opentag", {"name": "HTML","attributes": {}}],
|
||||
["opentag", {"name": "HEAD","attributes": {}}],
|
||||
["opentag", {"name": "SCRIPT","attributes": {}}],
|
||||
["script", "if (1 < 0) { console.log('elo there'); }"],
|
||||
["closetag", "SCRIPT"],
|
||||
["closetag", "HEAD"],
|
||||
["closetag", "HTML"]
|
||||
]
|
||||
});
|
||||
40
app/node_modules/xml2js/node_modules/sax/test/self-closing-child-strict.js
generated
vendored
Normal file
40
app/node_modules/xml2js/node_modules/sax/test/self-closing-child-strict.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
require(__dirname).test({
|
||||
xml :
|
||||
"<root>"+
|
||||
"<child>" +
|
||||
"<haha />" +
|
||||
"</child>" +
|
||||
"<monkey>" +
|
||||
"=(|)" +
|
||||
"</monkey>" +
|
||||
"</root>",
|
||||
expect : [
|
||||
["opentag", {
|
||||
"name": "root",
|
||||
"attributes": {}
|
||||
}],
|
||||
["opentag", {
|
||||
"name": "child",
|
||||
"attributes": {}
|
||||
}],
|
||||
["opentag", {
|
||||
"name": "haha",
|
||||
"attributes": {}
|
||||
}],
|
||||
["closetag", "haha"],
|
||||
["closetag", "child"],
|
||||
["opentag", {
|
||||
"name": "monkey",
|
||||
"attributes": {}
|
||||
}],
|
||||
["text", "=(|)"],
|
||||
["closetag", "monkey"],
|
||||
["closetag", "root"],
|
||||
["end"],
|
||||
["ready"]
|
||||
],
|
||||
strict : true,
|
||||
opt : {}
|
||||
});
|
||||
|
||||
40
app/node_modules/xml2js/node_modules/sax/test/self-closing-child.js
generated
vendored
Normal file
40
app/node_modules/xml2js/node_modules/sax/test/self-closing-child.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
require(__dirname).test({
|
||||
xml :
|
||||
"<root>"+
|
||||
"<child>" +
|
||||
"<haha />" +
|
||||
"</child>" +
|
||||
"<monkey>" +
|
||||
"=(|)" +
|
||||
"</monkey>" +
|
||||
"</root>",
|
||||
expect : [
|
||||
["opentag", {
|
||||
"name": "ROOT",
|
||||
"attributes": {}
|
||||
}],
|
||||
["opentag", {
|
||||
"name": "CHILD",
|
||||
"attributes": {}
|
||||
}],
|
||||
["opentag", {
|
||||
"name": "HAHA",
|
||||
"attributes": {}
|
||||
}],
|
||||
["closetag", "HAHA"],
|
||||
["closetag", "CHILD"],
|
||||
["opentag", {
|
||||
"name": "MONKEY",
|
||||
"attributes": {}
|
||||
}],
|
||||
["text", "=(|)"],
|
||||
["closetag", "MONKEY"],
|
||||
["closetag", "ROOT"],
|
||||
["end"],
|
||||
["ready"]
|
||||
],
|
||||
strict : false,
|
||||
opt : {}
|
||||
});
|
||||
|
||||
25
app/node_modules/xml2js/node_modules/sax/test/self-closing-tag.js
generated
vendored
Normal file
25
app/node_modules/xml2js/node_modules/sax/test/self-closing-tag.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
require(__dirname).test({
|
||||
xml :
|
||||
"<root> "+
|
||||
"<haha /> "+
|
||||
"<haha/> "+
|
||||
"<monkey> "+
|
||||
"=(|) "+
|
||||
"</monkey>"+
|
||||
"</root> ",
|
||||
expect : [
|
||||
["opentag", {name:"ROOT", attributes:{}}],
|
||||
["opentag", {name:"HAHA", attributes:{}}],
|
||||
["closetag", "HAHA"],
|
||||
["opentag", {name:"HAHA", attributes:{}}],
|
||||
["closetag", "HAHA"],
|
||||
// ["opentag", {name:"HAHA", attributes:{}}],
|
||||
// ["closetag", "HAHA"],
|
||||
["opentag", {name:"MONKEY", attributes:{}}],
|
||||
["text", "=(|)"],
|
||||
["closetag", "MONKEY"],
|
||||
["closetag", "ROOT"]
|
||||
],
|
||||
opt : { trim : true }
|
||||
});
|
||||
17
app/node_modules/xml2js/node_modules/sax/test/stray-ending.js
generated
vendored
Normal file
17
app/node_modules/xml2js/node_modules/sax/test/stray-ending.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// stray ending tags should just be ignored in non-strict mode.
|
||||
// https://github.com/isaacs/sax-js/issues/32
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<a><b></c></b></a>"
|
||||
, expect :
|
||||
[ [ "opentag", { name: "A", attributes: {} } ]
|
||||
, [ "opentag", { name: "B", attributes: {} } ]
|
||||
, [ "text", "</c>" ]
|
||||
, [ "closetag", "B" ]
|
||||
, [ "closetag", "A" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
17
app/node_modules/xml2js/node_modules/sax/test/trailing-non-whitespace.js
generated
vendored
Normal file
17
app/node_modules/xml2js/node_modules/sax/test/trailing-non-whitespace.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
require(__dirname).test({
|
||||
xml : "<span>Welcome,</span> to monkey land",
|
||||
expect : [
|
||||
["opentag", {
|
||||
"name": "SPAN",
|
||||
"attributes": {}
|
||||
}],
|
||||
["text", "Welcome,"],
|
||||
["closetag", "SPAN"],
|
||||
["text", " to monkey land"],
|
||||
["end"],
|
||||
["ready"]
|
||||
],
|
||||
strict : false,
|
||||
opt : {}
|
||||
});
|
||||
17
app/node_modules/xml2js/node_modules/sax/test/unquoted.js
generated
vendored
Normal file
17
app/node_modules/xml2js/node_modules/sax/test/unquoted.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// unquoted attributes should be ok in non-strict mode
|
||||
// https://github.com/isaacs/sax-js/issues/31
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<span class=test hello=world></span>"
|
||||
, expect :
|
||||
[ [ "attribute", { name: "CLASS", value: "test" } ]
|
||||
, [ "attribute", { name: "HELLO", value: "world" } ]
|
||||
, [ "opentag", { name: "SPAN",
|
||||
attributes: { CLASS: "test", HELLO: "world" } } ]
|
||||
, [ "closetag", "SPAN" ]
|
||||
]
|
||||
, strict : false
|
||||
, opt : {}
|
||||
}
|
||||
)
|
||||
|
||||
67
app/node_modules/xml2js/node_modules/sax/test/xmlns-issue-41.js
generated
vendored
Normal file
67
app/node_modules/xml2js/node_modules/sax/test/xmlns-issue-41.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
var t = require(__dirname)
|
||||
|
||||
, xmls = // should be the same both ways.
|
||||
[ "<parent xmlns:a='http://ATTRIBUTE' a:attr='value' />"
|
||||
, "<parent a:attr='value' xmlns:a='http://ATTRIBUTE' />" ]
|
||||
|
||||
, ex1 =
|
||||
[ [ "opennamespace"
|
||||
, { prefix: "a"
|
||||
, uri: "http://ATTRIBUTE"
|
||||
}
|
||||
]
|
||||
, [ "attribute"
|
||||
, { name: "xmlns:a"
|
||||
, value: "http://ATTRIBUTE"
|
||||
, prefix: "xmlns"
|
||||
, local: "a"
|
||||
, uri: "http://www.w3.org/2000/xmlns/"
|
||||
}
|
||||
]
|
||||
, [ "attribute"
|
||||
, { name: "a:attr"
|
||||
, local: "attr"
|
||||
, prefix: "a"
|
||||
, uri: "http://ATTRIBUTE"
|
||||
, value: "value"
|
||||
}
|
||||
]
|
||||
, [ "opentag"
|
||||
, { name: "parent"
|
||||
, uri: ""
|
||||
, prefix: ""
|
||||
, local: "parent"
|
||||
, attributes:
|
||||
{ "a:attr":
|
||||
{ name: "a:attr"
|
||||
, local: "attr"
|
||||
, prefix: "a"
|
||||
, uri: "http://ATTRIBUTE"
|
||||
, value: "value"
|
||||
}
|
||||
, "xmlns:a":
|
||||
{ name: "xmlns:a"
|
||||
, local: "a"
|
||||
, prefix: "xmlns"
|
||||
, uri: "http://www.w3.org/2000/xmlns/"
|
||||
, value: "http://ATTRIBUTE"
|
||||
}
|
||||
}
|
||||
, ns: {"a": "http://ATTRIBUTE"}
|
||||
}
|
||||
]
|
||||
, ["closetag", "parent"]
|
||||
, ["closenamespace", { prefix: "a", uri: "http://ATTRIBUTE" }]
|
||||
]
|
||||
|
||||
// swap the order of elements 2 and 1
|
||||
, ex2 = [ex1[0], ex1[2], ex1[1]].concat(ex1.slice(3))
|
||||
, expected = [ex1, ex2]
|
||||
|
||||
xmls.forEach(function (x, i) {
|
||||
t.test({ xml: x
|
||||
, expect: expected[i]
|
||||
, strict: true
|
||||
, opt: { xmlns: true }
|
||||
})
|
||||
})
|
||||
59
app/node_modules/xml2js/node_modules/sax/test/xmlns-rebinding.js
generated
vendored
Normal file
59
app/node_modules/xml2js/node_modules/sax/test/xmlns-rebinding.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<root xmlns:x='x1' xmlns:y='y1' x:a='x1' y:a='y1'>"+
|
||||
"<rebind xmlns:x='x2'>"+
|
||||
"<check x:a='x2' y:a='y1'/>"+
|
||||
"</rebind>"+
|
||||
"<check x:a='x1' y:a='y1'/>"+
|
||||
"</root>"
|
||||
|
||||
, expect :
|
||||
[ [ "opennamespace", { prefix: "x", uri: "x1" } ]
|
||||
, [ "opennamespace", { prefix: "y", uri: "y1" } ]
|
||||
, [ "attribute", { name: "xmlns:x", value: "x1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } ]
|
||||
, [ "attribute", { name: "xmlns:y", value: "y1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "y" } ]
|
||||
, [ "attribute", { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } ]
|
||||
, [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ]
|
||||
, [ "opentag", { name: "root", uri: "", prefix: "", local: "root",
|
||||
attributes: { "xmlns:x": { name: "xmlns:x", value: "x1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" }
|
||||
, "xmlns:y": { name: "xmlns:y", value: "y1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "y" }
|
||||
, "x:a": { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" }
|
||||
, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
|
||||
ns: { x: 'x1', y: 'y1' } } ]
|
||||
|
||||
, [ "opennamespace", { prefix: "x", uri: "x2" } ]
|
||||
, [ "attribute", { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } ]
|
||||
, [ "opentag", { name: "rebind", uri: "", prefix: "", local: "rebind",
|
||||
attributes: { "xmlns:x": { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } },
|
||||
ns: { x: 'x2' } } ]
|
||||
|
||||
, [ "attribute", { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" } ]
|
||||
, [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ]
|
||||
, [ "opentag", { name: "check", uri: "", prefix: "", local: "check",
|
||||
attributes: { "x:a": { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" }
|
||||
, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
|
||||
ns: { x: 'x2' } } ]
|
||||
|
||||
, [ "closetag", "check" ]
|
||||
|
||||
, [ "closetag", "rebind" ]
|
||||
, [ "closenamespace", { prefix: "x", uri: "x2" } ]
|
||||
|
||||
, [ "attribute", { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } ]
|
||||
, [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ]
|
||||
, [ "opentag", { name: "check", uri: "", prefix: "", local: "check",
|
||||
attributes: { "x:a": { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" }
|
||||
, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
|
||||
ns: { x: 'x1', y: 'y1' } } ]
|
||||
, [ "closetag", "check" ]
|
||||
|
||||
, [ "closetag", "root" ]
|
||||
, [ "closenamespace", { prefix: "x", uri: "x1" } ]
|
||||
, [ "closenamespace", { prefix: "y", uri: "y1" } ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
)
|
||||
|
||||
71
app/node_modules/xml2js/node_modules/sax/test/xmlns-strict.js
generated
vendored
Normal file
71
app/node_modules/xml2js/node_modules/sax/test/xmlns-strict.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
require(__dirname).test
|
||||
( { xml :
|
||||
"<root>"+
|
||||
"<plain attr='normal'/>"+
|
||||
"<ns1 xmlns='uri:default'>"+
|
||||
"<plain attr='normal'/>"+
|
||||
"</ns1>"+
|
||||
"<ns2 xmlns:a='uri:nsa'>"+
|
||||
"<plain attr='normal'/>"+
|
||||
"<a:ns a:attr='namespaced'/>"+
|
||||
"</ns2>"+
|
||||
"</root>"
|
||||
|
||||
, expect :
|
||||
[ [ "opentag", { name: "root", prefix: "", local: "root", uri: "",
|
||||
attributes: {}, ns: {} } ]
|
||||
|
||||
, [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]
|
||||
, [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "",
|
||||
attributes: { "attr": { name: "attr", value: "normal", uri: "", prefix: "", local: "attr", uri: "" } },
|
||||
ns: {} } ]
|
||||
, [ "closetag", "plain" ]
|
||||
|
||||
, [ "opennamespace", { prefix: "", uri: "uri:default" } ]
|
||||
|
||||
, [ "attribute", { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } ]
|
||||
, [ "opentag", { name: "ns1", prefix: "", local: "ns1", uri: "uri:default",
|
||||
attributes: { "xmlns": { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } },
|
||||
ns: { "": "uri:default" } } ]
|
||||
|
||||
, [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "uri:default" } ]
|
||||
, [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "uri:default", ns: { '': 'uri:default' },
|
||||
attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "uri:default" } } } ]
|
||||
, [ "closetag", "plain" ]
|
||||
|
||||
, [ "closetag", "ns1" ]
|
||||
|
||||
, [ "closenamespace", { prefix: "", uri: "uri:default" } ]
|
||||
|
||||
, [ "opennamespace", { prefix: "a", uri: "uri:nsa" } ]
|
||||
|
||||
, [ "attribute", { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } ]
|
||||
|
||||
, [ "opentag", { name: "ns2", prefix: "", local: "ns2", uri: "",
|
||||
attributes: { "xmlns:a": { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } },
|
||||
ns: { a: "uri:nsa" } } ]
|
||||
|
||||
, [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]
|
||||
, [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "",
|
||||
attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } },
|
||||
ns: { a: 'uri:nsa' } } ]
|
||||
, [ "closetag", "plain" ]
|
||||
|
||||
, [ "attribute", { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } ]
|
||||
, [ "opentag", { name: "a:ns", prefix: "a", local: "ns", uri: "uri:nsa",
|
||||
attributes: { "a:attr": { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } },
|
||||
ns: { a: 'uri:nsa' } } ]
|
||||
, [ "closetag", "a:ns" ]
|
||||
|
||||
, [ "closetag", "ns2" ]
|
||||
|
||||
, [ "closenamespace", { prefix: "a", uri: "uri:nsa" } ]
|
||||
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
)
|
||||
|
||||
15
app/node_modules/xml2js/node_modules/sax/test/xmlns-unbound.js
generated
vendored
Normal file
15
app/node_modules/xml2js/node_modules/sax/test/xmlns-unbound.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
require(__dirname).test(
|
||||
{ strict : true
|
||||
, opt : { xmlns: true }
|
||||
, expect :
|
||||
[ ["error", "Unbound namespace prefix: \"unbound\"\nLine: 0\nColumn: 28\nChar: >"]
|
||||
|
||||
, [ "attribute", { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } ]
|
||||
, [ "opentag", { name: "root", uri: "", prefix: "", local: "root",
|
||||
attributes: { "unbound:attr": { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } },
|
||||
ns: {} } ]
|
||||
, [ "closetag", "root" ]
|
||||
]
|
||||
}
|
||||
).write("<root unbound:attr='value'/>")
|
||||
35
app/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js
generated
vendored
Normal file
35
app/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix-attribute.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
require(__dirname).test(
|
||||
{ xml : "<root xml:lang='en'/>"
|
||||
, expect :
|
||||
[ [ "attribute"
|
||||
, { name: "xml:lang"
|
||||
, local: "lang"
|
||||
, prefix: "xml"
|
||||
, uri: "http://www.w3.org/XML/1998/namespace"
|
||||
, value: "en"
|
||||
}
|
||||
]
|
||||
, [ "opentag"
|
||||
, { name: "root"
|
||||
, uri: ""
|
||||
, prefix: ""
|
||||
, local: "root"
|
||||
, attributes:
|
||||
{ "xml:lang":
|
||||
{ name: "xml:lang"
|
||||
, local: "lang"
|
||||
, prefix: "xml"
|
||||
, uri: "http://www.w3.org/XML/1998/namespace"
|
||||
, value: "en"
|
||||
}
|
||||
}
|
||||
, ns: {}
|
||||
}
|
||||
]
|
||||
, ["closetag", "root"]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
)
|
||||
|
||||
20
app/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix.js
generated
vendored
Normal file
20
app/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-prefix.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
require(__dirname).test(
|
||||
{ xml : "<xml:root/>"
|
||||
, expect :
|
||||
[
|
||||
[ "opentag"
|
||||
, { name: "xml:root"
|
||||
, uri: "http://www.w3.org/XML/1998/namespace"
|
||||
, prefix: "xml"
|
||||
, local: "root"
|
||||
, attributes: {}
|
||||
, ns: {}
|
||||
}
|
||||
]
|
||||
, ["closetag", "xml:root"]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
)
|
||||
|
||||
40
app/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-redefine.js
generated
vendored
Normal file
40
app/node_modules/xml2js/node_modules/sax/test/xmlns-xml-default-redefine.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
require(__dirname).test(
|
||||
{ xml : "<xml:root xmlns:xml='ERROR'/>"
|
||||
, expect :
|
||||
[ ["error"
|
||||
, "xml: prefix must be bound to http://www.w3.org/XML/1998/namespace\n"
|
||||
+ "Actual: ERROR\n"
|
||||
+ "Line: 0\nColumn: 27\nChar: '"
|
||||
]
|
||||
, [ "attribute"
|
||||
, { name: "xmlns:xml"
|
||||
, local: "xml"
|
||||
, prefix: "xmlns"
|
||||
, uri: "http://www.w3.org/2000/xmlns/"
|
||||
, value: "ERROR"
|
||||
}
|
||||
]
|
||||
, [ "opentag"
|
||||
, { name: "xml:root"
|
||||
, uri: "http://www.w3.org/XML/1998/namespace"
|
||||
, prefix: "xml"
|
||||
, local: "root"
|
||||
, attributes:
|
||||
{ "xmlns:xml":
|
||||
{ name: "xmlns:xml"
|
||||
, local: "xml"
|
||||
, prefix: "xmlns"
|
||||
, uri: "http://www.w3.org/2000/xmlns/"
|
||||
, value: "ERROR"
|
||||
}
|
||||
}
|
||||
, ns: {}
|
||||
}
|
||||
]
|
||||
, ["closetag", "xml:root"]
|
||||
]
|
||||
, strict : true
|
||||
, opt : { xmlns: true }
|
||||
}
|
||||
)
|
||||
|
||||
100
app/node_modules/xml2js/package.json
generated
vendored
Normal file
100
app/node_modules/xml2js/package.json
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
{
|
||||
"name": "xml2js",
|
||||
"description": "Simple XML to JavaScript object converter.",
|
||||
"keywords": [
|
||||
"xml",
|
||||
"json"
|
||||
],
|
||||
"homepage": "https://github.com/Leonidas-from-XIV/node-xml2js",
|
||||
"version": "0.1.14",
|
||||
"author": {
|
||||
"name": "Marek Kubica",
|
||||
"email": "marek@xivilization.net",
|
||||
"url": "http://xivilization.net"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "maqr",
|
||||
"email": "maqr.lollerskates@gmail.com",
|
||||
"url": "https://github.com/maqr"
|
||||
},
|
||||
{
|
||||
"name": "Ben Weaver",
|
||||
"url": "http://benweaver.com/"
|
||||
},
|
||||
{
|
||||
"name": "Jae Kwon",
|
||||
"url": "https://github.com/jaekwon"
|
||||
},
|
||||
{
|
||||
"name": "Jim Robert"
|
||||
},
|
||||
{
|
||||
"name": "Ștefan Rusu",
|
||||
"url": "http://www.saltwaterc.eu/"
|
||||
},
|
||||
{
|
||||
"name": "Carter Cole",
|
||||
"email": "carter.cole@cartercole.com",
|
||||
"url": "http://cartercole.com/"
|
||||
},
|
||||
{
|
||||
"name": "Kurt Raschke",
|
||||
"email": "kurt@kurtraschke.com",
|
||||
"url": "http://www.kurtraschke.com/"
|
||||
},
|
||||
{
|
||||
"name": "Contra",
|
||||
"email": "contra@australia.edu",
|
||||
"url": "https://github.com/Contra"
|
||||
},
|
||||
{
|
||||
"name": "Marcelo Diniz",
|
||||
"email": "marudiniz@gmail.com",
|
||||
"url": "https://github.com/mdiniz"
|
||||
},
|
||||
{
|
||||
"name": "Michael Hart",
|
||||
"url": "https://github.com/mhart"
|
||||
},
|
||||
{
|
||||
"name": "Zachary Scott",
|
||||
"email": "zachary@zacharyscott.net",
|
||||
"url": "http://zacharyscott.net/"
|
||||
},
|
||||
{
|
||||
"name": "Raoul Millais",
|
||||
"url": "https://github.com/raoulmillais"
|
||||
},
|
||||
{
|
||||
"name": "Salsita Software",
|
||||
"url": "http://www.salsitasoft.com/"
|
||||
}
|
||||
],
|
||||
"main": "./lib/xml2js",
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Leonidas-from-XIV/node-xml2js.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"sax": ">=0.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffee-script": ">=1.0.1",
|
||||
"zap": ">=0.2.3",
|
||||
"docco": ">=0.3.0"
|
||||
},
|
||||
"_id": "xml2js@0.1.14",
|
||||
"optionalDependencies": {},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"_engineSupported": true,
|
||||
"_npmVersion": "1.1.21",
|
||||
"_nodeVersion": "v0.6.18",
|
||||
"_defaultsLoaded": true,
|
||||
"_from": "xml2js"
|
||||
}
|
||||
173
app/node_modules/xml2js/src/xml2js.coffee
generated
vendored
Normal file
173
app/node_modules/xml2js/src/xml2js.coffee
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
sax = require 'sax'
|
||||
events = require 'events'
|
||||
|
||||
# Underscore has a nice function for this, but we try to go without dependencies
|
||||
isEmpty = (thing) ->
|
||||
return typeof thing is "object" && thing? && Object.keys(thing).length is 0
|
||||
|
||||
exports.defaults =
|
||||
"0.1":
|
||||
explicitCharkey: false
|
||||
trim: true
|
||||
# normalize implicates trimming, just so you know
|
||||
normalize: true
|
||||
# set default attribute object key
|
||||
attrkey: "@"
|
||||
# set default char object key
|
||||
charkey: "#"
|
||||
# always put child nodes in an array
|
||||
explicitArray: false
|
||||
# ignore all attributes regardless
|
||||
ignoreAttrs: false
|
||||
# merge attributes and child elements onto parent object. this may
|
||||
# cause collisions.
|
||||
mergeAttrs: false
|
||||
explicitRoot: false
|
||||
validator: null
|
||||
"0.2":
|
||||
explicitCharkey: false
|
||||
trim: false
|
||||
normalize: false
|
||||
attrkey: "$"
|
||||
charkey: "_"
|
||||
explicitArray: true
|
||||
ignoreAttrs: false
|
||||
mergeAttrs: false
|
||||
explicitRoot: true
|
||||
validator: null
|
||||
|
||||
class exports.ValidationError extends Error
|
||||
constructor: (message) ->
|
||||
@message = message
|
||||
|
||||
class exports.Parser extends events.EventEmitter
|
||||
constructor: (opts) ->
|
||||
# copy this versions default options
|
||||
@options = {}
|
||||
@options[key] = value for own key, value of exports.defaults["0.1"]
|
||||
# overwrite them with the specified options, if any
|
||||
@options[key] = value for own key, value of opts
|
||||
|
||||
@reset()
|
||||
|
||||
reset: =>
|
||||
# remove all previous listeners for events, to prevent event listener
|
||||
# accumulation
|
||||
@removeAllListeners()
|
||||
# make the SAX parser. tried trim and normalize, but they are not
|
||||
# very helpful
|
||||
@saxParser = sax.parser true, {
|
||||
trim: false,
|
||||
normalize: false
|
||||
}
|
||||
|
||||
# emit one error event if the sax parser fails. this is mostly a hack, but
|
||||
# the sax parser isn't state of the art either.
|
||||
err = false
|
||||
@saxParser.onerror = (error) =>
|
||||
if ! err
|
||||
err = true
|
||||
@emit "error", error
|
||||
|
||||
# always use the '#' key, even if there are no subkeys
|
||||
# setting this property by and is deprecated, yet still supported.
|
||||
# better pass it as explicitCharkey option to the constructor
|
||||
@EXPLICIT_CHARKEY = @options.explicitCharkey
|
||||
@resultObject = null
|
||||
stack = []
|
||||
# aliases, so we don't have to type so much
|
||||
attrkey = @options.attrkey
|
||||
charkey = @options.charkey
|
||||
|
||||
@saxParser.onopentag = (node) =>
|
||||
obj = {}
|
||||
obj[charkey] = ""
|
||||
unless @options.ignoreAttrs
|
||||
for own key of node.attributes
|
||||
if attrkey not of obj and not @options.mergeAttrs
|
||||
obj[attrkey] = {}
|
||||
if @options.mergeAttrs
|
||||
obj[key] = node.attributes[key]
|
||||
else
|
||||
obj[attrkey][key] = node.attributes[key]
|
||||
|
||||
# need a place to store the node name
|
||||
obj["#name"] = node.name
|
||||
stack.push obj
|
||||
|
||||
@saxParser.onclosetag = =>
|
||||
obj = stack.pop()
|
||||
nodeName = obj["#name"]
|
||||
delete obj["#name"]
|
||||
|
||||
s = stack[stack.length - 1]
|
||||
# remove the '#' key altogether if it's blank
|
||||
if obj[charkey].match(/^\s*$/)
|
||||
delete obj[charkey]
|
||||
else
|
||||
obj[charkey] = obj[charkey].trim() if @options.trim
|
||||
obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim() if @options.normalize
|
||||
# also do away with '#' key altogether, if there's no subkeys
|
||||
# unless EXPLICIT_CHARKEY is set
|
||||
if Object.keys(obj).length == 1 and charkey of obj and not @EXPLICIT_CHARKEY
|
||||
obj = obj[charkey]
|
||||
|
||||
if @options.emptyTag != undefined && isEmpty obj
|
||||
obj = @options.emptyTag
|
||||
|
||||
if @options.validator?
|
||||
xpath = "/" + (node["#name"] for node in stack).concat(nodeName).join("/")
|
||||
obj = @options.validator(xpath, s and s[nodeName], obj)
|
||||
|
||||
# check whether we closed all the open tags
|
||||
if stack.length > 0
|
||||
if not @options.explicitArray
|
||||
if nodeName not of s
|
||||
s[nodeName] = obj
|
||||
else if s[nodeName] instanceof Array
|
||||
s[nodeName].push obj
|
||||
else
|
||||
old = s[nodeName]
|
||||
s[nodeName] = [old]
|
||||
s[nodeName].push obj
|
||||
else
|
||||
if not (s[nodeName] instanceof Array)
|
||||
s[nodeName] = []
|
||||
s[nodeName].push obj
|
||||
else
|
||||
# if explicitRoot was specified, wrap stuff in the root tag name
|
||||
if @options.explicitRoot
|
||||
# avoid circular references
|
||||
old = obj
|
||||
obj = {}
|
||||
obj[nodeName] = old
|
||||
|
||||
@resultObject = obj
|
||||
@emit "end", @resultObject
|
||||
|
||||
@saxParser.ontext = @saxParser.oncdata = (text) =>
|
||||
s = stack[stack.length - 1]
|
||||
if s
|
||||
s[charkey] += text
|
||||
|
||||
parseString: (str, cb) =>
|
||||
if cb? and typeof cb is "function"
|
||||
@on "end", (result) ->
|
||||
@reset()
|
||||
cb null, result
|
||||
@on "error", (err) ->
|
||||
@reset()
|
||||
cb err
|
||||
|
||||
if str.toString().trim() is ''
|
||||
@emit "end", null
|
||||
return true
|
||||
|
||||
try
|
||||
@saxParser.write str.toString()
|
||||
catch ex
|
||||
if ex instanceof exports.ValidationError
|
||||
@emit("error", ex.message)
|
||||
else
|
||||
throw ex
|
||||
|
||||
42
app/node_modules/xml2js/test/fixtures/sample.xml
generated
vendored
Normal file
42
app/node_modules/xml2js/test/fixtures/sample.xml
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<sample>
|
||||
<chartest desc="Test for CHARs">Character data here!</chartest>
|
||||
<cdatatest desc="Test for CDATA" misc="true"><![CDATA[CDATA here!]]></cdatatest>
|
||||
<nochartest desc="No data" misc="false" />
|
||||
<whitespacetest desc="Test for normalizing and trimming">
|
||||
Line One
|
||||
Line Two
|
||||
</whitespacetest>
|
||||
<listtest>
|
||||
<item>
|
||||
This <subitem>Foo(1)</subitem> is
|
||||
<subitem>Foo(2)</subitem>
|
||||
character
|
||||
<subitem>Foo(3)</subitem>
|
||||
data!
|
||||
<subitem>Foo(4)</subitem>
|
||||
</item>
|
||||
<item>Qux.</item>
|
||||
<item>Quux.</item>
|
||||
</listtest>
|
||||
<arraytest>
|
||||
<item><subitem>Baz.</subitem></item>
|
||||
<item><subitem>Foo.</subitem><subitem>Bar.</subitem></item>
|
||||
</arraytest>
|
||||
<emptytest/>
|
||||
<ordertest>
|
||||
<one>1</one>
|
||||
<two>2</two>
|
||||
<three>3</three>
|
||||
<one>4</one>
|
||||
<two>5</two>
|
||||
<three>6</three>
|
||||
</ordertest>
|
||||
<validatortest>
|
||||
<emptyarray/>
|
||||
<oneitemarray>
|
||||
<item>Bar.</item>
|
||||
</oneitemarray>
|
||||
<numbertest>42</numbertest>
|
||||
<stringtest>43</stringtest>
|
||||
</validatortest>
|
||||
</sample>
|
||||
193
app/node_modules/xml2js/test/xml2js.test.coffee
generated
vendored
Normal file
193
app/node_modules/xml2js/test/xml2js.test.coffee
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
# use zap to run tests, it also detects CoffeeScript files
|
||||
xml2js = require '../lib/xml2js'
|
||||
fs = require 'fs'
|
||||
util = require 'util'
|
||||
assert = require 'assert'
|
||||
path = require 'path'
|
||||
|
||||
fileName = path.join __dirname, '/fixtures/sample.xml'
|
||||
|
||||
skeleton = (options, checks) ->
|
||||
(test) ->
|
||||
xmlString = options?.__xmlString
|
||||
delete options?.__xmlString
|
||||
x2js = new xml2js.Parser options
|
||||
x2js.addListener 'end', (r) ->
|
||||
checks r
|
||||
test.finish()
|
||||
if not xmlString
|
||||
fs.readFile fileName, (err, data) ->
|
||||
x2js.parseString data
|
||||
else
|
||||
x2js.parseString xmlString
|
||||
###
|
||||
The `validator` function validates the value at the XPath. It also transforms the value
|
||||
if necessary to conform to the schema or other validation information being used. If there
|
||||
is an existing value at this path it is supplied in `currentValue` (e.g. this is the second or
|
||||
later item in an array).
|
||||
If the validation fails it should throw a `ValidationError`.
|
||||
###
|
||||
validator = (xpath, currentValue, newValue) ->
|
||||
if xpath == '/sample/validatortest/numbertest'
|
||||
return Number(newValue)
|
||||
else if xpath in ['/sample/arraytest', '/sample/validatortest/emptyarray', '/sample/validatortest/oneitemarray']
|
||||
if not ('item' of newValue)
|
||||
return {'item': []}
|
||||
else if xpath in ['/sample/arraytest/item', '/sample/validatortest/emptyarray/item', '/sample/validatortest/oneitemarray/item']
|
||||
if not currentValue
|
||||
return [newValue]
|
||||
else if xpath == '/validationerror'
|
||||
throw new xml2js.ValidationError("Validation error!")
|
||||
return newValue
|
||||
|
||||
module.exports =
|
||||
'test parse with defaults': skeleton(undefined, (r) ->
|
||||
console.log 'Result object: ' + util.inspect(r, false, 10)
|
||||
assert.equal r['chartest']['@']['desc'], 'Test for CHARs'
|
||||
assert.equal r['chartest']['#'], 'Character data here!'
|
||||
assert.equal r['cdatatest']['@']['desc'], 'Test for CDATA'
|
||||
assert.equal r['cdatatest']['@']['misc'], 'true'
|
||||
assert.equal r['cdatatest']['#'], 'CDATA here!'
|
||||
assert.equal r['nochartest']['@']['desc'], 'No data'
|
||||
assert.equal r['nochartest']['@']['misc'], 'false'
|
||||
assert.equal r['listtest']['item'][0]['#'], 'This is character data!'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][0], 'Foo(1)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][1], 'Foo(2)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][2], 'Foo(3)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][3], 'Foo(4)'
|
||||
assert.equal r['listtest']['item'][1], 'Qux.'
|
||||
assert.equal r['listtest']['item'][2], 'Quux.')
|
||||
|
||||
'test parse with explicitCharkey': skeleton(explicitCharkey: true, (r) ->
|
||||
assert.equal r['chartest']['@']['desc'], 'Test for CHARs'
|
||||
assert.equal r['chartest']['#'], 'Character data here!'
|
||||
assert.equal r['cdatatest']['@']['desc'], 'Test for CDATA'
|
||||
assert.equal r['cdatatest']['@']['misc'], 'true'
|
||||
assert.equal r['cdatatest']['#'], 'CDATA here!'
|
||||
assert.equal r['nochartest']['@']['desc'], 'No data'
|
||||
assert.equal r['nochartest']['@']['misc'], 'false'
|
||||
assert.equal r['listtest']['item'][0]['#'], 'This is character data!'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][0]['#'], 'Foo(1)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][1]['#'], 'Foo(2)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][2]['#'], 'Foo(3)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][3]['#'], 'Foo(4)'
|
||||
assert.equal r['listtest']['item'][1]['#'], 'Qux.'
|
||||
assert.equal r['listtest']['item'][2]['#'], 'Quux.')
|
||||
|
||||
'test parse with mergeAttrs': skeleton(mergeAttrs: true, (r) ->
|
||||
console.log 'Result object: ' + util.inspect(r, false, 10)
|
||||
assert.equal r['chartest']['desc'], 'Test for CHARs'
|
||||
assert.equal r['chartest']['#'], 'Character data here!'
|
||||
assert.equal r['cdatatest']['desc'], 'Test for CDATA'
|
||||
assert.equal r['cdatatest']['misc'], 'true'
|
||||
assert.equal r['cdatatest']['#'], 'CDATA here!'
|
||||
assert.equal r['nochartest']['desc'], 'No data'
|
||||
assert.equal r['nochartest']['misc'], 'false'
|
||||
assert.equal r['listtest']['item'][0]['#'], 'This is character data!'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][0], 'Foo(1)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][1], 'Foo(2)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][2], 'Foo(3)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][3], 'Foo(4)'
|
||||
assert.equal r['listtest']['item'][1], 'Qux.'
|
||||
assert.equal r['listtest']['item'][2], 'Quux.')
|
||||
|
||||
'test default text handling': skeleton(undefined, (r) ->
|
||||
assert.equal r['whitespacetest']['#'], 'Line One Line Two')
|
||||
|
||||
'test disable trimming': skeleton(trim: false, (r) ->
|
||||
assert.equal r['whitespacetest']['#'], 'Line One Line Two')
|
||||
|
||||
'test disable normalize': skeleton(normalize: false, (r) ->
|
||||
assert.equal r['whitespacetest']['#'], 'Line One\n Line Two')
|
||||
|
||||
'test disable normalize and trim': skeleton(normalize: false, trim: false, (r) ->
|
||||
assert.equal r['whitespacetest']['#'], '\n Line One\n Line Two\n ')
|
||||
|
||||
'test default root node elimination': skeleton(__xmlString: '<root></root>', (r) ->
|
||||
assert.deepEqual r, {})
|
||||
|
||||
'test disabled root node elimination': skeleton(__xmlString: '<root></root>', explicitRoot: true, (r) ->
|
||||
assert.deepEqual r, {root: {}})
|
||||
|
||||
'test default empty tag result': skeleton(undefined, (r) ->
|
||||
assert.deepEqual r['emptytest'], {})
|
||||
|
||||
'test empty tag result specified null': skeleton(emptyTag: null, (r) ->
|
||||
assert.equal r['emptytest'], null)
|
||||
|
||||
'test empty string result specified null': skeleton(__xmlString: ' ', (r) ->
|
||||
assert.equal r, null)
|
||||
|
||||
'test parse with custom char and attribute object keys': skeleton(attrkey: 'attrobj', charkey: 'charobj', (r) ->
|
||||
assert.equal r['chartest']['attrobj']['desc'], 'Test for CHARs'
|
||||
assert.equal r['chartest']['charobj'], 'Character data here!'
|
||||
assert.equal r['cdatatest']['attrobj']['desc'], 'Test for CDATA'
|
||||
assert.equal r['cdatatest']['attrobj']['misc'], 'true'
|
||||
assert.equal r['cdatatest']['charobj'], 'CDATA here!'
|
||||
assert.equal r['nochartest']['attrobj']['desc'], 'No data'
|
||||
assert.equal r['nochartest']['attrobj']['misc'], 'false')
|
||||
|
||||
'test child node without explicitArray': skeleton(explicitArray: false, (r) ->
|
||||
assert.equal r['arraytest']['item'][0]['subitem'], 'Baz.'
|
||||
assert.equal r['arraytest']['item'][1]['subitem'][0], 'Foo.'
|
||||
assert.equal r['arraytest']['item'][1]['subitem'][1], 'Bar.')
|
||||
|
||||
'test child node with explicitArray': skeleton(explicitArray: true, (r) ->
|
||||
assert.equal r['arraytest'][0]['item'][0]['subitem'][0], 'Baz.'
|
||||
assert.equal r['arraytest'][0]['item'][1]['subitem'][0], 'Foo.'
|
||||
assert.equal r['arraytest'][0]['item'][1]['subitem'][1], 'Bar.')
|
||||
|
||||
'test ignore attributes': skeleton(ignoreAttrs: true, (r) ->
|
||||
assert.equal r['chartest'], 'Character data here!'
|
||||
assert.equal r['cdatatest'], 'CDATA here!'
|
||||
assert.deepEqual r['nochartest'], {}
|
||||
assert.equal r['listtest']['item'][0]['#'], 'This is character data!'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][0], 'Foo(1)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][1], 'Foo(2)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][2], 'Foo(3)'
|
||||
assert.equal r['listtest']['item'][0]['subitem'][3], 'Foo(4)'
|
||||
assert.equal r['listtest']['item'][1], 'Qux.'
|
||||
assert.equal r['listtest']['item'][2], 'Quux.')
|
||||
|
||||
'test simple callback mode': (test) ->
|
||||
x2js = new xml2js.Parser()
|
||||
fs.readFile fileName, (err, data) ->
|
||||
assert.equal err, null
|
||||
x2js.parseString data, (err, r) ->
|
||||
assert.equal err, null
|
||||
# just a single test to check whether we parsed anything
|
||||
assert.equal r['chartest']['#'], 'Character data here!'
|
||||
test.finish()
|
||||
|
||||
'test double parse': (test) ->
|
||||
x2js = new xml2js.Parser()
|
||||
fs.readFile fileName, (err, data) ->
|
||||
assert.equal err, null
|
||||
x2js.parseString data, (err, r) ->
|
||||
assert.equal err, null
|
||||
# make sure we parsed anything
|
||||
assert.equal r['chartest']['#'], 'Character data here!'
|
||||
x2js.parseString data, (err, r) ->
|
||||
assert.equal err, null
|
||||
assert.equal r['chartest']['#'], 'Character data here!'
|
||||
test.finish()
|
||||
|
||||
'test validator': skeleton(validator: validator, (r) ->
|
||||
assert.equal typeof r['validatortest']['stringtest'], 'string'
|
||||
assert.equal typeof r['validatortest']['numbertest'], 'number'
|
||||
assert.ok r['validatortest']['emptyarray']['item'] instanceof Array
|
||||
assert.equal r['validatortest']['emptyarray']['item'].length, 0
|
||||
assert.ok r['validatortest']['oneitemarray']['item'] instanceof Array
|
||||
assert.equal r['validatortest']['oneitemarray']['item'].length, 1
|
||||
assert.equal r['validatortest']['oneitemarray']['item'], 'Bar.'
|
||||
assert.ok r['arraytest']['item'] instanceof Array
|
||||
assert.equal r['arraytest']['item'].length, 2
|
||||
assert.equal r['arraytest']['item'][0]['subitem'], 'Baz.'
|
||||
assert.equal r['arraytest']['item'][1]['subitem'][0], 'Foo.'
|
||||
assert.equal r['arraytest']['item'][1]['subitem'][1], 'Bar.')
|
||||
|
||||
'test validation error': (test) ->
|
||||
x2js = new xml2js.Parser({validator: validator})
|
||||
x2js.parseString '<validationerror/>', (err, r) ->
|
||||
assert.equal err, 'Validation error!'
|
||||
test.finish()
|
||||
Reference in New Issue
Block a user