walidazizi / rdflib

Automatically exported from code.google.com/p/rdflib
Other
0 stars 0 forks source link

Possibly bogus rdflib.plugins.parsers.notation3.BadSyntax #190

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Running the attached example gives:

$ python test.py 
3.1.0
# next char:  u'}'
Traceback (most recent call last):
  File "test.py", line 25, in <module>
    graph.parse(StringInputSource(prefix + '<%s>' % url + meta), format='n3')
  File "/home/nikratio/.local/lib/python2.6/site-packages/rdflib/graph.py", line 984, in parse
    location=location, file=file, data=data, **args)
  File "/home/nikratio/.local/lib/python2.6/site-packages/rdflib/graph.py", line 780, in parse
    parser.parse(source, self, **args)
  File "/home/nikratio/.local/lib/python2.6/site-packages/rdflib/plugins/parsers/notation3.py", line 2257, in parse
    p.loadStream(source.getByteStream())
  File "/home/nikratio/.local/lib/python2.6/site-packages/rdflib/plugins/parsers/notation3.py", line 892, in loadStream
    return self.loadBuf(stream.read())   # Not ideal
  File "/home/nikratio/.local/lib/python2.6/site-packages/rdflib/plugins/parsers/notation3.py", line 898, in loadBuf
    self.feed(buf)
  File "/home/nikratio/.local/lib/python2.6/site-packages/rdflib/plugins/parsers/notation3.py", line 928, in feed
    "expected directive or statement")
rdflib.plugins.parsers.notation3.BadSyntax: at line 21 of <>:
Bad syntax (expected directive or statement) at ^ in:
"... 0000 6\nWICHTIGES DOKUMENT - SORGFÄLTIG AUFBEWAHREN!\n " .^
} } WHERE { {
?tag1 a nao:Tag ; nao:prefLabel "()" .
"

The data was generated by tracker (www.gnome.org/projects/tracker/). Personally 
I don't know much about RDF, so it's quite possible that the input is truly 
malformed. If that's the case, please let me know so that I can file a tracker 
bug instead.

Original issue reported on code.google.com by Nikolaus@rath.org on 14 Sep 2011 at 1:57

Attachments:

GoogleCodeExporter commented 8 years ago
The origin of this is currently under review but in the interim, a workaround 
(maybe even a fix) is to escape the newline characters:

"Betriebsnummer der Einzugsstelle:\\nKnappschaft\\n980 0000 6\\nWICHTIGES 
DOKUMENT - SORGFÄLTIG AUFBEWAHREN!\\n "

This will result in a successful parsing.

Original comment by gjhigg...@gmail.com on 24 Oct 2011 at 3:45