Replies: 3 comments
-
Thank you, this is an interesting question!
They only work with container membership properties, querying Personally, I dislike
I am not sure how such a function could work in SPARQL (but see Jena functions for some functions with However, you don't need any special feature to build RDF Collections with SPARQL, see the following example. Input data (
Query PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
CONSTRUCT {
?item a rdf:List .
?item rdf:first ?value .
?item rdf:rest ?rest .
} WHERE {
#SELECT * WHERE {
SERVICE <x-sparql-anything:> {
fx:properties fx:location "./data.csv" .
?csv a fx:root .
?csv ?li ?item .
?item rdf:_1 ?value
OPTIONAL { ?csv ?li2 ?next . filter (fx:next(?li) = ?li2) }
BIND (IF(BOUND(?next), ?next, rdf:nil) AS ?rest )
}
} Output of @prefix fx: <http://sparql.xyz/facade-x/ns/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xyz: <http://sparql.xyz/facade-x/data/> .
[ rdf:type rdf:List ;
rdf:first "item-1" ;
rdf:rest [ rdf:type rdf:List ;
rdf:first "item-2" ;
rdf:rest [ rdf:type rdf:List ;
rdf:first "item-3" ;
rdf:rest [ rdf:type rdf:List ;
rdf:first "item-4" ;
rdf:rest [ rdf:type rdf:List ;
rdf:first "item-4" ;
rdf:rest [ rdf:type rdf:List ;
rdf:first "item-6" ;
rdf:rest ()
]
]
]
]
]
] .
|
Beta Was this translation helpful? Give feedback.
-
Thanks @enridaga, that query is quite neat and solves the problem! In fact, I think a repository of query templates for common and not so common patterns would be a nice addition of the website or docs. Patterns like that "could" also be captured in functions such as the jena ones for usability sake.
Me neither, but if SKOS tells you it's |
Beta Was this translation helpful? Give feedback.
-
Indeed :) |
Beta Was this translation helpful? Give feedback.
-
Hi! I was wondering whether SPARQL anything can support the construction of an RDF Collection, eg. in cases where order of a CSV or JSON array needs to be mapped to as
rdf:List
(like for the object ofskos:memberList
).fx:list(?a, ?l)
, which adds?a
to a list?l
?Beta Was this translation helpful? Give feedback.
All reactions