I am experimenting with converting RDF to another format (JSON-LD in this case, via RDFLib) and back to RDF. The resulting RDF is a tad different from the original, and although as a human both kinda make sense, I do wonder if they are actually semantically exactly the same.
Are the 2 following snippets interchangeable in RDF?
Original:
<cim:Substation rdf:ID="_1234">
<cim:IdentifiedObject.name>A substation</cim:IdentifiedObject.name>
</cim:Substation>
The back and forth converted snippet:
<rdf:Description rdf:about="_1234">
<rdf:type rdf:resource="cim:Substation"/>
<cim:IdentifiedObject.name>A substation</cim:IdentifiedObject.name>
</rdf:Description>
No, these two snippets are definitely not equivalent. This can be verified by using a converter (such as this one), and choosing a more basic RDF serialization format, such as N-Triples.
Input:
Output:
Input:
Output:
There are two differences in these two snippets:
rdf:ID="name"is (more or less) an abbreviation ofrdf:about="#name"(notice the#). If you care about the document using stable URIs for its resources, usingrdf:about="name"will produce different URIs, as you can see from the N-Triples output ‒ one hasexample:base/#_1234and the other hasexample:base/_1234. The only situation where this might be equivalent is if the parser/formatter chose a different XML base for the second snippet (e.g.example:base#as opposed toexample:base), and interpreted the absolute URI formation ofexample:base#+_1234asexample:base#_1234, which is nevertheless incorrect, asexample:base#+_1234isexample:_1234.cim:Substationas an XML element name is not resolved in the same way as the value ofrdf:resource. In the former case, the XML namespace is used and concatenated with the element's local name (resulting inexample:cim#Substation), while in the latter case, it is simply treated as a plain URI. This would be equivalent only if the prefixcim:is supposed to denote the namespacecim:(i.e. havingxmlns:cim="cim:"in the original snippet) which it might not.