Query and Rule languages Use Cases and Examples |
Produced: Thu Jun 17 10:46:59 CEST 2004
Alberto Reggiori and Andy Seaborne |
select
?uri,?name, ?lat, ?lon
from
<http://swordfish.rdfweb.org/discovery/2003/11/cities/xmlrdf.jsp?query=port>
where
(?city, <rdfs:label>, ?name),
(?city, <rdfs:label>,?uri),
(?city, <pos:lat>, ?lat),
(?city, <pos:long>, ?lon)
using
rdfs FOR <http://www.w3.org/2000/01/rdf-schema#>,
pos FOR <http://www.w3.org/2003/01/geo/wgs84_pos#>,
doilair FOR <http://www.daml.org/2001/10/html/airport-ont#>,
vcard FOR <http://www.w3.org/vcard-rdf/3.0#>
select
?uri,?name, ?lat, ?lon
from
<http://foaf.asemantics.com/dirkx>
where
(?person, <rdf:type>, <foaf:Person>),
(?person, <foaf:name>, ?name),
(?person, <foaf:based_near>, ?bn),
(?person, <foaf:mbox>,?uri),
(?bn, <pos:lat>, ?lat),
(?bn, <pos:long>, ?lon)
using
rdf FOR <http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
rdfs FOR <http://www.w3.org/2000/01/rdf-schema#>,
foaf FOR <http://xmlns.com/foaf/0.1/>,
dc FOR <http://purl.org/dc/elements/1.1/>,
pos FOR <http://www.w3.org/2003/01/geo/wgs84_pos#>
select
?uri,?name, ?lat, ?lon
from
<http://foaf.asemantics.com//few.airports.rdf>
where
(?airport, <airportonto:name>, ?name),
(?airport, <airportonto:location>,?uri),
(?airport, <airportonto:longitude>, ?lon),
(?airport, <airportonto:latitude>, ?lat)
using
rdf FOR <http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
rdfs FOR <http://www.w3.org/2000/01/rdf-schema#>,
foaf FOR <http://xmlns.com/foaf/0.1/>,
dc FOR <http://purl.org/dc/elements/1.1/>,
pos FOR <http://www.w3.org/2003/01/geo/wgs84_pos#>,
airportonto FOR <http://www.daml.org/2001/10/html/airport-ont#>
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix dc: <http://purl.org/dc/elements/1.1/>.
@prefix dcq: <http://purl.org/dc/terms/>.
@prefix etbthes: <http://eun.org/etb/thesaurus/elements/>.
@prefix rss: <http://purl.org/rss/1.0/>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
@prefix : <#>.
@prefix result: <result#>.
{
[ dc:title [
rdf:value ?title_value;
dc:language [dcq:RFC1766 ?title_language]];
dc:subject [
etbthes:ETBT [
rdf:value ?subject_value;
dc:language [dcq:RFC1766 ?subject_language]]];
dc:description [
rdf:value ?description_value;
dc:language [dcq:RFC1766 ?description_language]];
dc:identifier ?identifier;
dc:language [dcq:RFC1766 ?language]].
} => {
[ result:titleValue ?title_value;
result:titleLanguage ?title_language;
result:subjectValue ?subject_value;
result:subjectLangauge ?subject_language;
result:descriptionValue ?description_value;
result:descriptionLangauge ?description_language;
result:langauge ?language;
result:identifier ?identifier].
}.
distribute(all(),
'distribute(.-dc:title->*,
".-rdf:value->*",
"(.-dc:language->*)-dcq:RFC1766->*",
)',
'distribute((.-dc:subject->*)-etbthes:ETBT->*,
".-rdf:value->*",
"(.-dc:language->*)-dcq:RFC1766->*",
)',
'distribute(.-dc:description->*,
".-rdf:value->*",
"(.-dc:language->*)-dcq:RFC1766->*",
)',
'distribute(.-dc:identifier->*,
".-rdf:value->*",
"(.-dc:language->*)-dcq:RFC1766->*",
)',
)
SELECT
title_value, title_language,
subject_value,subject_language,
description_value, description_language,
language,
identifier
FROM
{x} <dc:title> {} <rdf:value> {title_value};
<dc:language> {} <dcq:RFC1766> {title_language},
{x} <dc:subject> {} <etbthes:ETBT> {} <rdf:value> {subject_value};
<dc:language> {} <dcq:RFC1766> {subject_language},
{x} <dc:description> {} <rdf:value> {description_value};
<dc:language> {} <dcq:RFC1766> {description_language},
{x} <dc:identifier> {identifier},
{x} <dc:language> {} <dcq:RFC1766> {language}
USING NAMESPACE
dc = <!http://purl.org/dc/elements/1.1/>,
dcq = <!http://purl.org/dc/terms/>,
dct = <!http://purl.org/dc/dcmitype/>,
etb = <!http://eun.org/etb/elements/>,
etbthes = <!http://eun.org/etb/thesaurus/elements/>
SELECT
?title_value, ?title_language,
?subject_value,?subject_language,
?description_value, ?description_language,
?language,
?x.dc:identifier
FROM ?x.dc:title{?tt}.rdf:value{?title_value},
?tt.dc:language.dcq:RFC1766{?title_language},
?x.dc:subject.etbthes:ETBT{?ss2}.rdf:value{?subject_value},
?ss2.dc:language.dcq:RFC1766{?subject_language},
?x.dc:description{?dd}.rdf:value{?description_value},
?dd.dc:language.dcq:RFC1766{?description_language},
?x.dc:language.dcq:RFC1766{?language}
USE
rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
dc for <http://purl.org/dc/elements/1.1/>,
dcq for <http://purl.org/dc/terms/>,
etbthes for <http://eun.org/etb/thesaurus/elements/>
(deductiverule
?x <- (? (dc:title ?tt) (dc:description ?dd)
((etbthes:ETBT dc:subject) ?ss2)
(dc:identifier ?identifier)
((dcq:RFC1766 dc:language) ?language))
?tt <- (? (rdf:value ?t_val)
((dcq:RFC1766 dc:language) ?t_lang))
?ss2 <- (? (rdf:value ?subject_val)
((dcq:RFC1766 dc:language) ?s_lang))
?dd <- (? (rdf:value ?desc_val)
((dcq:RFC1766 dc:language) ?desc_lang))
=>
(result (title_value ?t_val)
(title_language ?t_lang)
(subj_val ?subject_val)
(subj_lang ?s_lang)
(desc_value ?desc_val)
(desc_lang ?desc_lang)
(language ?language)
(identifier ?identifier))
)
SELECT
?title_value, ?title_language,
?subject_value,?subject_language,
?description_value, ?description_language,
?language,
?identifier
FROM
<http://braveheart.eun.org/xml/rdf/example10.xml>
WHERE
( ?x, <dc:title>, ?tt),
( ?tt, <rdf:value>, ?title_value),
( ?tt, <dc:language>, ?ttl),
( ?ttl, <dcq:RFC1766>, ?title_language),
( ?x, <dc:subject>, ?ss1),
( ?ss1, <etbthes:ETBT>, ?ss2),
( ?ss2, <rdf:value>, ?subject_value),
( ?ss2, <dc:language>, ?ss3),
( ?ss3, <dcq:RFC1766>, ?subject_language),
( ?x, <dc:description>, ?dd),
( ?dd, <rdf:value>, ?description_value),
( ?dd, <dc:language>, ?ddl),
( ?ddl, <dcq:RFC1766>, ?description_language),
( ?x, <dc:identifier>, ?identifier),
( ?x, <dc:language>, ?ll1),
( ?ll1, <dcq:RFC1766>, ?language)
USING
rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
rdfs for <http://www.w3.org/2000/01/rdf-schema#>,
dc for <http://purl.org/dc/elements/1.1/>,
dcq for <http://purl.org/dc/terms/>,
dct for <http://purl.org/dc/dcmitype/>,
etb for <http://eun.org/etb/elements/>,
etbthes for <http://eun.org/etb/thesaurus/elements/>
@prefix rss: <http://purl.org/rss/1.0/>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
@prefix : <#>.
this log:forAll :t, :l.
{
<http://xmlhack.com/rss10.php>.log:semantics log:includes {
[] a rss:item; rss:title :t; rss:link :l.
:t string:containsIgnoringCase "XML". }
} => {
[] :title :t; :link :l
}.
(type(rss:item) |- rss:title -> contains('RDQL')) -> rss:link
SELECT link
FROM
{item} <rdf:type> {<rss:item>};
<rss:title> {title};
<rss:link> {link}
WHERE
title like "*RDQL*"
USING NAMESPACE
rss = <!http://purl.org/rss/1.0/>
(deductiverule
(rss:item (rss:title ?title) (rss:link ?link))
(test (str-index "RDQL" ?title))
=>
(result (link ?link))
)
SELECT ?link
FROM <http://xmlhack.com/rss10.php>
WHERE
(?item, <rdf:type>, <rss:item>),
(?item, <rss::title>, ?title),
(?item, <rss::link>, ?link)
AND ?title LIKE '/RDql/i'
USING
rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
rss for <http://purl.org/rss/1.0/>
SELECT ?link
FROM <http://xmlhack.com/rss10.php>
WHERE
(?item, <rdf:type>, <rss:item>),
(?item, <rss::title>, %"RDQL"%),
(?item, <rss::link>, ?link)
USING
rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
rss for <http://purl.org/rss/1.0/>
@prefix rss: <http://purl.org/rss/1.0/>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix : <#>.
this log:forAll :t, :l.
{
<http://xmlhack.com/rss10.php>.log:semantics log:includes {
[] a rss:item; rss:title :t; rss:link :l }
} => {
[] :title :t; :link :l
}.
distribute(type(rss:item),
'. - rss:title -> *',
'. - rss:link -> *')
select title, link
from {item} <rdf:type> {<rss:item>};
<rss:title> {title};
<rss:link> {link}
using namespace
rss = <!http://purl.org/rss/1.0/>
SELECT ?title, ?link
FROM rss:item::?item.rss:title,
?item.rss:link{?link}
USE
rss for [http://purl.org/rss/1.0/]
(deductiverule
(rss:item (rss:title ?title) (rss:link ?link))
=>
(result (title ?title) (link ?link))
)
SELECT ?title, ?link
FROM <http://xmlhack.com/rss10.php>
WHERE
(?item, <rdf:type>, <rss:item>),
(?item, <rss::title>, ?title),
(?item, <rss::link>, ?link)
USING
rdf for <http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
rss for <http://purl.org/rss/1.0/>
@prefix con: <http://www.w3.org/2000/10/swap/pim/contact#>.
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix data: <#>.
@prefix : <#>.
{ [] :Given ?g; :Family ?f; :favoriteSport ?s.
?s :label ?l.
("<tr><td>" ?g "</td><td>" ?f "</td><td>" ?l "\n" )
string:concatenation ?r } => { ?l log:outputString ?r }.
"000" log:outputString """<html><body>
<h1>Ordered by sport</h1>
<table>
""".
"ZZZ" log:outputString "</table></body></html>\n".
# test data:
:soccer :label "Soccer".
:tennis :label "Tennis".
[] :Given "Andrew"; :Family "Other"; :favoriteSport :soccer.
[] :Given "Jane"; :Family "Doe"; :favoriteSport :tennis.
[] :Given "Jane"; :Family "Smith"; :favoriteSport :soccer.
[] :Given "John"; :Family "Smith"; :favoriteSport :tennis.
[] :Given "Marmaduke"; :Family "Smith"; :favoriteSport :soccer.
[] :Given "Smith"; :Family "Robinson"; :favoriteSport :soccer.
distribute(type(hdr:HeaderField),
'. - hdr:fieldName -> *',
'. - rdfs:label -> *',
'distribute(. - hdr:protocol -> *,
". - hdr:protocolName -> *",
". - hdr:specification -> *",
". - hdr:document -> *")
)
SELECT *
FROM
{Header} <rdf:type> {HeaderField};
<hdr:fieldName> {Name};
<rdfs:label> {Purpose};
<hdr:protocol> {P} <hdr:protocolName> {Pname};
<hdr:specification> {Ps} <hdr:document> {Psdocument}
USING NAMESPACE
hdr = <!foo://bar/>
SELECT
?header,
?header.hdr:fieldName,
?header.rdfs:label,
?p,
?p.hdr:protocolName,
?ps,
?ps.hdr:document
FROM hdr:HeaderField::?header.hdr:protocol{?p}.hdr:specification{?ps}}
(deductiverule
?Header <- (hdr:HeaderField (hdr:fieldName ?name)
(rdfs:label ?purpose)
(hdr:protocol ?p))
?p <- (? (hdr:protocolName ?pn) (hdr:spec ?ps))
?ps <- (? (hdr:document ?psdocument))
=>
(result (header ?Header) (name ?name)
(protocol ?p) (purpose ?purpose)
(pname ?pn) (spec ?ps)
(document ?psdocument))
)
hrep:HdrProtoPattern :-
( [ rep:var "header" ]
[ rep:and
( [ rep:uri rdf:type ] [ rep:uri hdr:HeaderField ] ),
( [ rep:uri hdr:fieldName ] [ rep:var "name" ] ),
( [ rep:uri rdfs:label ] [ rep:var "purpose" ] ),
( [ rep:uri hdr:protocol ] [ rep:var "p" ]
[ rep:and
( [ rep:uri hdr:protocolName] [ rep:var "pname" ] ),
( [ rep:uri hdr:specification] [ rep:var "ps" ]
[ rep:uri hdr:document ] [ rep:var "psdocument" ] )
] )
] ) .
( ?Header
( rdf:type hdr:HeaderField &
hdr:fieldName ?name &
rdfs:label ?purpose &
hdr:protocol ?p
( hdr:protocolName ?pname &
hdr:specification ?ps hdr:document ?psdocument ) ) )
If no range information from the schema is available, this
query fails to match a property of resource .
# @@ would be nice to have this just use --mode=rsme --think
# to pick up hte schema data automatically
#
@prefix con: <http://www.w3.org/2000/10/swap/pim/contact#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix data: <#>.
@prefix : <#>.
{data:x ?p ?v. ?p rdfs:range ?c} => {[] :prop ?p; :range ?c; :val ?v }.
# test data:
data:x con:office [
con:address [ con:street "Lombard Street" ]];
con:home [
con:address [ con:street "Islington Gardens"]].
# test metadata: (a subset of the schema)
con:office rdfs:range con:Location.
con:home rdfs:range con:Location.
con:address rdfs:range con:Address.
data:x - (all() |- rdfs:range -> *) -> *
session.namespaces["vcard"] = "http://www.w3.org/2001/vcard-rdf/3.0#";
session.namespaces["data"] = "file://test/";
session.namespaces["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#";
select ?property, ?value, ?type using somedata where
{?property [data:x] ?value} and {[rdfs:range] ?property ?type}
select prop, val, type
from {<data:x>} prop {val},
{prop} <rdfs:range> {type}
using namespace
data = <!file://test/>
SELECT ?property, ?value, ?type
FROM
?x.?property{?value},
?property.rdfs:range{?type}
USE
rdfs FOR [http://www.w3.org/2000/01/rdf-schema#]
(deductiverule
data:x <- (? (?property ?value))
?property <- (rdf:Property (rdfs:range $? ?t $?))
=>
(result (property ?property) (value ?value)
(type ?t))
)
SELECT ?property, ?value, ?type
WHERE
(<data:x>, ?property, ?value) ,
(?property, <rdfs:range>, ?type)
USING
vcard FOR <http://www.w3.org/2001/vcard-rdf/3.0#>
rdfs FOR <http://www.w3.org/2000/01/rdf-schema#>
rdf FOR <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
data FOR <file://test/>
This depends on the regularity of the data
@prefix this: <#>.
@prefix con: <http://www.w3.org/2000/10/swap/pim/contact#>.
@prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>.
@prefix : <http://www.w3.org/2001/vcard-rdf/3.0#>.
# @@ Test case is not schema-valid - see vcard schema.
{[] :Family "Smith"; :Given ?g } => { ?g a this:SmithFamilyMember }.
# test data:
[] :Given "Andrew"; :Family "Other".
[] :Given "Jane"; :Family "Doe".
[] :Given "Jane"; :Family "Smith".
[] :Given "John"; :Family "Smith".
[] :Given "Marmaduke"; :Family "Smith".
[] :Given "Smith"; :Family "Robinson".
("Smith" <- vcard:Family - *) - vcard:Given -> *
session.namespaces["vcard"] = "http://www.w3.org/2001/vcard-rdf/3.0#";
select ?v using somedata where {[vcard:N] ?x ?y}
and {[vcard:Family] ?y 'Smith'} and {[vcard:Given] ?y ?v}
SELECT v
FROM
{x} <vcard:N> {y} <vcard:Family> {"Smith"};
<vcard:Given> {v}
USING NAMESPACE
vcard = <!http://www.w3.org/2001/vcard-rdf/3.0#>
SELECT v
FROM
{x} vcard:N {y}. vcard:Family {fam}
{y} vcard:Given {v}
WHERE
fam = "Smith"
USING NAMESPACE
vcard = http://www.w3.org/2001/vcard-rdf/3.0#
SELECT ?v
FROM
?x.vcard:N{?y}.vcard:Family=>'Smith' ,
?y.vcard:Given{?v}
USE
vcard FOR [http://www.w3.org/2001/vcard-rdf/3.0#]
(deductiverule
?x <- (? (vcard:N ?y))
?y <- (? (vcard:Family "Smith") (vcard:Given ?v))
=>
(person (name ?v))
)
SELECT ?v
WHERE
(?x, <vcard:N>, ?y) ,
(?y, <vcard:Family>, "Smith") ,
(?y, <vcard:Given>, ?v)
USING
vcard FOR <http://www.w3.org/2001/vcard-rdf/3.0#>
@prefix email: <http://www.hpl.hp.com/email/email#>.
{ ?x email:message-id "123456@example.com" }
=>
{ ?x email:message-id "123456@example.com" }.
# test data
@prefix : <#>.
:m1235 email:message-id "814358768@example.com";
email:from "whoever@example.com".
:m1236 email:message-id "814358432168@example.com";
email:from "whoever@example.com".
:m12314 email:message-id "123456@example.com";
email:from "whoeverelse@example.com".
all() |- email:message-id -> eq('123456@example.com')
select x
from {x} <email:message-id> {"123456@example.com"}
using namespace
email = <!http://www.hpl.hp.com/email/email#>
SELECT x
FROM {x} email:message-id {id}
WHERE id = "123456@example.com"
USING NAMESPACE
email = http://www.hpl.hp.com/email/email#
SELECT ?x
FROM ?x.email:message_id=>'123456@example.com'
USE email FOR [http://www.hpl.hp.com/email/email#]
session.namespaces["pop3"] = "http://www.intellidimension.com/namespaces/pop3#";
session.namespaces["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
session.namespaces["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#";
var ds = new DataSource("pop3?server=mail.somewhere.net&user=someuser&pass=xxxx&action=list");
select ?msg ?from using #ds where {[rdf:type] ?msg [pop3:Message]} and
{[pop3:property] ?msg ?prop} and {[rdfs:label] ?prop 'From'} and
{[rdf:value] ?prop ?from} and regexp(?from, 'hotmail')<>''
(deductiverule
?x <- (? (email:message-id '123456@example.com'))
=>
(result (email ?x))
)
SELECT ?x
WHERE (?x, <email:message-id>, '123456@example.com')
USING email FOR <http://www.hpl.hp.com/email/email#>
The concept of statement "context" (scope/provenance) is out of the RDF model and has not been considered yet for inclusion into the RDF specifications. Some RDF toolkits out there allow to SELECT triples using one more dimension/component (s,p,o + c) - it is not clear at all to me where this "extension" is going to fit into the RDF framework (i.e. reification and higher-oder statements) but it is definitively needed as soon as you start writing real-world applications.
SELECT
?x, ?title, ?date, ?description, ?section, ?acquired, ?source, ?ctx
FROM
<rdfstore://nb@demo.asemantics.com:1234>
WHERE
(?ctx, <dc:date>, "2003-11-14"@it),
(?ctx, <rdf:type>, <rdfstore:Context>),
(?x, <lmn:section>, %"international | national | gossip"%, ?ctx),
(?x, <rdf:type>, <rss:item>, ?ctx),
(?x, <rss:title>, ?title, ?ctx),
(?x, <dc:date>, ?date, ?ctx),
(?x, <rss:description>, ?description, ?ctx),
(?x, <lmn:acquired>, ?acquired, ?ctx),
(?x, <lmn:section>, ?section, ?ctx),
(?items, ?ii, ?x, ?ctx),
(?items, <rdf:type>, <rdf:Seq>, ?ctx),
(?s, <rss:items>, ?items, ?ctx),
(?s, <rdf:type>, <rss:channel>, ?ctx),
(?s, <rss:title>, ?source, ?ctx)
USING
rss FOR <http://purl.org/rss/1.0/>,
lmn FOR <http://www.asemantics.com/schemas/lastminutenews/>,
dc FOR <http://purl.org/dc/elements/1.1/>,
dctypes FOR <http://purl.org/dc/dcmitype/>,
h FOR <http://www.w3.org/1999/xhtml>,
rdf FOR <http://www.w3.org/1999/02/22-rdf-syntax-ns#>, rdfstore FOR <http://rdfstore.sourceforge.net/contexts/>
One generalization is for queries to be in three parts: locate, extract and present.
Locate is all exact matches of the (conjunctive) query graph pattern (c.f. QL98) and produces a number of solutions, where each solution is a set of variable bindings.
Extract is zero or more optional patterns, each of which is tried for each exact match and can extend each variable binding set with new variables (need not do so for all solutions).
Present deals with the form of the output. This may be the variables actually required, like in a SELECT clause, or it may be an RDF template where a graph has variables in it. The values of the variables are substituted to form a subgraphs for each solution.
Example:
In a system like cwm, the left-hand side of log:implies is the locate part, the right-hand side is the present part. There is no extract (optional bindings).
Similarly in RDQL and Inkiling, the locate part is the WHERE clause, the present part is the SELECT clause (not RDF) and there is no extract part.
DQL does have this optionality through the 'may bind' variables.
Issue: this implicit model of query execution may be limited in tha optional variable bindings in the extract part do not take part in the locate process.
What use cases does this miss?
Is it compatible with a path-like view of query?
What use cases does this miss?
Is it compatible with a path-like view of query?
select
NAME, STREET
from
{} <nc:friends> {FRIENDS} <rdfs:member> {FRIEND},
{FRIEND} <nc:name> {NAME};
[<nc:address> {} <nc:street> {STREET}]
using namespace
nc = <!http://home.netscape.com/NC-rdf#>
Notes: To run the query, and others, and to modify the example, please log in to the "demo" ID of the Internet Business Logic system at www.reengineeringllc.com .
Pick RDFQueryLangComparison1, and view/change or run it using a browser.
select
class, descr
from
{class} <rdf:type> {<rdfs:Class>};
<rdfs:label> {descr}
where
lang(descr) = "en"
i dont know
This use-case arose from wanting to process a history of events relating to a document editing process (see: http://www.ninebynine.org/wip/DocIssues/RDFConceptIssues.n3, http://www.ninebynine.org/wip/DocIssues/RDFConceptIssues.html).
Container and list queries for the above data have been implemented in my "RDF for little languages" report generator (see http://www.ninebynine.org/Software/Intro.html) The query itself is encoded in Notation3 in the source code file N3GenDocIssues.py.
@prefix therm: <http://www.example.com/thermal#>.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix : <myHouse#>.
@prefix my: <myHouse#>.
{ ?thermostat therm:temp ?t; therm:setting ?s .
?s math:greaterThan ?t .
} => {
?thermostat a therm:CallingForHeat .
}.
{ [] a therm:CallingForHeat } => { :boiler therm:control "ON" }.
# test data:
:livingRoom therm:temp "22"; therm:setting "21".
:bedroom therm:temp "14"; therm:setting "18".
:hall therm:temp "22"; therm:setting "21".
XPath (and XQuery) query is user-friendly and most developers (webmasters) like/use it every day - it is important that any RDF/XML query language be XML "friendly" in that sense
This document was automatically generated from the RDF for the use cases.
To submit new use cases or change existing ones, please email Alberto Reggiori or Andy Seaborne.