sax 1.1.0 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +16 -32
- package/lib/sax.js +1450 -1317
- package/package.json +16 -4
- package/AUTHORS +0 -10
- package/CONTRIBUTING.md +0 -14
- package/examples/big-not-pretty.xml +0 -8002
- package/examples/example.js +0 -29
- package/examples/get-products.js +0 -58
- package/examples/hello-world.js +0 -4
- package/examples/not-pretty.xml +0 -8
- package/examples/pretty-print.js +0 -74
- package/examples/shopping.xml +0 -2
- package/examples/strict.dtd +0 -870
- package/examples/test.html +0 -15
- package/examples/test.xml +0 -1254
- package/test/attribute-name.js +0 -33
- package/test/attribute-no-space.js +0 -75
- package/test/bom.js +0 -44
- package/test/buffer-overrun.js +0 -26
- package/test/case.js +0 -50
- package/test/cdata-chunked.js +0 -11
- package/test/cdata-end-split.js +0 -15
- package/test/cdata-fake-end.js +0 -28
- package/test/cdata-multiple.js +0 -15
- package/test/cdata.js +0 -10
- package/test/cyrillic.js +0 -8
- package/test/duplicate-attribute.js +0 -13
- package/test/emoji.js +0 -12
- package/test/end_empty_stream.js +0 -5
- package/test/entities.js +0 -10
- package/test/entity-mega.js +0 -16
- package/test/flush.js +0 -13
- package/test/index.js +0 -86
- package/test/issue-23.js +0 -43
- package/test/issue-30.js +0 -24
- package/test/issue-35.js +0 -15
- package/test/issue-47.js +0 -12
- package/test/issue-49.js +0 -31
- package/test/issue-84.js +0 -13
- package/test/issue-86.js +0 -30
- package/test/parser-position.js +0 -28
- package/test/script-close-better.js +0 -12
- package/test/script.js +0 -12
- package/test/self-closing-child-strict.js +0 -44
- package/test/self-closing-child.js +0 -44
- package/test/self-closing-tag.js +0 -25
- package/test/stand-alone-comment.js +0 -11
- package/test/stray-ending.js +0 -17
- package/test/trailing-attribute-no-value.js +0 -10
- package/test/trailing-non-whitespace.js +0 -18
- package/test/unclosed-root.js +0 -11
- package/test/unquoted.js +0 -18
- package/test/utf8-split.js +0 -34
- package/test/xml_entities.js +0 -11
- package/test/xmlns-as-tag-name.js +0 -15
- package/test/xmlns-issue-41.js +0 -68
- package/test/xmlns-rebinding.js +0 -63
- package/test/xmlns-strict.js +0 -74
- package/test/xmlns-unbound-element.js +0 -33
- package/test/xmlns-unbound.js +0 -15
- package/test/xmlns-xml-default-ns.js +0 -31
- package/test/xmlns-xml-default-prefix-attribute.js +0 -36
- package/test/xmlns-xml-default-prefix.js +0 -21
- package/test/xmlns-xml-default-redefine.js +0 -41
package/test/issue-86.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require(__dirname).test
|
|
2
|
-
( { xml : "<root>abc</root>de<f"
|
|
3
|
-
, expect :
|
|
4
|
-
[ [ "opentag", { name: "ROOT", attributes: {}, isSelfClosing: false } ]
|
|
5
|
-
, [ "text", "abc" ]
|
|
6
|
-
, [ "closetag", "ROOT" ]
|
|
7
|
-
, [ "text", "de<f" ]
|
|
8
|
-
]
|
|
9
|
-
, strict : false
|
|
10
|
-
, opt : {}
|
|
11
|
-
}
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
require(__dirname).test
|
|
15
|
-
( { xml : "<root>abc</root>de<f"
|
|
16
|
-
, expect :
|
|
17
|
-
[ [ "opentag", { name: "root", attributes: {}, isSelfClosing: false } ]
|
|
18
|
-
, [ "text", "abc" ]
|
|
19
|
-
, [ "closetag", "root" ]
|
|
20
|
-
, [ "error", "Text data outside of root node.\nLine: 0\nColumn: 17\nChar: d" ]
|
|
21
|
-
, [ "text", "d" ]
|
|
22
|
-
, [ "error", "Text data outside of root node.\nLine: 0\nColumn: 18\nChar: e" ]
|
|
23
|
-
, [ "text", "e" ]
|
|
24
|
-
, [ "error", "Unexpected end\nLine: 0\nColumn: 20\nChar: " ]
|
|
25
|
-
]
|
|
26
|
-
, strict : true
|
|
27
|
-
, opt : {}
|
|
28
|
-
}
|
|
29
|
-
)
|
|
30
|
-
|
package/test/parser-position.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var sax = require("../lib/sax"),
|
|
2
|
-
assert = require("assert")
|
|
3
|
-
|
|
4
|
-
function testPosition(chunks, expectedEvents) {
|
|
5
|
-
var parser = sax.parser();
|
|
6
|
-
expectedEvents.forEach(function(expectation) {
|
|
7
|
-
parser['on' + expectation[0]] = function() {
|
|
8
|
-
for (var prop in expectation[1]) {
|
|
9
|
-
assert.equal(parser[prop], expectation[1][prop]);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
chunks.forEach(function(chunk) {
|
|
14
|
-
parser.write(chunk);
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
testPosition(['<div>abcdefgh</div>'],
|
|
19
|
-
[ ['opentag', { position: 5, startTagPosition: 1 }]
|
|
20
|
-
, ['text', { position: 19, startTagPosition: 14 }]
|
|
21
|
-
, ['closetag', { position: 19, startTagPosition: 14 }]
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
testPosition(['<div>abcde','fgh</div>'],
|
|
25
|
-
[ ['opentag', { position: 5, startTagPosition: 1 }]
|
|
26
|
-
, ['text', { position: 19, startTagPosition: 14 }]
|
|
27
|
-
, ['closetag', { position: 19, startTagPosition: 14 }]
|
|
28
|
-
]);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require(__dirname).test({
|
|
2
|
-
xml : "<html><head><script>'<div>foo</div></'</script></head></html>",
|
|
3
|
-
expect : [
|
|
4
|
-
["opentag", {"name": "HTML","attributes": {}, isSelfClosing: false}],
|
|
5
|
-
["opentag", {"name": "HEAD","attributes": {}, isSelfClosing: false}],
|
|
6
|
-
["opentag", {"name": "SCRIPT","attributes": {}, isSelfClosing: false}],
|
|
7
|
-
["script", "'<div>foo</div></'"],
|
|
8
|
-
["closetag", "SCRIPT"],
|
|
9
|
-
["closetag", "HEAD"],
|
|
10
|
-
["closetag", "HTML"]
|
|
11
|
-
]
|
|
12
|
-
});
|
package/test/script.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require(__dirname).test({
|
|
2
|
-
xml : "<html><head><script>if (1 < 0) { console.log('elo there'); }</script></head></html>",
|
|
3
|
-
expect : [
|
|
4
|
-
["opentag", {"name": "HTML","attributes": {}, "isSelfClosing": false}],
|
|
5
|
-
["opentag", {"name": "HEAD","attributes": {}, "isSelfClosing": false}],
|
|
6
|
-
["opentag", {"name": "SCRIPT","attributes": {}, "isSelfClosing": false}],
|
|
7
|
-
["script", "if (1 < 0) { console.log('elo there'); }"],
|
|
8
|
-
["closetag", "SCRIPT"],
|
|
9
|
-
["closetag", "HEAD"],
|
|
10
|
-
["closetag", "HTML"]
|
|
11
|
-
]
|
|
12
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require(__dirname).test({
|
|
3
|
-
xml :
|
|
4
|
-
"<root>"+
|
|
5
|
-
"<child>" +
|
|
6
|
-
"<haha />" +
|
|
7
|
-
"</child>" +
|
|
8
|
-
"<monkey>" +
|
|
9
|
-
"=(|)" +
|
|
10
|
-
"</monkey>" +
|
|
11
|
-
"</root>",
|
|
12
|
-
expect : [
|
|
13
|
-
["opentag", {
|
|
14
|
-
"name": "root",
|
|
15
|
-
"attributes": {},
|
|
16
|
-
"isSelfClosing": false
|
|
17
|
-
}],
|
|
18
|
-
["opentag", {
|
|
19
|
-
"name": "child",
|
|
20
|
-
"attributes": {},
|
|
21
|
-
"isSelfClosing": false
|
|
22
|
-
}],
|
|
23
|
-
["opentag", {
|
|
24
|
-
"name": "haha",
|
|
25
|
-
"attributes": {},
|
|
26
|
-
"isSelfClosing": true
|
|
27
|
-
}],
|
|
28
|
-
["closetag", "haha"],
|
|
29
|
-
["closetag", "child"],
|
|
30
|
-
["opentag", {
|
|
31
|
-
"name": "monkey",
|
|
32
|
-
"attributes": {},
|
|
33
|
-
"isSelfClosing": false
|
|
34
|
-
}],
|
|
35
|
-
["text", "=(|)"],
|
|
36
|
-
["closetag", "monkey"],
|
|
37
|
-
["closetag", "root"],
|
|
38
|
-
["end"],
|
|
39
|
-
["ready"]
|
|
40
|
-
],
|
|
41
|
-
strict : true,
|
|
42
|
-
opt : {}
|
|
43
|
-
});
|
|
44
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require(__dirname).test({
|
|
3
|
-
xml :
|
|
4
|
-
"<root>"+
|
|
5
|
-
"<child>" +
|
|
6
|
-
"<haha />" +
|
|
7
|
-
"</child>" +
|
|
8
|
-
"<monkey>" +
|
|
9
|
-
"=(|)" +
|
|
10
|
-
"</monkey>" +
|
|
11
|
-
"</root>",
|
|
12
|
-
expect : [
|
|
13
|
-
["opentag", {
|
|
14
|
-
"name": "ROOT",
|
|
15
|
-
"attributes": {},
|
|
16
|
-
"isSelfClosing": false
|
|
17
|
-
}],
|
|
18
|
-
["opentag", {
|
|
19
|
-
"name": "CHILD",
|
|
20
|
-
"attributes": {},
|
|
21
|
-
"isSelfClosing": false
|
|
22
|
-
}],
|
|
23
|
-
["opentag", {
|
|
24
|
-
"name": "HAHA",
|
|
25
|
-
"attributes": {},
|
|
26
|
-
"isSelfClosing": true
|
|
27
|
-
}],
|
|
28
|
-
["closetag", "HAHA"],
|
|
29
|
-
["closetag", "CHILD"],
|
|
30
|
-
["opentag", {
|
|
31
|
-
"name": "MONKEY",
|
|
32
|
-
"attributes": {},
|
|
33
|
-
"isSelfClosing": false
|
|
34
|
-
}],
|
|
35
|
-
["text", "=(|)"],
|
|
36
|
-
["closetag", "MONKEY"],
|
|
37
|
-
["closetag", "ROOT"],
|
|
38
|
-
["end"],
|
|
39
|
-
["ready"]
|
|
40
|
-
],
|
|
41
|
-
strict : false,
|
|
42
|
-
opt : {}
|
|
43
|
-
});
|
|
44
|
-
|
package/test/self-closing-tag.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require(__dirname).test({
|
|
3
|
-
xml :
|
|
4
|
-
"<root> "+
|
|
5
|
-
"<haha /> "+
|
|
6
|
-
"<haha/> "+
|
|
7
|
-
"<monkey> "+
|
|
8
|
-
"=(|) "+
|
|
9
|
-
"</monkey>"+
|
|
10
|
-
"</root> ",
|
|
11
|
-
expect : [
|
|
12
|
-
["opentag", {name:"ROOT", attributes:{}, isSelfClosing: false}],
|
|
13
|
-
["opentag", {name:"HAHA", attributes:{}, isSelfClosing: true}],
|
|
14
|
-
["closetag", "HAHA"],
|
|
15
|
-
["opentag", {name:"HAHA", attributes:{}, isSelfClosing: true}],
|
|
16
|
-
["closetag", "HAHA"],
|
|
17
|
-
// ["opentag", {name:"HAHA", attributes:{}}],
|
|
18
|
-
// ["closetag", "HAHA"],
|
|
19
|
-
["opentag", {name:"MONKEY", attributes:{}, isSelfClosing: false}],
|
|
20
|
-
["text", "=(|)"],
|
|
21
|
-
["closetag", "MONKEY"],
|
|
22
|
-
["closetag", "ROOT"]
|
|
23
|
-
],
|
|
24
|
-
opt : { trim : true }
|
|
25
|
-
});
|
package/test/stray-ending.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// stray ending tags should just be ignored in non-strict mode.
|
|
2
|
-
// https://github.com/isaacs/sax-js/issues/32
|
|
3
|
-
require(__dirname).test
|
|
4
|
-
( { xml :
|
|
5
|
-
"<a><b></c></b></a>"
|
|
6
|
-
, expect :
|
|
7
|
-
[ [ "opentag", { name: "A", attributes: {}, isSelfClosing: false } ]
|
|
8
|
-
, [ "opentag", { name: "B", attributes: {}, isSelfClosing: false } ]
|
|
9
|
-
, [ "text", "</c>" ]
|
|
10
|
-
, [ "closetag", "B" ]
|
|
11
|
-
, [ "closetag", "A" ]
|
|
12
|
-
]
|
|
13
|
-
, strict : false
|
|
14
|
-
, opt : {}
|
|
15
|
-
}
|
|
16
|
-
)
|
|
17
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require(__dirname).test({
|
|
3
|
-
xml : "<span>Welcome,</span> to monkey land",
|
|
4
|
-
expect : [
|
|
5
|
-
["opentag", {
|
|
6
|
-
"name": "SPAN",
|
|
7
|
-
"attributes": {},
|
|
8
|
-
isSelfClosing: false
|
|
9
|
-
}],
|
|
10
|
-
["text", "Welcome,"],
|
|
11
|
-
["closetag", "SPAN"],
|
|
12
|
-
["text", " to monkey land"],
|
|
13
|
-
["end"],
|
|
14
|
-
["ready"]
|
|
15
|
-
],
|
|
16
|
-
strict : false,
|
|
17
|
-
opt : {}
|
|
18
|
-
});
|
package/test/unclosed-root.js
DELETED
package/test/unquoted.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// unquoted attributes should be ok in non-strict mode
|
|
2
|
-
// https://github.com/isaacs/sax-js/issues/31
|
|
3
|
-
require(__dirname).test
|
|
4
|
-
( { xml :
|
|
5
|
-
"<span class=test hello=world></span>"
|
|
6
|
-
, expect :
|
|
7
|
-
[ [ "attribute", { name: "CLASS", value: "test" } ]
|
|
8
|
-
, [ "attribute", { name: "HELLO", value: "world" } ]
|
|
9
|
-
, [ "opentag", { name: "SPAN",
|
|
10
|
-
attributes: { CLASS: "test", HELLO: "world" },
|
|
11
|
-
isSelfClosing: false } ]
|
|
12
|
-
, [ "closetag", "SPAN" ]
|
|
13
|
-
]
|
|
14
|
-
, strict : false
|
|
15
|
-
, opt : {}
|
|
16
|
-
}
|
|
17
|
-
)
|
|
18
|
-
|
package/test/utf8-split.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
var assert = require('assert')
|
|
2
|
-
var saxStream = require('../lib/sax').createStream()
|
|
3
|
-
|
|
4
|
-
var b = new Buffer('误')
|
|
5
|
-
|
|
6
|
-
saxStream.on('text', function(text) {
|
|
7
|
-
assert.equal(text, b.toString())
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
saxStream.write(new Buffer('<test><a>'))
|
|
11
|
-
saxStream.write(b.slice(0, 1))
|
|
12
|
-
saxStream.write(b.slice(1))
|
|
13
|
-
saxStream.write(new Buffer('</a><b>'))
|
|
14
|
-
saxStream.write(b.slice(0, 2))
|
|
15
|
-
saxStream.write(b.slice(2))
|
|
16
|
-
saxStream.write(new Buffer('</b><c>'))
|
|
17
|
-
saxStream.write(b)
|
|
18
|
-
saxStream.write(new Buffer('</c>'))
|
|
19
|
-
saxStream.write(Buffer.concat([new Buffer('<d>'), b.slice(0, 1)]))
|
|
20
|
-
saxStream.end(Buffer.concat([b.slice(1), new Buffer('</d></test>')]))
|
|
21
|
-
|
|
22
|
-
var saxStream2 = require('../lib/sax').createStream()
|
|
23
|
-
|
|
24
|
-
saxStream2.on('text', function(text) {
|
|
25
|
-
assert.equal(text, '�')
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
saxStream2.write(new Buffer('<root>'));
|
|
29
|
-
saxStream2.write(new Buffer('<e>'));
|
|
30
|
-
saxStream2.write(new Buffer([0xC0]));
|
|
31
|
-
saxStream2.write(new Buffer('</e>'));
|
|
32
|
-
saxStream2.write(Buffer.concat([new Buffer('<f>'), b.slice(0,1)]));
|
|
33
|
-
saxStream2.write(new Buffer('</root>'));
|
|
34
|
-
saxStream2.end();
|
package/test/xml_entities.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require(__dirname).test({
|
|
2
|
-
opt: { strictEntities: true },
|
|
3
|
-
xml: '<r>⌋ ' +
|
|
4
|
-
'♠ © → & ' +
|
|
5
|
-
'< < < < < > ℜ ℘ €</r>',
|
|
6
|
-
expect: [
|
|
7
|
-
['opentag', {'name':'R', attributes:{}, isSelfClosing: false}],
|
|
8
|
-
['text', '⌋ ♠ © → & < < < < < > ℜ ℘ €'],
|
|
9
|
-
['closetag', 'R']
|
|
10
|
-
]
|
|
11
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require(__dirname).test
|
|
3
|
-
( { xml :
|
|
4
|
-
"<xmlns/>"
|
|
5
|
-
, expect :
|
|
6
|
-
[ [ "opentag", { name: "xmlns", uri: "", prefix: "", local: "xmlns",
|
|
7
|
-
attributes: {}, ns: {},
|
|
8
|
-
isSelfClosing: true}
|
|
9
|
-
],
|
|
10
|
-
["closetag", "xmlns"]
|
|
11
|
-
]
|
|
12
|
-
, strict : true
|
|
13
|
-
, opt : { xmlns: true }
|
|
14
|
-
}
|
|
15
|
-
);
|
package/test/xmlns-issue-41.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var t = require(__dirname)
|
|
2
|
-
|
|
3
|
-
, xmls = // should be the same both ways.
|
|
4
|
-
[ "<parent xmlns:a='http://ATTRIBUTE' a:attr='value' />"
|
|
5
|
-
, "<parent a:attr='value' xmlns:a='http://ATTRIBUTE' />" ]
|
|
6
|
-
|
|
7
|
-
, ex1 =
|
|
8
|
-
[ [ "opennamespace"
|
|
9
|
-
, { prefix: "a"
|
|
10
|
-
, uri: "http://ATTRIBUTE"
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
, [ "attribute"
|
|
14
|
-
, { name: "xmlns:a"
|
|
15
|
-
, value: "http://ATTRIBUTE"
|
|
16
|
-
, prefix: "xmlns"
|
|
17
|
-
, local: "a"
|
|
18
|
-
, uri: "http://www.w3.org/2000/xmlns/"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
, [ "attribute"
|
|
22
|
-
, { name: "a:attr"
|
|
23
|
-
, local: "attr"
|
|
24
|
-
, prefix: "a"
|
|
25
|
-
, uri: "http://ATTRIBUTE"
|
|
26
|
-
, value: "value"
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
, [ "opentag"
|
|
30
|
-
, { name: "parent"
|
|
31
|
-
, uri: ""
|
|
32
|
-
, prefix: ""
|
|
33
|
-
, local: "parent"
|
|
34
|
-
, attributes:
|
|
35
|
-
{ "a:attr":
|
|
36
|
-
{ name: "a:attr"
|
|
37
|
-
, local: "attr"
|
|
38
|
-
, prefix: "a"
|
|
39
|
-
, uri: "http://ATTRIBUTE"
|
|
40
|
-
, value: "value"
|
|
41
|
-
}
|
|
42
|
-
, "xmlns:a":
|
|
43
|
-
{ name: "xmlns:a"
|
|
44
|
-
, local: "a"
|
|
45
|
-
, prefix: "xmlns"
|
|
46
|
-
, uri: "http://www.w3.org/2000/xmlns/"
|
|
47
|
-
, value: "http://ATTRIBUTE"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
, ns: {"a": "http://ATTRIBUTE"}
|
|
51
|
-
, isSelfClosing: true
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
, ["closetag", "parent"]
|
|
55
|
-
, ["closenamespace", { prefix: "a", uri: "http://ATTRIBUTE" }]
|
|
56
|
-
]
|
|
57
|
-
|
|
58
|
-
// swap the order of elements 2 and 1
|
|
59
|
-
, ex2 = [ex1[0], ex1[2], ex1[1]].concat(ex1.slice(3))
|
|
60
|
-
, expected = [ex1, ex2]
|
|
61
|
-
|
|
62
|
-
xmls.forEach(function (x, i) {
|
|
63
|
-
t.test({ xml: x
|
|
64
|
-
, expect: expected[i]
|
|
65
|
-
, strict: true
|
|
66
|
-
, opt: { xmlns: true }
|
|
67
|
-
})
|
|
68
|
-
})
|
package/test/xmlns-rebinding.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require(__dirname).test
|
|
3
|
-
( { xml :
|
|
4
|
-
"<root xmlns:x='x1' xmlns:y='y1' x:a='x1' y:a='y1'>"+
|
|
5
|
-
"<rebind xmlns:x='x2'>"+
|
|
6
|
-
"<check x:a='x2' y:a='y1'/>"+
|
|
7
|
-
"</rebind>"+
|
|
8
|
-
"<check x:a='x1' y:a='y1'/>"+
|
|
9
|
-
"</root>"
|
|
10
|
-
|
|
11
|
-
, expect :
|
|
12
|
-
[ [ "opennamespace", { prefix: "x", uri: "x1" } ]
|
|
13
|
-
, [ "opennamespace", { prefix: "y", uri: "y1" } ]
|
|
14
|
-
, [ "attribute", { name: "xmlns:x", value: "x1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } ]
|
|
15
|
-
, [ "attribute", { name: "xmlns:y", value: "y1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "y" } ]
|
|
16
|
-
, [ "attribute", { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } ]
|
|
17
|
-
, [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ]
|
|
18
|
-
, [ "opentag", { name: "root", uri: "", prefix: "", local: "root",
|
|
19
|
-
attributes: { "xmlns:x": { name: "xmlns:x", value: "x1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" }
|
|
20
|
-
, "xmlns:y": { name: "xmlns:y", value: "y1", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "y" }
|
|
21
|
-
, "x:a": { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" }
|
|
22
|
-
, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
|
|
23
|
-
ns: { x: 'x1', y: 'y1' },
|
|
24
|
-
isSelfClosing: false } ]
|
|
25
|
-
|
|
26
|
-
, [ "opennamespace", { prefix: "x", uri: "x2" } ]
|
|
27
|
-
, [ "attribute", { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } ]
|
|
28
|
-
, [ "opentag", { name: "rebind", uri: "", prefix: "", local: "rebind",
|
|
29
|
-
attributes: { "xmlns:x": { name: "xmlns:x", value: "x2", uri: "http://www.w3.org/2000/xmlns/", prefix: "xmlns", local: "x" } },
|
|
30
|
-
ns: { x: 'x2' },
|
|
31
|
-
isSelfClosing: false } ]
|
|
32
|
-
|
|
33
|
-
, [ "attribute", { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" } ]
|
|
34
|
-
, [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ]
|
|
35
|
-
, [ "opentag", { name: "check", uri: "", prefix: "", local: "check",
|
|
36
|
-
attributes: { "x:a": { name: "x:a", value: "x2", uri: "x2", prefix: "x", local: "a" }
|
|
37
|
-
, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
|
|
38
|
-
ns: { x: 'x2' },
|
|
39
|
-
isSelfClosing: true } ]
|
|
40
|
-
|
|
41
|
-
, [ "closetag", "check" ]
|
|
42
|
-
|
|
43
|
-
, [ "closetag", "rebind" ]
|
|
44
|
-
, [ "closenamespace", { prefix: "x", uri: "x2" } ]
|
|
45
|
-
|
|
46
|
-
, [ "attribute", { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" } ]
|
|
47
|
-
, [ "attribute", { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } ]
|
|
48
|
-
, [ "opentag", { name: "check", uri: "", prefix: "", local: "check",
|
|
49
|
-
attributes: { "x:a": { name: "x:a", value: "x1", uri: "x1", prefix: "x", local: "a" }
|
|
50
|
-
, "y:a": { name: "y:a", value: "y1", uri: "y1", prefix: "y", local: "a" } },
|
|
51
|
-
ns: { x: 'x1', y: 'y1' },
|
|
52
|
-
isSelfClosing: true } ]
|
|
53
|
-
, [ "closetag", "check" ]
|
|
54
|
-
|
|
55
|
-
, [ "closetag", "root" ]
|
|
56
|
-
, [ "closenamespace", { prefix: "x", uri: "x1" } ]
|
|
57
|
-
, [ "closenamespace", { prefix: "y", uri: "y1" } ]
|
|
58
|
-
]
|
|
59
|
-
, strict : true
|
|
60
|
-
, opt : { xmlns: true }
|
|
61
|
-
}
|
|
62
|
-
)
|
|
63
|
-
|
package/test/xmlns-strict.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require(__dirname).test
|
|
3
|
-
( { xml :
|
|
4
|
-
"<root>"+
|
|
5
|
-
"<plain attr='normal'/>"+
|
|
6
|
-
"<ns1 xmlns='uri:default'>"+
|
|
7
|
-
"<plain attr='normal'/>"+
|
|
8
|
-
"</ns1>"+
|
|
9
|
-
"<ns2 xmlns:a='uri:nsa'>"+
|
|
10
|
-
"<plain attr='normal'/>"+
|
|
11
|
-
"<a:ns a:attr='namespaced'/>"+
|
|
12
|
-
"</ns2>"+
|
|
13
|
-
"</root>"
|
|
14
|
-
|
|
15
|
-
, expect :
|
|
16
|
-
[ [ "opentag", { name: "root", prefix: "", local: "root", uri: "",
|
|
17
|
-
attributes: {}, ns: {}, isSelfClosing: false } ]
|
|
18
|
-
|
|
19
|
-
, [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]
|
|
20
|
-
, [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "",
|
|
21
|
-
attributes: { "attr": { name: "attr", value: "normal", uri: "", prefix: "", local: "attr", uri: "" } },
|
|
22
|
-
ns: {}, isSelfClosing: true } ]
|
|
23
|
-
, [ "closetag", "plain" ]
|
|
24
|
-
|
|
25
|
-
, [ "opennamespace", { prefix: "", uri: "uri:default" } ]
|
|
26
|
-
|
|
27
|
-
, [ "attribute", { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } ]
|
|
28
|
-
, [ "opentag", { name: "ns1", prefix: "", local: "ns1", uri: "uri:default",
|
|
29
|
-
attributes: { "xmlns": { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } },
|
|
30
|
-
ns: { "": "uri:default" }, isSelfClosing: false } ]
|
|
31
|
-
|
|
32
|
-
, [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]
|
|
33
|
-
, [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "uri:default", ns: { '': 'uri:default' },
|
|
34
|
-
attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } },
|
|
35
|
-
isSelfClosing: true } ]
|
|
36
|
-
, [ "closetag", "plain" ]
|
|
37
|
-
|
|
38
|
-
, [ "closetag", "ns1" ]
|
|
39
|
-
|
|
40
|
-
, [ "closenamespace", { prefix: "", uri: "uri:default" } ]
|
|
41
|
-
|
|
42
|
-
, [ "opennamespace", { prefix: "a", uri: "uri:nsa" } ]
|
|
43
|
-
|
|
44
|
-
, [ "attribute", { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } ]
|
|
45
|
-
|
|
46
|
-
, [ "opentag", { name: "ns2", prefix: "", local: "ns2", uri: "",
|
|
47
|
-
attributes: { "xmlns:a": { name: "xmlns:a", value: "uri:nsa", prefix: "xmlns", local: "a", uri: "http://www.w3.org/2000/xmlns/" } },
|
|
48
|
-
ns: { a: "uri:nsa" }, isSelfClosing: false } ]
|
|
49
|
-
|
|
50
|
-
, [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]
|
|
51
|
-
, [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "",
|
|
52
|
-
attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } },
|
|
53
|
-
ns: { a: 'uri:nsa' },
|
|
54
|
-
isSelfClosing: true } ]
|
|
55
|
-
, [ "closetag", "plain" ]
|
|
56
|
-
|
|
57
|
-
, [ "attribute", { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } ]
|
|
58
|
-
, [ "opentag", { name: "a:ns", prefix: "a", local: "ns", uri: "uri:nsa",
|
|
59
|
-
attributes: { "a:attr": { name: "a:attr", value: "namespaced", prefix: "a", local: "attr", uri: "uri:nsa" } },
|
|
60
|
-
ns: { a: 'uri:nsa' },
|
|
61
|
-
isSelfClosing: true } ]
|
|
62
|
-
, [ "closetag", "a:ns" ]
|
|
63
|
-
|
|
64
|
-
, [ "closetag", "ns2" ]
|
|
65
|
-
|
|
66
|
-
, [ "closenamespace", { prefix: "a", uri: "uri:nsa" } ]
|
|
67
|
-
|
|
68
|
-
, [ "closetag", "root" ]
|
|
69
|
-
]
|
|
70
|
-
, strict : true
|
|
71
|
-
, opt : { xmlns: true }
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
require(__dirname).test(
|
|
2
|
-
{ strict : true
|
|
3
|
-
, opt : { xmlns: true }
|
|
4
|
-
, expect :
|
|
5
|
-
[ [ "error", "Unbound namespace prefix: \"unbound:root\"\nLine: 0\nColumn: 15\nChar: >"]
|
|
6
|
-
, [ "opentag", { name: "unbound:root", uri: "unbound", prefix: "unbound", local: "root"
|
|
7
|
-
, attributes: {}, ns: {}, isSelfClosing: true } ]
|
|
8
|
-
, [ "closetag", "unbound:root" ]
|
|
9
|
-
]
|
|
10
|
-
}
|
|
11
|
-
).write("<unbound:root/>");
|
|
12
|
-
|
|
13
|
-
require(__dirname).test(
|
|
14
|
-
{ strict : true
|
|
15
|
-
, opt : { xmlns: true }
|
|
16
|
-
, expect :
|
|
17
|
-
[ [ "opennamespace", { prefix: "unbound", uri: "someuri" } ]
|
|
18
|
-
, [ "attribute", { name: 'xmlns:unbound', value: 'someuri'
|
|
19
|
-
, prefix: 'xmlns', local: 'unbound'
|
|
20
|
-
, uri: 'http://www.w3.org/2000/xmlns/' } ]
|
|
21
|
-
, [ "opentag", { name: "unbound:root", uri: "someuri", prefix: "unbound", local: "root"
|
|
22
|
-
, attributes: { 'xmlns:unbound': {
|
|
23
|
-
name: 'xmlns:unbound'
|
|
24
|
-
, value: 'someuri'
|
|
25
|
-
, prefix: 'xmlns'
|
|
26
|
-
, local: 'unbound'
|
|
27
|
-
, uri: 'http://www.w3.org/2000/xmlns/' } }
|
|
28
|
-
, ns: { "unbound": "someuri" }, isSelfClosing: true } ]
|
|
29
|
-
, [ "closetag", "unbound:root" ]
|
|
30
|
-
, [ "closenamespace", { prefix: 'unbound', uri: 'someuri' }]
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
).write("<unbound:root xmlns:unbound=\"someuri\"/>");
|
package/test/xmlns-unbound.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
require(__dirname).test(
|
|
3
|
-
{ strict : true
|
|
4
|
-
, opt : { xmlns: true }
|
|
5
|
-
, expect :
|
|
6
|
-
[ ["error", "Unbound namespace prefix: \"unbound\"\nLine: 0\nColumn: 28\nChar: >"]
|
|
7
|
-
|
|
8
|
-
, [ "attribute", { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } ]
|
|
9
|
-
, [ "opentag", { name: "root", uri: "", prefix: "", local: "root",
|
|
10
|
-
attributes: { "unbound:attr": { name: "unbound:attr", value: "value", uri: "unbound", prefix: "unbound", local: "attr" } },
|
|
11
|
-
ns: {}, isSelfClosing: true } ]
|
|
12
|
-
, [ "closetag", "root" ]
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
).write("<root unbound:attr='value'/>")
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var xmlns_attr =
|
|
2
|
-
{
|
|
3
|
-
name: "xmlns", value: "http://foo", prefix: "xmlns",
|
|
4
|
-
local: "", uri : "http://www.w3.org/2000/xmlns/"
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
var attr_attr =
|
|
8
|
-
{
|
|
9
|
-
name: "attr", value: "bar", prefix: "",
|
|
10
|
-
local : "attr", uri : ""
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
require(__dirname).test
|
|
15
|
-
( { xml :
|
|
16
|
-
"<elm xmlns='http://foo' attr='bar'/>"
|
|
17
|
-
, expect :
|
|
18
|
-
[ [ "opennamespace", { prefix: "", uri: "http://foo" } ]
|
|
19
|
-
, [ "attribute", xmlns_attr ]
|
|
20
|
-
, [ "attribute", attr_attr ]
|
|
21
|
-
, [ "opentag", { name: "elm", prefix: "", local: "elm", uri : "http://foo",
|
|
22
|
-
ns : { "" : "http://foo" },
|
|
23
|
-
attributes: { xmlns: xmlns_attr, attr: attr_attr },
|
|
24
|
-
isSelfClosing: true } ]
|
|
25
|
-
, [ "closetag", "elm" ]
|
|
26
|
-
, [ "closenamespace", { prefix: "", uri: "http://foo"} ]
|
|
27
|
-
]
|
|
28
|
-
, strict : true
|
|
29
|
-
, opt : {xmlns: true}
|
|
30
|
-
}
|
|
31
|
-
)
|