SELECT variable used to order the result (by the orderedBy argument)). If this variable was not part of the SELECT variables, then it will be the first encountered variable in the columns.
SELECT constructSELECT construct. The key of the Map is the variable nameSELECT ?number ?type WHERE { ?alarm rdf:type inav:Alarm . ?alarm inav:AlarmNumber ?number . ?alarm inav:hasAlarmType ?type . }The following code will print the
?number and ?type of each result:public void subscribe(ServiceInstance service) { QueryResults results = (QueryResults) service.getData("response").getValue(); Iterator<QueryResults.Result> it = results.getOrderedResultsList().iterator(); while (it.hasNext()) { QueryResults.Result result = it.next(); int number = result.getValue("number").getValueAsInt(); String type = result.getValue("type").getValueAsString(); System.out.println("Alarm " + number + ": " + type); } }
<sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="name"/> <variable name="age"/> </head> <results> <result> <binding name="name"> <literal xml:lang="en">Bob</literal> </binding> <binding name="age"> <literal datatype="http://www.w3.org/2001/XMLSchema#integer">30</literal> </binding> </result> <result> <binding name="name"> <literal xml:lang="en">Bobby</literal> </binding> <binding name="age"> <literal datatype="http://www.w3.org/2001/XMLSchema#integer">40</literal> </binding> </result> </results> </sparql>If we call:
QueryResults results = QueryResultsUtilities.getOrderedResults(<XML String>, true, "name");Wr will have two results:
Copyright 2025 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence