RDFLib/rdflib — Issue #65: value error when parsing n3
Author: gjhiggins
Created: 2012-02-20 08:31:49+00:00
State: closed

crumpj...@gmail.com, 2009-06-17T21:34:54.000Z

Is this a bug?

>>> from rdflib import ConjunctiveGraph
>>> g = ConjunctiveGraph()
>>> g.parse('/Users/jjc/Desktop/tempANLordsWales.n3', format='n3')

throws a Value error:
ValueError: Found a when expecting a
http://www.w3.org/2000/10/swap/grammar/n3#objecttail .

The puzzling thing is that the parse apparently succeeded, for a subsequent call to
g.serialize(format='n3') returns exactly the graph I expected.

the error and trace:
No handlers could be found for logger "rdflib.Literal"
File "build/bdist.macosx-10.3-i386/egg/rdflib/Graph.py", line 890, in parse
File "build/bdist.macosx-10.3-i386/egg/rdflib/Graph.py", line 713, in parse
File "build/bdist.macosx-10.3-i386/egg/rdflib/syntax/parsers/N3Parser.py", line 32, in parse
File "build/bdist.macosx-10.3-i386/egg/rdflib/syntax/parsers/n3p/n3proc.py", line 119, in parse
File "build/bdist.macosx-10.3-i386/egg/rdflib/syntax/parsers/n3p/n3p.py", line 83, in parse
ValueError: Found a when expecting a http://www.w3.org/2000/10/swap/grammar/n3#objecttail . todoStack=[['http://www.w3.org/2000/10/swap/grammar/n3#document',
['http://www.w3.org/2000/10/swap/grammar/bnf#eof']], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []], ['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', []],
['http://www.w3.org/2000/10/swap/grammar/n3#statements_optional', [u'.', 'http://www.w3.org/2000/10/swap/grammar/n3#statements_optional']],
['http://www.w3.org/2000/10/swap/grammar/n3#statement', []], ['http://www.w3.org/2000/10/swap/grammar/n3#simpleStatement', []],
['http://www.w3.org/2000/10/swap/grammar/n3#propertylist', []], ['http://www.w3.org/2000/10/swap/grammar/n3#propertylisttail', []],
['http://www.w3.org/2000/10/swap/grammar/n3#propertylist', []], ['http://www.w3.org/2000/10/swap/grammar/n3#propertylisttail', []],
['http://www.w3.org/2000/10/swap/grammar/n3#propertylist', []], ['http://www.w3.org/2000/10/swap/grammar/n3#propertylisttail', []],
['http://www.w3.org/2000/10/swap/grammar/n3#propertylist', []], ['http://www.w3.org/2000/10/swap/grammar/n3#propertylisttail', []],
['http://www.w3.org/2000/10/swap/grammar/n3#propertylist', ['http://www.w3.org/2000/10/swap/grammar/n3#propertylisttail']],
['http://www.w3.org/2000/10/swap/grammar/n3#objecttail', []], ['http://www.w3.org/2000/10/swap/grammar/n3#objecttail', []]]

the .n3 file is attached.
cwm has no trouble parsing this file, in spite of its obvious peculiarities

rdflib 2.4.1; Python 2.5.2; MacBook OS X 10.5.5