I am using the results of one SPARQL query against an OntModel to
construct follow-on SPARQL queries.  The OntModel contains blank nodes
to denote some classes and individuals.  QueryResult gives me RDFNodes,
and I am using methods such as RDFNode#as(Class<T>) to obtain more
specific classifications for nodes including blank nodes (which seems to
work).  My understanding is that this gives me a Resource in the context
of the original, queried OntModel.

I am currently creating textual SPARQL queries.  My first question is,
what is the recommended way to represent a blank node in a textual
SPARQL query?  Is something like the following a reliable thing to do?

if (rdfNode.isAnon()) then {subjectName = "<" +
rdfNode.asResource().getId().getLabelString() + ">";}

My second question deals with the case where the initial SPARQL query is
a CONSTRUCT rather than a SELECT query, which returns a Model.  What is
the relationship between blank nodes in the constructed Model and the
OntModel that was initially queried?  If I visit triples using a
StmtIterator over the constructed Model, and create a textual name for a
blank node as above, can that name be used in a query applied to the
original OntModel?  How do I make sure that a blank node found in the
constructed Model will be mapped to the corresponding blank node in the
originating OntModel?



Reply via email to