简体   繁体   中英

Extend prefix URIs in SPARQL query

I have created a prefix which has various sublevels for example:

PREFIX myprefix: <https://myprefix.org/>

I have several sublevels of prefix that I have used to organise my data. For example:

https://myprefix.org/people 
https://myprefix.org/buildings
https://myprefix.org/plants

I would now like to be able to specify the prefix with the extension in a SPARQL query. For example, I would like to select all of the properties in my database connected to the instance with the URI https://myprefix.org/people/michael :

PREFIX myprefix: <https://myprefix.org/>
select * where { 
    myprefix:people/michael ?p ?o.
} limit 100 

I have tried several approaches and have been unable to extend the prefix URI in the SPARQL query. I am now wondering if it good practice to use subcategories for prefixes or whether each prefix be complete to the instance or property it is describing.

Is there any advice on how to accomplish this?

What I tend to do is to have a prefix for entities and one for ontologies, such as this: PREFIX: <http://example.com/entities#> PREFIX ont: <http://example.com/ontology#>

Then, when I want different entities, I will simply write: :people_michael or :plants_1234 .

Alternatively, your approach can also work, but in SPARQL you'll need to escape the / , so your query will be:

    PREFIX myprefix: <https://myprefix.org/>
    
    SELECT *
    WHERE { 
        myprefix:people\/michael ?p ?o.
    }
    LIMIT 100 

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