8.3 Semantic Web Queries 183
for $desc in
document("medline.xml")//MeshHeading/DescriptorName
let $cite := ../../MedlineCitation
where $desc/@MajorTopicYN = "Y"
return $cite, $desc/text()
Summary
- XQuery is the standard query language for processing XML documents.
- Every XPath expression is a valid XQuery query.
- A general query is made of four kinds of clause:
- A for clause scans the result of an XPath expression, one node at a time.
- A where clause selects which of the nodes scanned by the for clauses
are to be used.
- A return clause specifies the output of the query.
- A let clause sets a variable to an intermediate result. This is an op-
tional convenience so that a complicated expression does not have to
be written more than once.
8.3 Semantic Web Queries
Unlike XML which has standard navigation and query languages, the Se-
mantic Web languages do not yet have a standard query language. Some
suggestions have been made, but it is still unclear what the standard lan-
guage will eventually look like.
There are several contenders for a Semantic Web query language:
- A language similar to XQuery, which itself was inspired by SQL. Such a
language would treat the knowledge base as a database of triples. From
the point of view of the relational model, RDF has a very simple data
model: a table with three columns, the subject, predicate, and object.
The OWL languages are based on RDF triples so the same data model
would apply. However, this data model ignores the semantic differences
between relational databases and the Semantic Web languages.