query-b2f18304466cfc373e032daae097f82a
Dump reference(s) given a Q-item and optionally a property. SELECT ?statement ?refnode ?predicate ?propertyLabel ?value ?valueLabel WHERE { VALUES (?item ?itempredicate) { (wd:Q42 UNDEF) } #VALUES (?item ?itempredicate) { (wd:Q42 p:P2048) } ?item ?itempredicate ?statement . [] wikibase:claim ?itempredicate .
?statement prov:wasDerivedFrom ?refnode . ?refnode ?predicate ?value . OPTIONAL { ?property wikibase:reference|wikibase:referenceValue|wikibase:referenceValueNormalized ?predicate . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . } } ORDER BY ?statement ?refnode DESC(?predicate)
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Dump reference(s) given a Q-item and optionally a property.
SELECT ?statement ?refnode ?predicate ?propertyLabel ?value ?valueLabel
WHERE {
VALUES (?item ?itempredicate) { (wd:Q42 UNDEF) }
#VALUES (?item ?itempredicate) { (wd:Q42 p:P2048) }
?item ?itempredicate ?statement .
[] wikibase:claim ?itempredicate .
?statement prov:wasDerivedFrom ?refnode .
?refnode ?predicate ?value .
OPTIONAL { ?property wikibase:reference|wikibase:referenceValue|wikibase:referenceValueNormalized ?predicate . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
ORDER BY ?statement ?refnode DESC(?predicate)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?item")
v5("?itempredicate")
v3("?predicate"):::projected
v7("?property")
v2("?refnode"):::projected
v1("?statement"):::projected
v6("?value"):::projected
a1((" "))
c7(["bd:serviceParam"]):::iri
c9(["en"]):::literal
bind0[/VALUES ?item ?itempredicate/]
bind0-->v4
bind0-->v5
bind00(["wd:Q42"])
bind00 --> bind0
bind01([ERROR: Bad value])
bind01 --> bind0
v4 -->v5--> v1
a1 --"wikibase:claim"--> v5
v1 --"prov:wasDerivedFrom"--> v2
v2 -->v3--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v7 -."wikibase:referenceValueNormalized".-> v3
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v7 --"wikibase:referenceValue"--> v3
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v7 --"wikibase:reference"--> v3
end
union0r <== or ==> union0l
end
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end