Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

SPARQL request parsing



The SPARQLParser class allows to parse SPARQL requests expressed as a String, and generate a SPARQLRequest.

To create a SPARQLRequest from a String:
parsequery

Parser creation options

Main Article: Prefix declarations

There are several options to create the parser:

Parsing comments

By default comments in the SPARQL content are not parsed. The SPARQLParser.setParseComments(boolean parseComments) method allow to keep comments during parsing. Alternatively the SPARQLParser(String prefix, boolean parsePrefix, boolean parseComments) allow to manage the prefix and comments parsing.

Example

Suppose the following SPARQL request as a String:
   SELECT ?zone
   WHERE {
     ?zone rdf:type sitac:TaskZone .
     ?zone sitac:isTasked "true" .
   }
To parse this request, we can do:
   SPARQLParser parser = new SPARQLParser("sitac");
   SparqlRequest request = parser.parseQuery(<the request String>);

Unsupported constructs


For the moment, some constructs are yet not supported in SPARQL requests parsing. It does not mean that the parsing will fail, but the result will be incorrect in these cases.

Malformed requests

Main Article: Malformed requests

The SparqlHelperConfig.setErrorsHandlingType(char errorsHandlingType) specifies how the SPARQLParser should behave for malformed requests.

Notes

  1. ^ The SPARQLParser.parseQuery(URL, String) method allows to specify the charset to use when parsing the URL, the SPARQLParser.parseQuery(URL) method assume an UTF-8 encoded content

See also


Categories: Requestparsing

Copyright 2025 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence

Project Web Hosted by SourceForge.net Copyright 1999-2010 - Geeknet, Inc., All Rights Reserved About - Legal - Help