Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDFLib will accept broken RDF/XML #363

Closed
gromgull opened this issue Mar 1, 2014 · 6 comments
Closed

RDFLib will accept broken RDF/XML #363

gromgull opened this issue Mar 1, 2014 · 6 comments
Labels
bug Something isn't working parsing Related to a parsing.

Comments

@gromgull
Copy link
Member

gromgull commented Mar 1, 2014

This RDF/XML is invalid and should raise an exception:

import rdflib

data='''<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:http="http://www.w3.org/2011/http#">

    <http:HeaderElement rdf:about="#he0">
        <http:params>
            <http:Parameter rdf:about="#param0_0" />
            <http:Parameter rdf:about="#param0_1" />
        </http:params>
    </http:HeaderElement>

</rdf:RDF>
'''

g = rdflib.Graph().parse(data=data)

print g.serialize(format='n3')
@gromgull
Copy link
Member Author

gromgull commented Mar 2, 2014

Not so fast :)

@joernhees
Copy link
Member

This currently breaks master... the test fails here:

   <rdf:Description about="http://meetings.example.com/cal#m1">
        <Location parseType="Resource">
            <zip xmlns="http://www.another.example.org/geographical#">02139</zip>
            <lat xmlns="http://www.another.example.org/geographical#">14.124425</lat>
            <long xmlns="http://www.another.example.org/geographical#">14.245</long>
        </Location>
        <chair resource="http://www.example.org/people#fred"/>
        <homePage resource="http://meetings.example.com/m1/hp"/>
    </rdf:Description>

who doesn't love rdf+xml: http://www.w3.org/TR/2014/REC-rdf-syntax-grammar-20140225/#section-Syntax-parsetype-resource

@gromgull
Copy link
Member Author

gromgull commented Mar 3, 2014

Oh dear - It's not just that my hacky attempt at raising an exception wasn't working, but our parseType=Resource parsing is completely broken.

If I reduce down the example to this:

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="http://www.example.org/meeting_organization#">

    <rdf:Description about="http://meetings.example.com/cal#m1">
        <Location parseType="Resource">
            <zip xmlns="http://www.another.example.org/geographical#">02139</zip>
            <lat xmlns="http://www.another.example.org/geographical#">14.124425</lat>
        </Location>
    </rdf:Description>
</rdf:RDF>

And parse it without my exception raising code, I get:

@prefix : <http://www.example.org/meeting_organization#> .
@prefix default1: <http://www.another.example.org/geographical#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

[] <parseType> "Resource" .

[] a default1:zip .

[] <about> "http://meetings.example.com/cal#m1" ;
    :Location [ a default1:lat ] .

which is complete gobblygook. AFAIK the rdf/xml code hasn't been touched for a long time, and it may have been broken forever. I'll investigate.

@gromgull
Copy link
Member Author

gromgull commented Mar 3, 2014

So at first I started going back in rdflib history, and this was broken all the way back to version 2.0.6 - the earliest tagged version we have :)

BUT, as I start looking into the rdfxml parser, I realise that it's not the parsed that is broken, it's the example. The parseType here needs to be in the rdf namespace:

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="http://www.example.org/meeting_organization#">

    <rdf:Description about="http://meetings.example.com/cal#m1">
        <Location rdf:parseType="Resource">
            <zip xmlns="http://www.another.example.org/geographical#">02139</zip>
            <lat xmlns="http://www.another.example.org/geographical#">14.124425</lat>
        </Location>
    </rdf:Description>
</rdf:RDF>

That XML parses fine, and no exception is raised.

:)

@joernhees
Copy link
Member

phew ;)

the thing is: build still breaks.

@joernhees joernhees reopened this Mar 3, 2014
@joernhees
Copy link
Member

ah, i think you just forgot to restore https://github.com/RDFLib/rdflib/edit/master/test/test_issue363.py to something which works...

should we report upstream that http://www.w3.org/2000/10/swap/test/meet/white.rdf is broken?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parsing Related to a parsing.
Projects
None yet
Development

No branches or pull requests

2 participants