Hi,

On 31/07/13 00:10, Charles Li wrote:
   Hi, all Jena gurus:

   These should be two very simple questions for you guys, but I am new to
Jena and Sematic Web in general.

Aside: The right place to ask this is on the users list, this list is for people developing Jena.

I have the following RDF/XML snippet:

   <myNs:myAttr rdf:ID="*_{5E450868-C47D-4CA1-9779-06B003A9DA7D}*">
          <myNs:myAttr2>Foo</spc:myAttr2>
          <myNs:myRef rdf:resource="*#_{27900499-0D9D-4287-8F4D-E4C13BCB3C8D}
*" />
   </myNs:myAttr>

BTW I don't think '{' is legal in fragment identifiers, unless that's a result of the email mangling.

     (1) When I use the following code to loop through the query result:

                 Query query = QueryFactory.create("Select ?s ?p ?o where
{?s ?p ?o}");
QueryExecution qexec = QueryExecutionFactory.create(query, model);
ResultSet results = qexec.execSelect();
QuerySolution soln = null;
  while(results.hasNext()) {
try {
                                soln.get("?s")
                         .................

         How do I retrieve the RDFID in the subject?

rdf:ID is a not a property of a resource it is the URI of the resource. So:

    soln.get("s").getURI()

will return the full URI which will be the fragment ID in your sample resolved relative to whatever the given base URI for the document is.

    (2) How would I compose the SPARQL query to retrieve a single record by
a given RDF ID?

RDF doesn't have a notion of records. To get all the immediate properties of a particular URI use queries like:

   SELECT * WHERE
   {
      <my#uri> ?p ?o .
   }

Again the URI in the query is a full URI, not just the ID fragment. Typically people declare a prefix to match their base URI with a trailing '#' so that they can use the curi syntax eg:fragment in queries.

Dave

Reply via email to