-
Notifications
You must be signed in to change notification settings - Fork 577
Closed
Description
I want to set the public id to be an empty string, so that the ID values on my xml elements will not be amended.
If I run
g = rdflib.Graph()
g.load("foo.xml")
for subj, obj, pred in g:
print(f"El\tSubject:\t{s};\n\tPredicate:\t{p};\n\tObject:\t\t{o};")
where the contents of foo.xml
are:
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by CYME 8.0r02, CYME International T&D on 2017-02-13 7:51:55 PM-->
<rdf:RDF xmlns:cim="http://iec.ch/TC57/2013/CIM-schema-cim16#"
xmlns:cyme="http://www.cyme.com/CIM/1.0.2#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<cim:SwitchInfo rdf:ID="_AB16765A-B19E-4454-A58F-868D23C6CD26">
<cim:IdentifiedObject.name>DEFAULT</cim:IdentifiedObject.name>
<cim:SwitchInfo.ratedVoltage>25000.000000</cim:SwitchInfo.ratedVoltage>
<cim:SwitchInfo.ratedCurrent>100.000000</cim:SwitchInfo.ratedCurrent>
</cim:SwitchInfo>
</rdf:RDF>
I get the following output: all my
scratch.py:24
El Subject: file:///home/anton/Development/profile_validator/test_cim.xml#_AB16765A-B19E-4454-A58F-868D23C6CD26;
Predicate: http://iec.ch/TC57/2013/CIM-schema-cim16#SwitchInfo.ratedVoltage;
Object: 25000.000000;
El Subject: file:///home/anton/Development/profile_validator/test_cim.xml#_AB16765A-B19E-4454-A58F-868D23C6CD26;
Predicate: http://iec.ch/TC57/2013/CIM-schema-cim16#IdentifiedObject.name;
Object: DEFAULT;
El Subject: file:///home/anton/Development/profile_validator/test_cim.xml#_AB16765A-B19E-4454-A58F-868D23C6CD26;
Predicate: http://www.w3.org/1999/02/22-rdf-syntax-ns#type;
Object: http://iec.ch/TC57/2013/CIM-schema-cim16#SwitchInfo;
El Subject: file:///home/anton/Development/profile_validator/test_cim.xml#_AB16765A-B19E-4454-A58F-868D23C6CD26;
Predicate: http://iec.ch/TC57/2013/CIM-schema-cim16#SwitchInfo.ratedCurrent;
Object: 100.000000;
As I expect from what the docs say about how to use Graph.parse
, the base uri of each xml element includes the document file path - since I did not give a value for publicID
it uses the default behaviour for publicID=None
Where I'm finding an issue is that
g = rdflib.Graph()
g.load("foo.xml", publicID="")
for subj, obj, pred in g:
print(f"El\tSubject:\t{s};\n\tPredicate:\t{p};\n\tObject:\t\t{o};")
I get the same output, which to me is unexpected because the value of publicID
is not None
and therefore the base uri should be whatever I gave it.
I'm finding this behaviour in Python 3.6 with RDFLib 4.2.2
Metadata
Metadata
Assignees
Labels
No labels