简体   繁体   中英

JENA - get value from RDF

Sorry, i am again here, because i have a fast question,for example if i have this rdf:

<rdf:RDF
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:ts="http://www.test.com/testModel.owl#">  
<ts:Entity rdf:ID="1234_test"> 
   <ts:Resource> 
       <ts:testProp rdf:datatype="http://www.w3.org/2001/XMLSchema#string">test_ID_test</ts:testProp>
 </ts>
</ts>
</rdf:RDF>

How i can extract the value test_ID_test??? And if i want use SPARQL how can i do with jena???

For running a SPARQL query using Jena, see the ARQ documentation or the Jena SPARQL tutorial.

As for your query, it depends how you want to identify the resource. If you know a priori the URI of the resource, it's straightforward:

prefix ts: <http://www.test.com/testModel.owl#>
select ?tp_value where {
  ts:1234_test ts:testProp ?tp_value
}

If you happen to know only that it's a resource of type Entity , the query is only slightly more involved:

prefix ts: <http://www.test.com/testModel.owl#>
select ?tp_value where {
  ?entity a ts:Entity ;
            ts:testProp ?tp_value
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM