X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=doc%2Fsparql.xml;h=9daac588298ac4f40d8b2a749692f8b9ea6d4536;hb=ab121ed083cfa1b57dd76d30da92bbebe656f226;hp=838dce1cb4b52dd1340bdf0c12fe860cdc4a62c7;hpb=fd951f5b39fc73d6f4d97b93965ec1f3b6d9407b;p=mp-sparql-moved-to-github.git
diff --git a/doc/sparql.xml b/doc/sparql.xml
index 838dce1..9daac58 100644
--- a/doc/sparql.xml
+++ b/doc/sparql.xml
@@ -29,7 +29,10 @@
Configuration consists of one or more db elements. Each db element
describes how to access a specific database. The db element takes
attributes name of Z39.50 database (path) and
- HTTP access point of triplestore (uri). Each
+ HTTP access point of triplestore (uri).
+ Optionally, the schema for the database may be given with attribute
+ schema.
+ Each
db element takes these elements:
Configurable values:
@@ -41,12 +44,11 @@
- <field/>
+ <form/>
- Optional section for controlling what data rows are selected in the
- SPARQL statement and how they are mapped to the output document, all
- variables (\*) are selected when none is provided.
+ SPARQL Query formulation selection. Should start with one of the
+ query forms: SELECT or CONSTRUCT.
@@ -68,13 +70,33 @@
Section used to declare RPN use attribute strings (indexes) and map
them to BIBFRAME graph patterns.
Items in this section are expanded during RPN query processing and
- placeholders (%s, %d) are substituted with query terms.
+ placeholders (%s, %d,
+ %t) are substituted with query terms.
To map a given CQL index (e.g the default keyword index) into
multiple entity properties, SPARQL constructs like
`OPTIONAL` or `UNION` could be used.
+ <present type="attribute"/>
+
+
+ Section used to declare retrieval for a given element-set
+ (SRU schema). The CDATA is SPARQL where %u holds
+ the URI of the record. This can be used to construct the resulting
+ record.
+
+
+
+ <modifier/>
+
+
+ Optional section that allows you to add solution sequences or
+ modifiers.
+
+
+
+
@@ -87,16 +109,17 @@
- EXAMPLES
+ EXAMPLE
Configuration for database "Default" that allows searching works. Only
the field (use attribute) "bf.wtitle" is supported.
-
- rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns
+
bf: http://bibframe.org/vocab/
- ?work ?wtitle
+
?work a bf:Work
?work bf:workTitle ?wt
?wt bf:titleValue ?wtitle
@@ -105,9 +128,120 @@
]]>
+ The matching is done by a simple case-sensitive substring match. There is
+ no deduplication, so if a work has two titles, we get two rows.
+ EXAMPLE
+
+ A more complex configuration for database "work". This could be included in
+ the same filter section as the "Default" db above.
+
+ bf: http://bibframe.org/vocab/
+
+ ?work a bf:Work
+
+ OPTIONAL {
+ ?work bf:workTitle ?wt .
+ ?wt bf:titleValue ?wtitle }
+
+ OPTIONAL {
+ ?work bf:creator ?creator .
+ ?creator bf:label ?creatorlabel }
+
+ OPTIONAL {
+ ?work bf:subject ?subject .
+ ?subject bf:label ?subjectlabel }
+
+ ?wt bf:titleValue %v FILTER(contains(%v, %s))
+ ?creator bf:label %v FILTER(contains(%v, %s))
+ ?subject bf:label %v FILTER(contains(%v, %s))
+ {
+ ?work ?op1 ?child .
+ ?child ?op2 %v FILTER(contains(STR(%v), %s))
+ }
+
+ GROUP BY $work
+
+]]>
+
+
+
+ This returns one row for each work. Titles, authors, and subjects
+ are all optional. If they repeat, the repeated values are concatenated into
+ a single field, separated by semicolons. This is done by the GROUP_DIGEST
+ function that is specific to the Virtuoso back end.
+
+
+ This example supports use attributes 4 (title), 1003 (author), 21 (subject),
+ and 1016 (keyword) which matches any literal in a triplet that refers to the
+ work, so it works for the titleValue in the workTitle, as well as the label
+ in the subject, and what ever else there may be. Like the preceding example,
+ the matching is by a simple substring, case sensitive. A more realistic term
+ matching could be done with regular expressions, at the cost of some readability
+ portability, and performance.
+
+
+
+ EXAMPLE
+
+ Configuration for database "works". This uses CONSTRUCT to produce rdf.
+
+ bf: http://bibframe.org/vocab/
+
+ ?work a bf:Work
+
+ ?work bf:workTitle ?wt
+ ?wt bf:titleValue ?wtitle
+ ?wt bf:titleValue %v FILTER(contains(%v, %s))
+ ?work bf:creator ?creator
+ ?creator bf:label ?creatorlabel
+ ?creator bf:label %v FILTER(contains(%v, %s))
+ ?work bf:subject ?subject
+ ?subject bf:label ?subjectlabel
+ ?subject bf:label %v FILTER(contains(%v, %s))
+
+ ]]>
+
+
+
+
+ EXAMPLE
+
+ Configuration for database "instance". Like "work" above this uses SELECT
+ to return row-based data, this time from the instances. This is not deduplicated,
+ so if an instance has two titles, we get two rows, and if it also has
+ two formats, we get four rows. The DISTINCT in the SELECT
+
+ bf: http://bibframe.org/vocab/
+
+ ?instance a bf:Instance
+ ?instance bf:title ?title
+ ?instance bf:title %v FILTER(contains(%v, %s))
+ ?instance bf:format ?format
+ ?instance bf:format %s
+
+ ]]>
+
+
+
+
+
+
SEE ALSO