The checkIntegrity() will always throw an error because of the invalid initiation. solidNs() can have multiple prefixes for the same uri breaking the integrity.
|
const nsKeys = Object.keys(solidNs()) |
|
for (const i in nsKeys) { |
|
const uri = solidNs()[nsKeys[i]]('') |
|
const prefix = nsKeys[i] |
|
this.prefixes[uri] = prefix |
|
this.namespaces[prefix] = uri |
|
} |
Currently it will always have the last prefix for a specific uri in the prefixes object, and all variants in the namespaces object. However, when serializing only the prefixes object is used to convert uri to prefixes, so the other variants in the namespaces object will never be touched.
To solve it I think suggestPrefix should be used, this will make sure the integrity is kept, and instead of using the last prefix of the solidNs() it will use the first one.
The setPrefix should, then also delete the old value in the namespace object to keep the integrity, this does not effect the functionality of the serializer, it only may make it a bit slower
|
// remove any existing prefix targeting this uri |
|
// for (let existingPrefix in this.namespaces) { |
|
// if (this.namespaces[existingPrefix] == uri) |
|
// delete this.namespaces[existingPrefix]; |
|
// } |
I will make this change in fase-3 of my refactor of the serializer #740
The
checkIntegrity()will always throw an error because of the invalid initiation.solidNs()can have multiple prefixes for the same uri breaking the integrity.rdflib.js/src/serializer.js
Lines 27 to 33 in 1b386c4
Currently it will always have the last prefix for a specific uri in the
prefixesobject, and all variants in thenamespacesobject. However, when serializing only theprefixesobject is used to convert uri to prefixes, so the other variants in thenamespacesobject will never be touched.To solve it I think
suggestPrefixshould be used, this will make sure the integrity is kept, and instead of using the last prefix of the solidNs() it will use the first one.The
setPrefixshould, then also delete the old value in thenamespaceobject to keep the integrity, this does not effect the functionality of the serializer, it only may make it a bit slowerrdflib.js/src/serializer.js
Lines 104 to 108 in 1b386c4
I will make this change in fase-3 of my refactor of the serializer #740