Consider:
PREFIX rss: <http://purl.org/rss/1.0/>
PREFIX dct: <http://purl.org/dc/terms/>
CONSTRUCT {
?article dct:title ?title .
}
WHERE {
?article rss:title ?title .
}
How I get a lang value on the output?
|
1
|
Consider:
How I get a lang value on the output? |
||||||
|
|
3
|
You can't do what you want with SPARQL 1.0. Currently all you can do is CONSTRUCT out triples that already exist in the underlying triple store. The CONSTRUCT query just takes the matches from the patterns in the WHERE clause and creates corresponding triples. Any languages or datatypes associated with literals will get passed through automatically. SPARQL 1.1 should help, but as it currently stands you'll have to jump through hoops. SPARQL 1.1. as currently drafted won't support use of functions in CONSTRUCT clauses, but will support sub-selects, select expressions, and, as a time-permitting feature, a function library. A combination of these features would let you assign the value of a newly generated literal (created by a custom function) in a sub-select, and then use that variable in a CONSTRUCT clause. This can be a little verbose, and there's currently some debate about supporting a LET keyword that will allow simpler syntax for assignments. This is supported as an extension in some SPARQL engines, but is not currently part of the specification. Now is the time to comment to the working group! |
||
|
|
|
2
|
I don't believe there is a way to add language tags to literals in the way you want. CONSTRUCT will copy them from the source graph, but you can't add new ones. Maybe this will be addressed in SPARQL 1.1 |
|||
|
|
1
|
If I execute your query over the following dataset:
I get this output:
If this is all you want to do then I think your query will work fine. If it's not working you may have to provide additional information about the query processor/triple store you are using so that we can better help you debug. Some query processors (the one I am using is from Intellidimension) allow you to extend their SPARQL query processor with custom functions. In this case they provide one out of the box that allows you to set/change the lang declaration on a literal value. SPARQL Construct Query:
Output:
|
|||
|