Comparing version 0.3.5 to 0.4.1
var fs = require("fs"), | ||
sys = require("sys"), | ||
util = require('util'), | ||
path = require("path"), | ||
@@ -10,6 +10,6 @@ xml = fs.cat(path.join(__dirname, "test.xml")), | ||
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); | ||
// util.error(""); | ||
// util.error(ev+": "+util.inspect(data)); | ||
// for (var i in data) util.error(i+ " "+util.inspect(data[i])); | ||
// util.error(this.line+":"+this.column); | ||
}}; | ||
@@ -24,4 +24,4 @@ | ||
loose.onend = function () { | ||
// sys.error("end"); | ||
// sys.error(sys.inspect(loose)); | ||
// util.error("end"); | ||
// util.error(util.inspect(loose)); | ||
}; | ||
@@ -28,0 +28,0 @@ |
@@ -54,3 +54,4 @@ // wrapper for non-node envs | ||
parser.opt = opt || {} | ||
parser.tagCase = parser.opt.lowercasetags ? "toLowerCase" : "toUpperCase" | ||
parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags; | ||
parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase" | ||
parser.tags = [] | ||
@@ -71,3 +72,6 @@ parser.closed = parser.closedRoot = parser.sawRoot = false | ||
// mostly just for error reporting | ||
parser.position = parser.line = parser.column = 0 | ||
parser.trackPosition = parser.opt.position !== false | ||
if (parser.trackPosition) { | ||
parser.position = parser.line = parser.column = 0 | ||
} | ||
emit(parser, "onready") | ||
@@ -139,3 +143,2 @@ } | ||
, close: function () { return this.write(null) } | ||
, end: function () { return this.write(null) } | ||
} | ||
@@ -347,5 +350,7 @@ | ||
closeText(parser) | ||
er += "\nLine: "+parser.line+ | ||
"\nColumn: "+parser.column+ | ||
"\nChar: "+parser.c | ||
if (parser.trackPosition) { | ||
er += "\nLine: "+parser.line+ | ||
"\nColumn: "+parser.column+ | ||
"\nChar: "+parser.c | ||
} | ||
er = new Error(er) | ||
@@ -372,3 +377,3 @@ parser.error = er | ||
function newTag (parser) { | ||
if (!parser.strict) parser.tagName = parser.tagName[parser.tagCase]() | ||
if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]() | ||
var parent = parser.tags[parser.tags.length - 1] || parser | ||
@@ -398,2 +403,3 @@ , tag = parser.tag = { name : parser.tagName, attributes : {} } | ||
function attrib (parser) { | ||
if (!parser.strict) parser.attribName = parser.attribName[parser.looseCase]() | ||
if (parser.opt.xmlns) { | ||
@@ -523,3 +529,3 @@ var qn = qname(parser.attribName) | ||
var tagName = parser.tagName | ||
if (!parser.strict) tagName = tagName[parser.tagCase]() | ||
if (!parser.strict) tagName = tagName[parser.looseCase]() | ||
var closeTo = tagName | ||
@@ -598,7 +604,9 @@ while (t --) { | ||
while (parser.c = c = chunk.charAt(i++)) { | ||
parser.position ++ | ||
if (c === "\n") { | ||
parser.line ++ | ||
parser.column = 0 | ||
} else parser.column ++ | ||
if (parser.trackPosition) { | ||
parser.position ++ | ||
if (c === "\n") { | ||
parser.line ++ | ||
parser.column = 0 | ||
} else parser.column ++ | ||
} | ||
switch (parser.state) { | ||
@@ -622,3 +630,3 @@ | ||
c = chunk.charAt(i++) | ||
if (c) { | ||
if (c && parser.trackPosition) { | ||
parser.position ++ | ||
@@ -625,0 +633,0 @@ if (c === "\n") { |
{ "name" : "sax" | ||
, "description": "An evented streaming XML parser in JavaScript" | ||
, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)" | ||
, "version" : "0.3.5" | ||
, "version" : "0.4.1" | ||
, "main" : "lib/sax.js" | ||
@@ -6,0 +6,0 @@ , "license" : { "type": "MIT" |
@@ -101,5 +101,6 @@ # sax js | ||
space. | ||
* `lowercasetags` - Boolean. If true, then lowercase tags in loose mode, | ||
rather than uppercasing them. | ||
* `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. | ||
* `position` - Boolean. If false, then don't track line/col/position. | ||
@@ -168,3 +169,3 @@ ## Methods | ||
`opentag` - An opening tag. Argument: object with `name` and `attributes`. | ||
In non-strict mode, tag names are uppercased, unless the `lowercasetags` | ||
In non-strict mode, tag names are uppercased, unless the `lowercase` | ||
option is set. If the `xmlns` option is set, then it will contain | ||
@@ -179,4 +180,6 @@ namespace binding information on the `ns` member, and will have a | ||
`attribute` - An attribute node. Argument: object with `name` and `value`, | ||
and also namespace information if the `xmlns` option flag is set. | ||
`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. | ||
@@ -183,0 +186,0 @@ `comment` - A comment node. Argument: the string of the comment. |
@@ -7,6 +7,6 @@ // unquoted attributes should be ok in non-strict mode | ||
, expect : | ||
[ [ "attribute", { name: "class", value: "test" } ] | ||
, [ "attribute", { name: "hello", value: "world" } ] | ||
[ [ "attribute", { name: "CLASS", value: "test" } ] | ||
, [ "attribute", { name: "HELLO", value: "world" } ] | ||
, [ "opentag", { name: "SPAN", | ||
attributes: { class: "test", hello: "world" } } ] | ||
attributes: { CLASS: "test", HELLO: "world" } } ] | ||
, [ "closetag", "SPAN" ] | ||
@@ -13,0 +13,0 @@ ] |
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
438175
44
1884
217
1
36