Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated addLiteral to properly support XMLLiteral #133

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions dist/rdflib-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,18 @@ $rdf.RDFParser = function (store) {
this.addSymbol(this.ARC, uri)
}, /** Add a literal to this frame */'addLiteral': function (value) {
if (this.parent.datatype) {
this.node = this.store.literal(value, '', this.store.sym(this.parent.datatype))
if (this.parent.datatype === RDFParser.ns.RDF + 'XMLLiteral' ) {
// The property value should be an XML string
// TODO: The DOM should be normalized to support === before serializing
var serializer = new XMLSerializer()
var lit=''
for (var c=0; c<value.childNodes.length; c++) {
lit += serializer.serializeToString(value.childNodes[c])
}
this.node = this.store.literal(lit, "", this.store.sym(this.parent.datatype))
} else {
this.node = this.store.literal(value, "", this.store.sym(this.parent.datatype))
}
} else {
this.node = this.store.literal(value, this.lang)
}
Expand All @@ -1983,6 +1994,8 @@ $rdf.RDFParser = function (store) {
}
}

var XMLSerializer = require('xmldom').XMLSerializer

// from the OpenLayers source .. needed to get around IE problems.
this.getAttributeNodeNS = function (node, uri, name) {
var attributeNode = null
Expand Down Expand Up @@ -11104,5 +11117,5 @@ if (typeof exports !== 'undefined') {
// Leak a global regardless of module system
root['$rdf'] = $rdf
}
$rdf.buildTime = "2016-06-01T15:36:17";
$rdf.buildTime = "2016-07-18T16:58:31";
})(this);
Loading