You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know how one should fix this. The problem is with the function TriXSerializer.serialize or the function XMLWriter.namespaces. TriXSerializer.serialize could remove the namespace with the empty prefix or XMLWriter.namespaces could give precedence to the namespaces in extra_ns over those in namespace.
The text was updated successfully, but these errors were encountered:
++ TriXSerializer.serialize could remove the namespace with the empty prefix
++ or XMLWriter.namespaces could give precedence to the namespaces in
++ extra_ns over those in namespace
I tip my hat to you for pointing out the alternative. The latter is a clear winner under the principle of "least surprise". It's a bit unfortunate that the regrettably vague "extra_ns" doesn't signal the precedence, rather the opposite. However, a very straightforward guard and a comment at least renders the semantics explicit in the codebase and AFAICT, XMLWriter isn't part of the published API
I am still suspecting an issue though: After inspecting your commit I don't think it works as I imagined it. You wrote
for prefix, namespace in namespaces:
if prefix:
write(' xmlns:%s="%s"\n' % (prefix, namespace))
# Allow user-provided namespace bindings to prevail
elif prefix not in self.extra_ns:
write(' xmlns="%s"\n' % namespace)
Like this, namespaces with a prefix are written in any case. You only check for the empty prefix whether it is already in extra_ns. Maybe you intended the following, which never writes a namespace from extra_ns?
for prefix, namespace in namespaces:
# Allow user-provided namespace bindings to prevail
if prefix not in self.extra_ns:
if prefix:
write(' xmlns:%s="%s"\n' % (prefix, namespace))
else:
write(' xmlns="%s"\n' % namespace)
When I have a ConjunctiveGraph with the default namespace set, for example
then the Trix serializer binds the default namespace twice in its XML output, once for the Trix namespace and once for the namespace I used:
I don't know how one should fix this. The problem is with the function
TriXSerializer.serialize
or the functionXMLWriter.namespaces
.TriXSerializer.serialize
could remove the namespace with the empty prefix orXMLWriter.namespaces
could give precedence to the namespaces inextra_ns
over those innamespace
.The text was updated successfully, but these errors were encountered: