rdfrdf-xml

Are those 2 RDF/XML snippets semantically equivalent?


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>


Solution

  • 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:

    <?xml version="1.0"?>
    <rdf:RDF xml:base="example:base/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cim="example:cim#">
        <cim:Substation rdf:ID="_1234">
            <cim:IdentifiedObject.name>A substation</cim:IdentifiedObject.name>
        </cim:Substation>
    </rdf:RDF>
    

    Output:

    <example:base/#_1234> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <example:cim#Substation> .
    <example:base/#_1234> <example:cim#IdentifiedObject.name> "A substation" .
    

    Input:

    <?xml version="1.0"?>
    <rdf:RDF xml:base="example:base/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cim="example:cim#">
        <rdf:Description rdf:about="_1234">
            <rdf:type rdf:resource="cim:Substation"/>
            <cim:IdentifiedObject.name>A substation</cim:IdentifiedObject.name>
        </rdf:Description>
    </rdf:RDF>
    

    Output:

    <example:base/_1234> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <cim:Substation> .
    <example:base/_1234> <example:cim#IdentifiedObject.name> "A substation" .
    

    There are two differences in these two snippets: