I've created a vocab description and use both the XML and Turtle serializations.
TRAK = Namespace('https://purl.org/trak/metamodel/vocab#')
The Turtle one (format='turtle', base = TRAK) is correct starting with (excerpt) :
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix trak: <https://purl.org/trak/metamodel/vocab#> .
@prefix vann: <http://purl.org/vocab/vann/> .
.
trak: a owl:Ontology ;
vann:preferredNamespacePrefix "trak"^^xsd:string ;
vann:preferredNamespaceUri trak: .
having sorted using the otsrdflib package to create a systematic and repeatable order.
The problem occurs with the XML version (format="pretty-xml", base=TRAK). This produces:
<?xml version='1.0' encoding='us-ascii'?>
<rdf:RDF xmlns:ns1="http://www.w3.org/2002/07/owl#" xmlns:ns2="http://purl.org/vocab/vann/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xml:base="https://purl.org/trak/metamodel/vocab#">
<ns1:Ontology rdf:about="">
<ns2:preferredNamespacePrefix rdf:datatype="http://www.w3.org/2001/XMLSchema#string">trak</ns2:preferredNamespacePrefix>
<ns2:preferredNamespaceUri rdf:resource="" />
...
</ns1:Class>
The problem is that the base namespace uri that formed the value for ns2:preferredNamespaceUri has been replaced leaving a null / empty value which isn't equivalent to the base uri.
How do I get around this to produce the equivalent of the Turtle vann:preferredNamespaceUri statement? I can obviously manually correct after output but this doesn't seem like the right approach.
I've created a vocab description and use both the XML and Turtle serializations.
TRAK = Namespace('https://purl.org/trak/metamodel/vocab#')The Turtle one
(format='turtle', base = TRAK)is correct starting with (excerpt) :having sorted using the otsrdflib package to create a systematic and repeatable order.
The problem occurs with the XML version
(format="pretty-xml", base=TRAK). This produces:The problem is that the base namespace uri that formed the value for ns2:preferredNamespaceUri has been replaced leaving a null / empty value which isn't equivalent to the base uri.
How do I get around this to produce the equivalent of the Turtle vann:preferredNamespaceUri statement? I can obviously manually correct after output but this doesn't seem like the right approach.