On 26/10/2023 10:17, Steve Vestal wrote:
What is the best way to reconstruct a typed Literal from a SPARQL SELECT result?

I have a SPARQL SELECT query issued against an OntModel in this way:

     QueryExecution structureRowsExec = QueryExecutionFactory.create(structureRowsQuery, owlOntModel);

Here are some example triples in the query:

      ?a2 <http://www.galois.com/indigo/test/structure_datatypes_test#floatProperty> ?dataVar1.       ?a2 <http://www.galois.com/indigo/test/structure_datatypes_test#dateTimeProperty> ?dataVar2.


Query results come back as the right RDF term kind.

The OntModel being queried was created using typed literals, e.g.,


    DataPropertyAssertion( struct:floatProperty struct:indivA2 "123.456"^^xsd:float )     DataPropertyAssertion( struct:dateTimeProperty struct:indivA2 "2023-10-06T12:05:10Z"^^xsd:dateTime )

When I look at the ?dataVar1 and ?dataVar2 results in a row, I get things like:

      1
      stringB
      123.456
      2023-10-06T12:05:10Z

Are those are just the toString() presentation?
Or is your query returning strings?


What is a good way to reconstruct a typed Literal from the query results?

RDFNode is the class for all RDF term types.

QuerySolution.get

and if you know they are literals:

QuerySolution.getLiteral

Is there a SPARQL option to show full typed literal strings? Something that can be added to the query?  A utility method that can identify the XSD schema simple data type when given a result value string?


Reply via email to