Changelog
3.1.0 (2018-08-28)
name
field (c7dffd5)<a name="3.0.0"></a>
Changelog
3.0.0 (2018-08-21)
xmlns
(as in <foo xmlns="some-uri">
would
be reported as having the prefix "xmlns"
and the local name ""
. This
behavior was inherited from sax. There was some logic to it, but this behavior
was surprising to users of the library. The principle of least surprise favors
eliminating that surprising behavior in favor of something less surprising.This commit makes it so that xmlns
is not reported as having a prefix of ""
and a local name of "xmlns"
. This accords with how people interpret attribute
names like foo
, bar
, moo
which all have no prefix and a local name.
Code that deals with namespace bindings or cares about xmlns
probably needs to
be changed.
<a name="2.2.1"></a>
Changelog
2.1.0 (2018-08-20)
<a name="2.0.0"></a>
Changelog
2.0.0 (2018-07-23)
parser
function, rename SAXParser (0878a6c)strict
argument anywhere. This also
effectively removes support for HTML processing, or allow processing
without errors anything which is less than full XML. It also removes
special processing of script
elements.attribute
is not a particularly useful event for parsing XML. The only thing
it adds over looking at attributes on tag objects is that you get the order of
the attributes from the source, but attribute order in XML is irrelevant.parser
function is removed. Just create a new instance with
new
.SAXParser
is now SaxesParser.
So new require("saxes").SaxesParser(...)
.
The API based on Stream is gone. There were multiple issues with it. It was Node-specific. It used an ancient Node API (the so-called "classic streams"). Its behavior was idiosyncratic.
Sax had no default error handler but if you wanted to continue calling
write()
after an error you had to call resume()
. We do away with
resume()
and instead install a default onerror
which throws. Replace
with a no-op handler if you want to continue after errors.
The "processinginstruction" now produces a "target" field instead of a "name" field. The nomenclature "target" is the one used in the XML literature.
ns
field is no longer using the prototype trick that sax used. The
ns
field of a tag contains only those namespaces that the tag declares.We no longer have opennamespace
and closenamespace
events. The
information they provide can be obtained by examining the tags passed to tag
events.
SGML declaration is not supported by XML. This is an XML parser. So we remove support for SGML declarations. They now cause errors.
We removed support for the code that checked buffer sizes and would
raise errors if a buffer was close to an arbitrary limit or emitted
multiple text
or cdata
events in order avoid passing strings
greater than an arbitrary size. So MAX_BUFFER_LENGTH
is gone.
The feature always seemed a bit awkward. Client code could limit the
size of buffers to 1024K, for instance, and not get a text
event
with a text payload greater than 1024K... so far so good but if the
same document contained a comment with more than 1024K that would
result in an error. Hmm.... why? The distinction seems entirely
arbitrary.
The upshot is that client code needs to be ready to handle strings of any length supported by the platform.
If there's a clear need to reintroduce it, we'll reassess.
script
element. It needs building.The library now assumes a modern runtime. It no longer contains any code to polyfill what's missing. It is up to developers using this code to deal with polyfills as needed.
trim
option. It is up to client code to trip text if
it needs it.normalize
option. It is up to client code
to perform whatever normalization it wants.lowercase
option makes no sense for XML. It is removed.In the process of making this change, we've removed support for the
on...
properties on streams objects. Their existence was not
warranted by any standard API provided by Node. (EventEmitter
does
not have on...
properties for events it supports, nor does
Stream
.) Their existence was also undocumented. And their
functioning was awkward. For instance, with sax, this:
const s = sax.createStream();
const handler = () => console.log("moo");
s.on("cdata", handler);
console.log(s.oncdata === handler);
would print false
. If you examine s.oncdata
you see it is glue
code instead of the handler assigned. This is just bizarre, so we
removed it.