Skip to content

Commit

Permalink
Merge pull request #470 from joernhees/rdf_xml_rdf_default_namespace
Browse files Browse the repository at this point in the history
fixes #468 RDF/XML problem with unqualified use of rdf:about
  • Loading branch information
joernhees committed Mar 7, 2015
2 parents cc6a656 + 56a851b commit 7d26d92
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
27 changes: 21 additions & 6 deletions rdflib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""\
A pure Python package providing the core RDF constructs.
"""A pure Python package providing the core RDF constructs.
The packages is intended to provide the core RDF types and interfaces
for working with RDF. The package defines a plugin interface for
Expand All @@ -12,19 +11,35 @@
A tiny example:
>>> import rdflib
>>> from rdflib import Graph, URIRef, Literal
>>> g = rdflib.Graph()
>>> g = Graph()
>>> result = g.parse("http://www.w3.org/2000/10/swap/test/meet/blue.rdf")
>>> print("graph has %s statements." % len(g))
graph has 9 statements.
graph has 4 statements.
>>>
>>> for s, p, o in g:
... if (s, p, o) not in g:
... raise Exception("It better be!")
>>> s = g.serialize(format='n3')
>>> s = g.serialize(format='nt')
>>>
>>> sorted(g) == [
... (URIRef(u'http://meetings.example.com/cal#m1'),
... URIRef(u'http://www.example.org/meeting_organization#homePage'),
... URIRef(u'http://meetings.example.com/m1/hp')),
... (URIRef(u'http://www.example.org/people#fred'),
... URIRef(u'http://www.example.org/meeting_organization#attending'),
... URIRef(u'http://meetings.example.com/cal#m1')),
... (URIRef(u'http://www.example.org/people#fred'),
... URIRef(u'http://www.example.org/personal_details#GivenName'),
... Literal(u'Fred')),
... (URIRef(u'http://www.example.org/people#fred'),
... URIRef(u'http://www.example.org/personal_details#hasEmail'),
... URIRef(u'mailto:fred@example.com'))
... ]
True
"""
__docformat__ = "restructuredtext en"
Expand Down
6 changes: 3 additions & 3 deletions rdflib/plugins/parsers/rdfxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
RDFNS = RDF

# http://www.w3.org/TR/rdf-syntax-grammar/#eventterm-attribute-URI
# A mapping from unqualified terms to there qualified version.
# A mapping from unqualified terms to their qualified version.
UNQUALIFIED = {"about": RDF.about,
"ID": RDF.ID,
"type": RDF.type,
Expand Down Expand Up @@ -216,9 +216,9 @@ def convert(self, name, qname, attrs):
atts = {}
for (n, v) in attrs.items(): # attrs._attrs.iteritems(): #
if n[0] is None:
att = URIRef(n[1])
att = n[1]
else:
att = URIRef("".join(n))
att = "".join(n)
if att.startswith(XMLNS) or att[0:3].lower() == "xml":
pass
elif att in UNQUALIFIED:
Expand Down

0 comments on commit 7d26d92

Please sign in to comment.