This document discusses how to query topic maps using SPARQL. It provides an example SPARQL query that selects the topic names and related links for all topics in a topic map. It then explains the components of SPARQL queries, including prefixes, select/construct clauses, variables, and general subject-predicate-object patterns used. Finally, it discusses how SPARQL can be used to configure RDF exports from topic maps.
1. How
to
“SPARQL”
Topic
Maps?
Query
Topic
Map
Result
HTML,
XML,
JSON
PREFIX
rdfs:
<hDp://www.w3.org/2000/01/rdf-‐schema#>
PREFIX
tmdm:
<hDp://psi.topicmaps.org/iso13250/model/>
SELECT
DISTINCT
?About
?see
WHERE
{
?x
a
?type
.
?type
tmdm:topic-‐name
?About
.
?type
rdfs:seeAlso
?see
.
}
ORDER
BY
?About
2. Components
of
a
Query
PREFIX
rdfs:
<hGp://www.w3.org/2000/01/rdf-‐schema#>
Shortcuts
(op5onal)
PREFIX
tmdm:
<hGp://psi.topicmaps.org/iso13250/model/>
SELECT
DISTINCT
?About
?see
Select
variables
WHERE
{
?x
a
?type
.
?type
tmdm:topic-‐name
?About
.
What
interests
you?
?type
rdfs:seeAlso
?see
.
}
ORDER
BY
?About
Solu5on
modifier
(op5onal)
3. Components
of
a
Query
PREFIX
rdfs:
<hGp://www.w3.org/2000/01/rdf-‐schema#>
Shortcuts
(op5onal)
PREFIX
tmdm:
<hGp://psi.topicmaps.org/iso13250/model/>
CONSTRUCT
{
?x
rdfs:seeAlso
?see
.
}
Construct
result
WHERE
{
?x
a
?type
.
?type
tmdm:topic-‐name
?About
.
What
interests
you?
?type
rdfs:seeAlso
?see
.
}
4. General
paGern
SUBJECT
PREDICATE
OBJECT
.
Find
all
topics
?x
and
their
?type
.
For
all
?types
find
their
topic-‐name
?About
.
For
all
?types
find
where
you
can
?see
them
.
?x
a
?type
.
?type
tmdm:topic-‐name
?About
.
?type
rdfs:seeAlso
?see
.
5. General
paGern
SUBJECT
PREDICATE
OBJECT
.
Find
all
topics
?x
and
their
?type
.
For
all
?types
find
their
topic-‐name
?About
.
For
all
?types
find
where
you
can
?see
them
.
SELECT
?About
?see
Query
City
hGp://example.com/wiki/City
Result
Kingdom
hGp://example.com/wiki/Kingdom
6. Using
SPARQL
to
configure
RDF
EXPORT
Find
all
topics
?x
and
their
?type
.
For
all
?types
find
their
topic-‐name
?About
.
For
all
?types
find
where
you
can
?see
them
.
CONSTRUCT
{
?x
rdfs:seeAlso
?see
.
}
Query
<hDp://paris.com>
rdfs:seeAlso
<hDp://example.com/wiki/City>
.
<hDp://denmark.com>
rdfs:seeAlso
<hDp://example.com/wiki/Kingdom>
.
Result
7. Rules
of
thumb
to
make
your
Topic
Maps
fly
as
Linked
Open
Data
Use
Locators
that
yield
machine
readable
informabon
when
dereferenced.
Reuse
exisbng
vocabularies
whenever
possible.
In
case
you
have
to
come
up
with
your
own
vocabulary:
publish
its
meaning,
in
a
machine-‐readable
way,
at
a
place
where
it
can
be
found
by
a
machine.
hDp://maiana.topicmapslab.de
hDp://code.google.com/p/sesametm
Arnim
Bleier
(bleier@informabk.uni-‐leipzig.de)