-
Notifications
You must be signed in to change notification settings - Fork 579
Closed
Description
I'm trying to use prefixes in rdf:datatype attributes, and they appear in turtle serializations but not pretty-xml nor xml. Test code:
import rdflib
CIM_NS = 'http://www.ucaiug.org/profile#'
if __name__ == '__main__':
g = rdflib.Graph()
CIM = rdflib.Namespace (CIM_NS)
g.bind('cim', CIM)
ac = rdflib.URIRef ('placeholderForID')
g.add ((ac, rdflib.RDF.type, rdflib.URIRef (CIM_NS + 'ACLineSegment')))
g.add ((ac, rdflib.URIRef (CIM_NS + 'Equipment.inService'), rdflib.Literal (True, datatype='cim:Boolean')))
g.add ((ac, rdflib.URIRef (CIM_NS + 'Conductor.length'), rdflib.Literal (1.0, datatype=CIM.Length)))
g.add ((ac, rdflib.URIRef (CIM_NS + 'ACLineSegment.r'), rdflib.Literal (1.0)))
g.serialize (destination='test.xml', format='pretty-xml', max_depth=1)
Output test.xml:
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
xmlns:cim="http://www.ucaiug.org/profile#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<cim:ACLineSegment rdf:about="placeholderForID">
<cim:Equipment.inService rdf:datatype="cim:Boolean">true</cim:Equipment.inService>
<cim:Conductor.length rdf:datatype="http://www.ucaiug.org/profile#Length">1.0</cim:Conductor.length>
<cim:ACLineSegment.r rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</cim:ACLineSegment.r>
</cim:ACLineSegment>
</rdf:RDF>
Expected test.xml:
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
xmlns:cim="http://www.ucaiug.org/profile#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
>
<cim:ACLineSegment rdf:about="placeholderForID">
<cim:Equipment.inService rdf:datatype="cim:Boolean">true</cim:Equipment.inService>
<cim:Conductor.length rdf:datatype="cim:Length">1.0</cim:Conductor.length>
<cim:ACLineSegment.r rdf:datatype="xsd:double">1.0</cim:ACLineSegment.r>
</cim:ACLineSegment>
</rdf:RDF>
Metadata
Metadata
Assignees
Labels
No labels