sax 0.4.1 → 0.4.2

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/AUTHORS CHANGED
@@ -7,3 +7,4 @@ Jann Horn <jann@Jann-PC.fritz.box>
7
7
  Elijah Insua <tmpvar@gmail.com>
8
8
  Henry Rawas <henryr@schakra.com>
9
9
  Justin Makeig <jmpublic@makeig.com>
10
+ Mike <mike@emotive.com>
package/lib/sax.js CHANGED
@@ -463,6 +463,8 @@ function openTag (parser, selfClosing) {
463
463
  }
464
464
 
465
465
  // handle deferred onattribute events
466
+ // Note: do not apply default ns to attributes:
467
+ // http://www.w3.org/TR/REC-xml-names/#defaulting
466
468
  for (var i = 0, l = parser.attribList.length; i < l; i ++) {
467
469
  var nv = parser.attribList[i]
468
470
  var name = nv[0]
@@ -470,7 +472,7 @@ function openTag (parser, selfClosing) {
470
472
  , qualName = qname(name)
471
473
  , prefix = qualName.prefix
472
474
  , local = qualName.local
473
- , uri = tag.ns[prefix] || ""
475
+ , uri = prefix == "" ? "" : (tag.ns[prefix] || "")
474
476
  , a = { name: name
475
477
  , value: value
476
478
  , prefix: prefix
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
- { "name" : "sax"
2
- , "description": "An evented streaming XML parser in JavaScript"
3
- , "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"
4
- , "version" : "0.4.1"
5
- , "main" : "lib/sax.js"
6
- , "license" : { "type": "MIT"
7
- , "url": "https://raw.github.com/isaacs/sax-js/master/LICENSE" }
8
- , "scripts" : { "test" : "node test/index.js" }
9
- , "repository": "git://github.com/isaacs/sax-js.git"
1
+ {
2
+ "name": "sax",
3
+ "description": "An evented streaming XML parser in JavaScript",
4
+ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
5
+ "version": "0.4.2",
6
+ "main": "lib/sax.js",
7
+ "license": {
8
+ "type": "MIT",
9
+ "url": "https://raw.github.com/isaacs/sax-js/master/LICENSE"
10
+ },
11
+ "scripts": {
12
+ "test": "node test/index.js"
13
+ },
14
+ "repository": "git://github.com/isaacs/sax-js.git"
10
15
  }
@@ -29,9 +29,9 @@ require(__dirname).test
29
29
  attributes: { "xmlns": { name: "xmlns", value: "uri:default", prefix: "xmlns", local: "", uri: "http://www.w3.org/2000/xmlns/" } },
30
30
  ns: { "": "uri:default" } } ]
31
31
 
32
- , [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "uri:default" } ]
32
+ , [ "attribute", { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } ]
33
33
  , [ "opentag", { name: "plain", prefix: "", local: "plain", uri: "uri:default", ns: { '': 'uri:default' },
34
- attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "uri:default" } } } ]
34
+ attributes: { "attr": { name: "attr", value: "normal", prefix: "", local: "attr", uri: "" } } } ]
35
35
  , [ "closetag", "plain" ]
36
36
 
37
37
  , [ "closetag", "ns1" ]
@@ -0,0 +1,30 @@
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
+ , [ "closetag", "elm" ]
25
+ , [ "closenamespace", { prefix: "", uri: "http://foo"} ]
26
+ ]
27
+ , strict : true
28
+ , opt : {xmlns: true}
29
+ }
30
+ )