Skip to content

Is it possible to define default prefixes with connection.prepareQuery(String)? #3980

Answered by EmptyStar
ate47 asked this question in Q&A
Discussion options

You must be logged in to vote

I came across this question a couple days ago in search of a solution to this exact situation, and from what I can tell, there is no API to apply prefixes to a SPARQL query or parser. It is possible for RDF parsers by calling RDFParser.getParserConfig().set(BasicParserSettings.NAMESPACES,namespaces), but no analogue exists for SPARQL parsers that I could find.

I implemented it in my own project by lexing SPARQL queries for their prefixes and tacking on prefixes that don't exist which is the same approach you mentioned plus some logic to work around duplicate prefixes. It's not ideal, but it works. https://github.com/rdfpub/generator/blob/main/init/src/main/java/pub/rdf/builder/DatabaseBui…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ate47
Comment options

Answer selected by ate47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants