sparqlxml-parse
Advanced tools
Comparing version 1.1.0 to 1.1.1
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
<a name="1.1.1"></a> | ||
## [1.1.0](https://github.com/rubensworks/sparqlxml-parse.js/compare/v1.1.0...v1.1.1) - 2018-08-24 | ||
- [Check edge-cases for empty bindings and results](https://github.com/rubensworks/sparqlxml-parse.js/commit/031c30c93e6e2e3a56b1dd2cb47013a30344998e) | ||
- [Fix parsing error on single bindings](https://github.com/rubensworks/sparqlxml-parse.js/commit/79b5a5bcad0abd8080b3900e84ab4e956ad13940) | ||
- [Catch SPARQL XML errors](https://github.com/rubensworks/sparqlxml-parse.js/commit/74787ade801564b2aaf09c50720478aa6c6b3dc3) | ||
<a name="1.1.0"></a> | ||
## [1.1.0] - 2018-08-23 | ||
## [1.1.0](https://github.com/rubensworks/sparqlxml-parse.js/compare/v1.0.0...v1.1.0) - 2018-08-23 | ||
- [Update to pure-js sax-stream XML parser](https://github.com/rubensworks/sparqlxml-parse.js/commit/c231ff4045c8c0fddaa5c95f594dc801ee5e1cae) | ||
@@ -7,0 +13,0 @@ |
@@ -13,3 +13,10 @@ "use strict"; | ||
_transform(chunk, encoding, callback) { | ||
callback(null, this.parser.parseXmlBindings(chunk)); | ||
let bindings; | ||
try { | ||
bindings = this.parser.parseXmlBindings(chunk); | ||
} | ||
catch (e) { | ||
return callback(e); | ||
} | ||
callback(null, bindings); | ||
} | ||
@@ -16,0 +23,0 @@ } |
@@ -50,23 +50,29 @@ "use strict"; | ||
const bindings = {}; | ||
for (const binding of rawBindings.children.binding) { | ||
const key = binding.attribs.name; | ||
let value = null; | ||
if (binding.children.bnode) { | ||
value = this.dataFactory.blankNode(binding.children.bnode.value); | ||
} | ||
else if (binding.children.literal) { | ||
if (binding.children.literal.attribs && binding.children.literal.attribs['xml:lang']) { | ||
value = this.dataFactory.literal(binding.children.literal.value, binding.children.literal.attribs['xml:lang']); | ||
if (rawBindings.children) { | ||
const bindingsArray = Array.isArray(rawBindings.children.binding) | ||
? rawBindings.children.binding : [rawBindings.children.binding]; | ||
for (const binding of bindingsArray) { | ||
if (binding.attribs) { | ||
const key = binding.attribs.name; | ||
let value = null; | ||
if (binding.children.bnode) { | ||
value = this.dataFactory.blankNode(binding.children.bnode.value); | ||
} | ||
else if (binding.children.literal) { | ||
if (binding.children.literal.attribs && binding.children.literal.attribs['xml:lang']) { | ||
value = this.dataFactory.literal(binding.children.literal.value, binding.children.literal.attribs['xml:lang']); | ||
} | ||
else if (binding.children.literal.attribs && binding.children.literal.attribs.datatype) { | ||
value = this.dataFactory.literal(binding.children.literal.value, this.dataFactory.namedNode(binding.children.literal.attribs.datatype)); | ||
} | ||
else { | ||
value = this.dataFactory.literal(binding.children.literal.value); | ||
} | ||
} | ||
else { | ||
value = this.dataFactory.namedNode(binding.children.uri.value); | ||
} | ||
bindings[this.prefixVariableQuestionMark ? ('?' + key) : key] = value; | ||
} | ||
else if (binding.children.literal.attribs && binding.children.literal.attribs.datatype) { | ||
value = this.dataFactory.literal(binding.children.literal.value, this.dataFactory.namedNode(binding.children.literal.attribs.datatype)); | ||
} | ||
else { | ||
value = this.dataFactory.literal(binding.children.literal.value); | ||
} | ||
} | ||
else { | ||
value = this.dataFactory.namedNode(binding.children.uri.value); | ||
} | ||
bindings[this.prefixVariableQuestionMark ? ('?' + key) : key] = value; | ||
} | ||
@@ -73,0 +79,0 @@ return bindings; |
{ | ||
"name": "sparqlxml-parse", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Parses SPARQL XML query results", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
"tslint-eslint-rules": "^5.3.1", | ||
"typescript": "^2.6.2" | ||
"typescript": "^3.0.1" | ||
}, | ||
@@ -48,0 +48,0 @@ "jest": { |
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
16477
191