Comparing version 3.1.0 to 4.0.0
@@ -1,11 +0,24 @@ | ||
# 3.1.0 | ||
# Changelog | ||
All notable changes to [saxen](https://github.com/nikku/saxen) are documented here. We use [semantic versioning](http://semver.org/) for releases. | ||
## Unreleased | ||
___Note:__ Yet to be released changes appear here._ | ||
## 4.0.0 | ||
* `FEAT`: fully support anonymous elements in namespace mode [`2f48744a`](https://github.com/nikku/saxen/commit/2f48744a077ec096a411d60f3f948903fa53bfc2) | ||
* `FEAT`: emit <warn> for all attribute parse issues [`a5014b25`](https://github.com/nikku/saxen/commit/a5014b257cc4635d55daa2df9d38ce6e3b0da13d) | ||
## 3.1.0 | ||
* `FEAT`: keep non-decodeable entities _as is_ | ||
* `FEAT`: decode only [required sub-set](https://www.w3.org/TR/REC-xml/#sec-predefined-ent) of named entities | ||
# 3.0.1 | ||
## 3.0.1 | ||
* `CHORE`: add license field to `package.json` | ||
# 3.0.0 | ||
## 3.0.0 | ||
@@ -17,3 +30,3 @@ * `FEAT`: throw on handler errors [`4b0ebb1`](https://github.com/nikku/saxen/commit/4b0ebb12edb6f98064f33f555d519f58a8ec3a63) | ||
# 2.0.0 | ||
## 2.0.0 | ||
@@ -26,7 +39,7 @@ * `FEAT`: rename events | ||
# 1.1.0 | ||
## 1.1.0 | ||
* `FEAT`: handle non-xml input | ||
# 1.0.4 | ||
## 1.0.4 | ||
@@ -36,15 +49,15 @@ * `DOCS`: better `@type` annotations | ||
# 1.0.3 | ||
## 1.0.3 | ||
* `DOCS`: correct `@type` and `@return` annotations in parser | ||
# 1.0.2 | ||
## 1.0.2 | ||
* `FIX`: properly handle namespace prefix collisions [#1](https://github.com/nikku/saxen/issues/1) | ||
# 1.0.1 | ||
## 1.0.1 | ||
* `CHORE`: improve test coverage and documentation | ||
# 1.0.0 | ||
## 1.0.0 | ||
@@ -63,4 +76,4 @@ * `FEAT`: don't skip unknown namespace nodes | ||
# ... | ||
## ... | ||
Check `git log` for earlier history. |
@@ -16,3 +16,3 @@ { | ||
], | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"main": "./parser.js", | ||
@@ -19,0 +19,0 @@ "bugs": { |
@@ -27,4 +27,4 @@ 'use strict'; | ||
function unmappedPrefix(prefix) { | ||
return 'unmapped prefix <' + prefix + '>'; | ||
function missingNamespaceForPrefix(prefix) { | ||
return 'missing namespace for prefix <' + prefix + '>'; | ||
} | ||
@@ -314,4 +314,2 @@ | ||
xmlns, | ||
xmlnsStack = isNamespace ? [] : null, | ||
_xmlns, | ||
elementName, | ||
@@ -369,3 +367,4 @@ _elementName, | ||
if (w !== 95 && w !== 58) { // char 95"_" 58":" | ||
return cachedAttrs = false; // error. invalid first char | ||
handleWarning('illegal first char attribute name'); | ||
return cachedAttrs = false; | ||
} | ||
@@ -383,3 +382,5 @@ } | ||
if (w !== 61) { // "=" == 61 | ||
return cachedAttrs = false; // error. invalid char "=" | ||
// expected "=" | ||
handleWarning('missing attribute value'); | ||
return cachedAttrs = false; | ||
} | ||
@@ -394,2 +395,3 @@ | ||
if (name === 'xmlns:xmlns') { | ||
handleWarning('illegal declaration of xmlns'); | ||
return cachedAttrs = false; // error. invalid name | ||
@@ -405,2 +407,3 @@ } | ||
if (w !== 39) { // "'" | ||
handleWarning('missing attribute value quotes'); | ||
return cachedAttrs = false; // error. invalid char | ||
@@ -413,2 +416,3 @@ } | ||
if (j === -1) { | ||
handleWarning('attribute value quote missmatch'); | ||
return cachedAttrs = false; // error. invalid char | ||
@@ -422,2 +426,3 @@ } | ||
// error. invalid char | ||
handleWarning('illegal character after attribute end'); | ||
return cachedAttrs = false; | ||
@@ -509,3 +514,3 @@ } | ||
if (!(nsName = nsMatrix[name.substring(0, w)])) { | ||
handleWarning(unmappedPrefix(name.substring(0, w))); | ||
handleWarning(missingNamespaceForPrefix(name.substring(0, w))); | ||
continue; | ||
@@ -557,3 +562,3 @@ } | ||
if (!(nsName = nsMatrix[name.substring(0, w)])) { | ||
handleWarning(unmappedPrefix(name.substring(0, w))); | ||
handleWarning(missingNamespaceForPrefix(name.substring(0, w))); | ||
continue; | ||
@@ -838,3 +843,2 @@ } | ||
_nsMatrix = nsMatrix; | ||
_xmlns = xmlns; | ||
@@ -846,3 +850,2 @@ if (tagStart) { | ||
nsMatrixStack.push(_nsMatrix); | ||
xmlnsStack.push(xmlns); | ||
} | ||
@@ -870,2 +873,8 @@ | ||
xmlns = nsMatrix[elementName.substring(0, w)]; | ||
// prefix given; namespace must exist | ||
if (!xmlns) { | ||
return handleError('missing namespace on <' + _elementName + '>'); | ||
} | ||
elementName = elementName.substr(w + 1); | ||
@@ -875,14 +884,15 @@ } else { | ||
if (!xmlns && _xmlns) { | ||
// if no default xmlns is defined, | ||
// inherit xmlns from parent | ||
xmlns = _xmlns; | ||
} | ||
// if no default namespace is defined, | ||
// we'll import the element as anonymous. | ||
// | ||
// it is up to users to correct that to the document defined | ||
// targetNamespace, or whatever their undersanding of the | ||
// XML spec mandates. | ||
} | ||
if (!xmlns) { | ||
return handleError('missing namespace on <' + _elementName + '>'); | ||
// adjust namespace prefixs as configured | ||
if (xmlns) { | ||
elementName = xmlns + ':' + elementName; | ||
} | ||
elementName = xmlns + ':' + elementName; | ||
} | ||
@@ -918,6 +928,4 @@ | ||
nsMatrix = nsMatrixStack.pop(); | ||
xmlns = xmlnsStack.pop(); | ||
} else { | ||
nsMatrix = _nsMatrix; | ||
xmlns = _xmlns; | ||
} | ||
@@ -924,0 +932,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27188
732