ajtucker opened a new issue, #2585: URL: https://github.com/apache/jena/issues/2585
### Version 5.0.0 ### What happened? We're building a SPARQL query programatically and then serializing the query to a string to be able to run it against a Fuseki SPARQL endpoint. In one case, we build a query with a valid URI node that is then serialized as an invalid prefixed name, because the local part starts with an invalid character according to https://www.w3.org/TR/sparql11-query/#rPN_LOCAL This query exhibits the issue: ```sparql PREFIX eg: <http://example.com/with-trailing/> ASK { <http://example.com/with-trailing/-with_leading-> a eg:BadPN_LOCAL . } ``` Using `qparse` to parse the above throws a `QueryParseException` as below when it checks the output query by re-parsing it. ### Relevant output and stacktrace ```shell $ qparse 'PREFIX eg: <http://example.com/with-trailing/> ASK { <http://example.com/with-trailing/-with_leading-> a eg:BadPN_LOCAL . }' PREFIX eg: <http://example.com/with-trailing/> ASK WHERE { eg:-with_leading- a eg:BadPN_LOCAL } **** Check failure: could not parse output query org.apache.jena.query.QueryParseException: Encountered " "-" "- "" at line 5, column 8. Was expecting one of: <IRIref> ... <PNAME_NS> ... <PNAME_LN> ... <VAR1> ... <VAR2> ... "a" ... "distinct" ... "multi" ... "shortest" ... "(" ... "!" ... "^" ... at org.apache.jena.sparql.lang.ParserARQ.perform(ParserARQ.java:99) at org.apache.jena.sparql.lang.ParserARQ.parse$(ParserARQ.java:52) at org.apache.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:33) at org.apache.jena.query.QueryFactory.parse(QueryFactory.java:144) at org.apache.jena.query.QueryFactory.create(QueryFactory.java:83) at org.apache.jena.sparql.util.QueryUtils.checkParse(QueryUtils.java:96) at org.apache.jena.sparql.util.QueryUtils.checkQuery(QueryUtils.java:38) at arq.qparse.exec(qparse.java:158) at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87) at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56) at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43) at arq.qparse.main(qparse.java:66) PREFIX eg: <http://example.com/with-trailing/> ASK WHERE { eg:-with_leading- a eg:BadPN_LOCAL } ``` ### Are you interested in making a pull request? Yes -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
