summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörn Hees <joernhees@users.noreply.github.com>2015-03-07 14:37:21 +0100
committerJörn Hees <joernhees@users.noreply.github.com>2015-03-07 14:37:21 +0100
commit7d26d92f747e8f71bab4f9d0f501e36406082708 (patch)
tree875dd05aba0bf39fd9dde3aa41cbabb6c9b5619d
parentcc6a656aee634de482f0a7e554a4212cd82dd054 (diff)
parent56a851b677dfe7011a2345dd311f33fbe7a29687 (diff)
downloadrdflib-7d26d92f747e8f71bab4f9d0f501e36406082708.tar.gz
Merge pull request #470 from joernhees/rdf_xml_rdf_default_namespace
fixes #468 RDF/XML problem with unqualified use of rdf:about
-rw-r--r--rdflib/__init__.py27
-rw-r--r--rdflib/plugins/parsers/rdfxml.py6
2 files changed, 24 insertions, 9 deletions
diff --git a/rdflib/__init__.py b/rdflib/__init__.py
index 245930b2..2627b5ed 100644
--- a/rdflib/__init__.py
+++ b/rdflib/__init__.py
@@ -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
@@ -12,19 +11,35 @@ The primary interface `rdflib` exposes to work with RDF is
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"
diff --git a/rdflib/plugins/parsers/rdfxml.py b/rdflib/plugins/parsers/rdfxml.py
index 33df73de..43762b81 100644
--- a/rdflib/plugins/parsers/rdfxml.py
+++ b/rdflib/plugins/parsers/rdfxml.py
@@ -20,7 +20,7 @@ __all__ = ['create_parser', 'BagID', 'ElementHandler',
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,
@@ -216,9 +216,9 @@ class RDFXMLHandler(handler.ContentHandler):
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: