commit 015b37a85e9324943c839c8c1d4aef602a67fc9d
parent 7a83a5762a69ba8bde30826af96edd9c439fdcbb
Author: Simon Kornblith <simon@simonster.com>
Date: Mon, 24 Feb 2014 11:03:53 -0500
Merge pull request #453 from aurimasv/rdflib-rdf-value
Correctly handle literals with attributes in RDF
Diffstat:
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/rdf/rdfparser.js b/chrome/content/zotero/xpcom/rdf/rdfparser.js
@@ -337,6 +337,11 @@ $rdf.RDFParser = function (store) {
if(dom['nodeType'] == RDFParser['nodeType']['TEXT']
|| dom['nodeType'] == RDFParser['nodeType']['CDATA_SECTION']) {
//we have a literal
+ if(frame['parent']['nodeType'] == frame['NODE']) {
+ //must have had attributes, store as rdf:value
+ frame['addArc'](RDFParser['ns']['RDF'] + 'value');
+ frame = this['buildFrame'](frame);
+ }
frame['addLiteral'](dom['nodeValue'])
} else if(elementURI(dom) != RDFParser['ns']['RDF'] + "RDF") {
// not root
diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js
@@ -2639,6 +2639,11 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
*/
"getResourceURI":function(resource) {
if(typeof(resource) == "string") return resource;
+
+ const rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+ var values = this.getTargets(resource, rdf + 'value');
+ if(values && values.length) return this.getResourceURI(values[0]);
+
if(resource.uri) return resource.uri;
if(resource.toNT == undefined) throw new Error("Zotero.RDF: getResourceURI called on invalid resource");
return resource.toNT();