On Wed, Mar 6, 2013 at 10:54 AM, Ziqi Zhang
<[email protected]> wrote:
> I may have misunderstood something but here is my problem.
>
> I am using Jena API to get triples from this SPARQL endpoint:
> http://sparql.sindice.com/sparql
> My query is:
> --------------
> SELECT DISTINCT ?s ?o WHERE {
> ?s rdf:type rdfs:Class .
> {?s foaf:name "species"@en .}
> UNION {?s foaf:name "species" .}
> OPTIONAL {?s owl:equivalentClass ?o .}
> }
> --------------
>
> The query should return 5 results, each about a *blank node*. If you send
> the query using the web interface above, you should get the following
> results:
> ---------------------------
> s       o
> nodeID://b122741495
> http://purl.org/science/protein/bysequence/ncbi_gene.42069
> nodeID://b122741495
> http://purl.org/science/protein/bysequence/ncbi_gene.42504
> nodeID://b122741495
> http://purl.org/science/protein/bysequence/ncbi_gene.47877
> nodeID://b122741495
> http://purl.org/science/protein/bysequence/ncbi_gene.42945
> nodeID://b122741495     nodeID://b122741495
>
>
> ---------------------------
>
> However, using Java Jena API and the following, code, I get completely
> different blank node IDs:
> ----------------------
> s                                                       o
> 32ec7330:13d4066f80a:-7fff
> http://purl.org/science/protein/bysequence/ncbi_gene.42069
> 32ec7330:13d4066f80a:-7fff
> http://purl.org/science/protein/bysequence/ncbi_gene.42504
> 32ec7330:13d4066f80a:-7fff
> http://purl.org/science/protein/bysequence/ncbi_gene.47877
> 32ec7330:13d4066f80a:-7fff
> http://purl.org/science/protein/bysequence/ncbi_gene.42945
> ----------------------
>
> Why are the IDs different? because they are different, I cannot do further
> queries on the node at the sparql end point. What I mean is, if I then
> query:
> "Select ?p ?o where{32ec7330:13d4066f80a:-7fff ?p ?o .}"
> I will have no results, because the node ID does not match with
> "nodeID://b122741495".
>
>
> Would really appreciate any insight to this!

Blank node labels aren't portable across graphs/endpoints/etc.
Although the HTML formatted output from that endpoint uses something
that looks sort of like an IRI "nodeID://b122741495" (and maybe that
is, in fact, a valid IRI), if it's not identified by an IRI in the
original data, you don't have a consistent and portable way to
reference it from someplace else.

I played around a bit with the endpoint that you're using, and I'm not
sure you're getting the results you want anyhow.  For instance, if you
run the query:

SELECT DISTINCT * WHERE {
?class1 a rdfs:Class ;
        foaf:name "species"@en ;
        ?prop ?object .
}

that retrieves all the other properties of that rdfs:Class that has
the foaf:name "species"@en, you get a whole lot of results, and I
doubt that most of them make sense in the context of "things that are
classes named species."  Maybe a query like the following would be
enlightening:

SELECT DISTINCT * WHERE {
{ ?x foaf:name "species"@en }
UNION
{ ?x owl:equivalentClass [ foaf:name "species"@en ] }
}

This selects things named species and things that are equivalentClass
to something named species.  The results I get for x are

http://purl.org/science/protein/bysequence/ncbi_gene.47877
http://purl.org/science/protein/bysequence/ncbi_gene.42428
nodeID://b122741495
http://purl.org/commons/record/ncbi_gene/42062
http://purl.org/science/protein/bysequence/ncbi_gene.43130
http://dataportal.ucar.edu/schemas/vsto.owl#AltitudeDependentParameter
http://purl.oreilly.com/ns/meta/EditoralProduct
http://www.gazettes-online.co.uk/ontology#Edition

which includes that blank node, but also some other strange things
that probably aren't biology related classes.

But yes, in general, you can't reliably point to a particular blank
node in a dataset.  You'll have more luck if you can relate it to
something in the data.  For instance, if you wanted to get more
information about the thing that has name "species", you can just add
it to the query

SELECT DISTINCT * WHERE {
?x owl:equivalentClass [ foaf:name "species"@en ] ;
   ?prop ?value .
}

If you're doing updates, you could do things like

INSERT {
_:b foaf:name "name in addition to species"
}
WHERE {
_:b foaf:name "species"
}

to add another property to things that you can already reference
through some query.

//JT
-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Reply via email to