ericprud / SWObjects

Semantic Web swiss army knife C++ libraries
MIT License
15 stars 4 forks source link

Converting RDX/XML lists to Turtle gives wrong results #4

Closed RubenVerborgh closed 9 years ago

RubenVerborgh commented 9 years ago

Given the file paper.rdf:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:bibo="http://purl.org/ontology/bibo/">
    <rdf:Description rdf:about="#Paper">
        <bibo:authorList rdf:parseType="Collection">
            <rdf:Description><foaf:name>A Von Groll</foaf:name></rdf:Description>
            <rdf:Description><foaf:name>A Martin</foaf:name></rdf:Description>
            <rdf:Description><foaf:name>P Jureen</foaf:name></rdf:Description>
        </bibo:authorList>
    </rdf:Description>
</rdf:RDF>

We get the following incorrect result:

$ sparql -l rdfxml -d paper.rdf -l turtle
<paper.rdf#Paper> <http://purl.org/ontology/bibo/authorList> _:b0x7fe1e8418520 .
_:b0x7fe1e8418520 <http://purl.org/ontology/bibo/authorList> _:b0x7fe1e8416260 .
_:b0x7fe1e8416260 <http://xmlns.com/foaf/0.1/name> "A Von Groll" .
_:b0x7fe1e84185e0 <http://xmlns.com/foaf/0.1/name> "A Martin" .
_:b0x7fe1e8419060 <http://xmlns.com/foaf/0.1/name> "P Jureen" .
<paper.rdf#Paper> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .

Note how all properties are attached to a single blank node, and how the authorList property occurs twice instead of one time. The rdf:rest property is also used incorrectly.

The correct result is:

$ cwm -rdf paper.rdf -n3=pq
    <#Paper>     <http://purl.org/ontology/bibo/authorList>  (
         [ <http://xmlns.com/foaf/0.1/name> "A Von Groll" ]
         [ <http://xmlns.com/foaf/0.1/name> "A Martin" ]
         [ <http://xmlns.com/foaf/0.1/name> "P Jureen" ] ) .
ericprud commented 9 years ago

yeah, that got screwed up a while ago. I need to add the RDF/XML tests. Here's the current output: <paper.rdf#Paper> http://purl.org/ontology/bibo/authorList :b0x1f3d190 . :b0x1f3d190 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/1999/02/22-rdf-syntax-ns#Collection . :b0x1f3d190 http://www.w3.org/1999/02/22-rdf-syntax-ns#first :b0x1f3d610 . :b0x1f3d610 http://xmlns.com/foaf/0.1/name "A Von Groll" . :b0x1f3d190 http://www.w3.org/1999/02/22-rdf-syntax-ns#rest :b0x1f3e3a0 . :b0x1f3e3a0 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/1999/02/22-rdf-syntax-ns#Collection . :b0x1f3e3a0 http://www.w3.org/1999/02/22-rdf-syntax-ns#first :b0x1f3dc30 . :b0x1f3dc30 http://xmlns.com/foaf/0.1/name "A Martin" . :b0x1f3e3a0 http://www.w3.org/1999/02/22-rdf-syntax-ns#rest :b0x1f3e950 . :b0x1f3e950 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/1999/02/22-rdf-syntax-ns#Collection . :b0x1f3e950 http://www.w3.org/1999/02/22-rdf-syntax-ns#first :b0x1f3e7c0 . :b0x1f3e7c0 http://xmlns.com/foaf/0.1/name "P Jureen" . :b0x1f3e950 http://www.w3.org/1999/02/22-rdf-syntax-ns#rest http://www.w3.org/1999/02/22-rdf-syntax-ns#nil .

ericprud commented 9 years ago

Added RDF 1.1 WG RDF/XML tests so this shouldn't happen again. There are two sets of RDF/XML tests, test_RDFXML and test_RdfXml, There should clearly be one, but one uses automatic test declaration ("BOOST_AUTO_TEST_CASE") and the other builds the tests dynamically from TSV files.

RubenVerborgh commented 9 years ago

Great, thanks!