Skip to content

Commit 07170d8

Browse files
author
Jim Amsden
committed
Parse XMLLiteral object value is XML source, not DOM
When parsing an XMLLiteral object, the value of the object should be normalized XML source, not the parsed XML DOM. This solution serializes the dom childNodes back into source, but doesn’t yet do the normalization. Normalization is required to allow equality to work on XMLLiteral objects.
1 parent 839fac5 commit 07170d8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

rdfparser.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@
250250
return true;
251251
};
252252

253+
var XMLSerializer = require('xmldom').XMLSerializer;
254+
253255
this.parseDOM = function(frame){
254256
// a DOM utility function used in parsing
255257
var rdfid;
@@ -357,7 +359,14 @@
357359
frame.datatype = RDFParser.ns.RDF + "XMLLiteral";// (this.buildFrame(frame)).addLiteral(dom)
358360
// should work but doesn't
359361
frame = this.buildFrame(frame);
360-
frame.addLiteral(dom);
362+
// The property value should be an XML string
363+
// TODO: The DOM should be normalized to support === before serializing
364+
var serializer = new XMLSerializer();
365+
var value='';
366+
for (var c=0; c<dom.childNodes.length; c++) {
367+
value += serializer.serializeToString(dom.childNodes[c]);
368+
}
369+
frame.addLiteral(value);
361370
dig = false;
362371
}
363372
else if (nv === "Resource"){

0 commit comments

Comments
 (0)