Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Adding SELECT content



Several methods allow to add elements in the SELECT part of the SPARQL request:

Selects with all

The syntax SELECT * is an abbreviation that selects all of the variables that are in-scope at that point in the query.

The following example uses a "SELECT *":
   SparqlRequest request = new SparqlRequest("sitac");
   request.setSelectAll();
   request.addType("zone", "TaskZone");
   request.addPropertyValue("zone", "isTasked", true);   
Will return the following SPARQL content:
   SELECT *
   WHERE {
      ?zone rdf:type sitac:TaskZone .
      ?zone sitac:isTasked "true" .
   }

Selects with variables

The following example uses a SELECT with a variable:
   SparqlRequest request = new SparqlRequest("sitac");
   request.addSelect("zone");
   request.addType("zone", "TaskZone");
   request.addPropertyValue("zone", "isTasked", true);   
Will return the following SPARQL content:
   SELECT ?zone
   WHERE {
      ?zone rdf:type sitac:TaskZone .
      ?zone sitac:isTasked "true" .
   }

Selects with expression

The following example uses a SELECT with an expression:
   SparqlRequest request = new SparqlRequest("sitac");
   request.addSelect("zone");
      
   VariableExpression varExpr = new VariableExpression("altitude");
   FunctionExpression function = new FunctionExpression(FunctionExpression.FUNCTION_FLOOR, varExpr);
   request.addSelect(function, "alt");
   request.addType("zone", "Zone");
   request.addPropertyRef("zone", "hasAltitude", "altitude");  
Will return the following SPARQL content:
   SELECT ?zone (floor(?altitude) AS ?alt)
   WHERE {
     ?zone rdf:type sitac:Zone .
     ?zone sitac:hasAltitude ?altitude .
   }

See also


Categories: Requestcreation

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