diff --git a/rdflib/plugins/parsers/notation3.py b/rdflib/plugins/parsers/notation3.py index ac1775b95..23c3a3c12 100644 --- a/rdflib/plugins/parsers/notation3.py +++ b/rdflib/plugins/parsers/notation3.py @@ -479,9 +479,13 @@ def directiveOrStatement(self, argstr, h): # @@I18N # _namechars = string.lowercase + string.uppercase + string.digits + '_-' - def tok(self, tok, argstr, i): + def tok(self, tok, argstr, i, colon=False): """Check for keyword. Space must have been stripped on entry and - we must not be at end of file.""" + we must not be at end of file. + + if colon, then keyword followed by colon is ok + (@prefix: is ok, rdf:type shortcut a must be followed by ws) + """ assert tok[0] not in _notNameChars # not for punctuation if argstr[i:i + 1] == "@": @@ -491,7 +495,8 @@ def tok(self, tok, argstr, i): return -1 # No, this has neither keywords declaration nor "@" if (argstr[i:i + len(tok)] == tok - and (argstr[i + len(tok)] in _notKeywordsChars)): + and ( argstr[i + len(tok)] in _notKeywordsChars) + or (colon and argstr[i+len(tok)] == ':')): i = i + len(tok) return i else: @@ -564,7 +569,7 @@ def directive(self, argstr, i): self._context.declareExistential(x) return i - j = self.tok('prefix', argstr, i) # no implied "#" + j = self.tok('prefix', argstr, i, colon=True) # no implied "#" if j >= 0: t = [] i = self.qname(argstr, j, t) @@ -1326,6 +1331,12 @@ def qname(self, argstr, i, res): if i < len(argstr) and argstr[i] == ':': pfx = ln + # bnodes names have different rules + if pfx == '_': + allowedChars = _notNameChars + else: + allowedChars = _notQNameChars + i = i + 1 lastslash = False # start = i # TODO first char . @@ -1336,7 +1347,7 @@ def qname(self, argstr, i, res): lastslash = True i += 1 - elif lastslash or c not in _notQNameChars: + elif lastslash or c not in allowedChars: if lastslash: if c not in escapeChars: @@ -1413,7 +1424,6 @@ def nodeOrLiteral(self, argstr, i, res): ch = argstr[i] if ch in "-+0987654321.": - #import ipdb; ipdb.set_trace() m = exponent_syntax.match(argstr, i) if m: j = m.end() diff --git a/test/test_trig_w3c.py b/test/test_trig_w3c.py index f41afdd24..aed425e01 100644 --- a/test/test_trig_w3c.py +++ b/test/test_trig_w3c.py @@ -23,8 +23,6 @@ def trig(test): } def test_trig(): - from nose import SkipTest - raise SkipTest() for t in nose_tests(testers, 'test/w3c/trig/manifest.ttl'): yield t