comunica / jQuery-Widget.js

🖼 A jQuery widget to query heterogeneous interfaces using Comunica SPARQL
http://query.linkeddatafragments.org/
MIT License
18 stars 35 forks source link

Prevent duplicate prefixes #163

Open simonvbrae opened 1 month ago

simonvbrae commented 1 month ago

Fixing Issue #149.

Some questions: Should I also account for "PREFIX" not being written all caps in the query? Can I assume that PREFIX lines start with PREFIX or with only whitespace before? Can I assume that each PREFIX declaration is on a seperate line starting with PREFIX? Or could there be multiple? Can prefixes be declared deeper in the query or only at the top?

rubensworks commented 1 month ago

Instead of parsing the query manually, I would recommend plugging into the actual SPARQL parser. This would also solve the questions you raised above, and make the code more robust.

I don't remember if the jquery widget here will actually call the parser here directly. So duplicate handling may actually be necessary to do in comunica base, or even SPARQL.js.

simonvbrae commented 1 month ago

Since it doesn't look like Jquery calls the parser, I'll have a look at doing it further up. Comunica seems like the logical place to do duplicate handling. For this case, using the last-defined prefix in the case of a duplicate should work.