proycon / foliatools

A number of command-line tools for working with FoLiA (Format for Linguistic Annotation). Includes validators, converters, visualisers, and more.
GNU General Public License v3.0
10 stars 4 forks source link

foliavalidator: PluginException #31

Closed pirolen closed 3 years ago

pirolen commented 3 years ago

How could I solve this error? (Noticed when trying to upload to FLAT)

$ foliavalidator myfile.folia.xml Validated successfully

$ foliavalidator --deep myfile.folia.xml PluginException: No plugin registered for (rdf, <class 'rdflib.parser.Parser'>)

pirolen commented 3 years ago

Full FLAT error message:

Uploaded file is no valid FoLiA Document: No plugin registered for (rdf, )Traceback (most recent call last): -- File "/home/flatuser/flateditor/env/lib/python3.7/site-packages/rdflib/plugin.py", line 103, in get -- p = _plugins[(name, kind)] -- KeyError: ('rdf', ) -- -- During handling of the above exception, another exception occurred: -- -- Traceback (most recent call last): -- File "/home/flatuser/flateditor/env/lib/python3.7/site-packages/foliadocserve/foliadocserve.py", line 940, in upload -- doc = folia.Document(string=data,setdefinitions=self.docstore.setdefinitions, loadsetdefinitions=True, autodeclare=True, allowadhocsets=True, processor=mainprocessor) -- File "/home/flatuser/flateditor/env/lib/python3.7/site-packages/folia/main.py", line 7216, in init -- self.parsexml(self.tree.getroot()) -- File "/home/flatuser/flateditor/env/lib/python3.7/site-packages/folia/main.py", line 8423, in parsexml -- self.parsemetadata(subnode) -- File "/home/flatuser/flateditor/env/lib/python3.7/site-packages/folia/main.py", line 8301, in parsemetadata -- self.parsexmldeclarations(declarations) -- File "/home/flatuser/flateditor/env/lib/python3.7/site-packages/folia/main.py", line 7687, in parsexmldeclarations -- self.declare(type, set, **subnode.attrib) -- File "/home/flatuser/flateditor/env/lib/python3.7/site-packages/folia/main.py", line 7778, in declare -- self.setdefinitions[set] = SetDefinition(set,verbose=self.verbose) #will raise exception on error -- File "/home/flatuser/flateditor/env/lib/python3.7/site-packages/folia/foliaset.py", line 395, in init -- self.graph.parse(location=url, format='rdf') -- File "/home/flatuser/flateditor/env/lib/python3.7/site-packages/rdflib/graph.py", line 1076, in parse -- parser = plugin.get(format, Parser)() -- File "/home/flatuser/flateditor/env/lib/python3.7/site-packages/rdflib/plugin.py", line 106, in get -- "No plugin registered for (%s, %s)" % (name, kind)) -- rdflib.plugin.PluginException: No plugin registered for (rdf, )

proycon commented 3 years ago

Interesting, I hadn't seen this one yet but I did some investigation and I think this is triggered by the host that hosts your set definition sending a mime-type that the underlying rdflib doesn't know how to handle. Can you show me the declarations section of your FoLiA document, then I can hopefully spot the URL that malfunctions?

pirolen commented 3 years ago

Thanks -- I did an attempt to include two new set declarations as XML, for references and notes, both are on github, likely not fully well formed. E.g. I'm not sure about the attributes type and xmlns.

I added the declarations by e.g. doc.declare(folia.Reference, 'https://raw.githubusercontent.com/pirolen/folia-resources/main/fset_references.foliaset.xml', format='application/foliaset+xml')

This is how they are in the file:

`

`

proycon commented 3 years ago

Ok, technically github sends out the wrong mime-type here (text/plain) but that does not appear to be the issue because I have the same with another set that does work.

What I do notice in your set definition is that the xmlns attribute is indeed missing, you need to have xmlns="http://ilk.uvt.nl/folia" on the root element. I wonder if that triggered this error.

(btw: you may need to restart foliadocserve when trying this in FLAT again, as it may cache set definitions)

pirolen commented 3 years ago

Yes, adding the correct xmlns solved it, thanks!