|
|
sem:bnode( ) as sem:blank
|
|
 |
Summary:
This function returns an identifier
for a blank node, allowing the construction of a triple
that refers to a blank node.
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
let $person1 := sem:bnode()
let $person2 := sem:bnode()
let $t1 := sem:triple($person1,
sem:iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
sem:iri("http://xmlns.com/foaf/0.1/Person"))
let $t2 := sem:triple($person2,
sem:iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
sem:iri("http://xmlns.com/foaf/0.1/Person"))
let $t3 := sem:triple($person1,
sem:iri("http://xmlns.com/foaf/0.1/knows"), $person2) return ($t1,$t2,$t3)
=> (: returns identifiers for blank nodes :)
sem:triple(
sem:blank("http://marklogic.com/semantics/blank/3098376212503391907"),
sem:iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
sem:iri("http://xmlns.com/foaf/0.1/Person"))
sem:triple(
sem:blank("http://marklogic.com/semantics/blank/3280643260770921296"),
sem:iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
sem:iri("http://xmlns.com/foaf/0.1/Person"))
sem:triple(
sem:blank("http://marklogic.com/semantics/blank/3098376212503391907"),
sem:iri("http://xmlns.com/foaf/0.1/knows"),
sem:blank("http://marklogic.com/semantics/blank/3280643260770921296"))
|
|
|
|
sem:graph-insert(
|
|
$graphname as sem:iri,
|
|
$triples as sem:triple*,
|
|
[$permissions as element(sec:permission)*],
|
|
[$collections as xs:string*],
|
|
[$quality as xs:int?],
|
|
[$forest-ids as xs:unsignedLong*]
|
| ) as xs:string* |
|
 |
Summary:
This function inserts triples into a named graph,
creating it if necessary. This is an update function
that returns document IDs.
|
Parameters:
$graphname
:
The name of
the graph to insert triples into.
|
$triples
:
The set of
triples to insert.
|
$permissions
(optional):
Permissions to apply to the
inserted documents.
|
$collections
(optional):
Additional collections to set on inserted
documents. When additional collections are set, inserted
triples will exist in multiple graphs.
|
$quality
(optional):
The quality setting to use for inserted
documents.
|
$forest-ids
(optional):
The forest-ids to use when inserting
documents.
|
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
sem:graph-insert(sem:iri('bookgraph'),
sem:triple(sem:iri('urn:isbn:9780080540160'),
sem:iri('http://purl.org/dc/elements/1.1/title'),
"Query XML,XQuery, XPath, and SQL/XML in context"))
=>
/triplestore/2c78915c5854b0f8.xml
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
let $string := '
<urn:isbn:006251587X> <http://purl.org/dc/elements/1.1/creator>
<http://www.w3.org/People/Berners-Lee/card#i> .
<urn:isbn:006251587X> <http://purl.org/dc/elements/1.1/title>
"Weaving the Web" .
<http://www.w3.org/People/Berners-Lee/card#i>
<http://www.w3.org/2006/vcard/title>"Director" .'
let $triples := sem:rdf-parse($string, "ntriple")
let $i := sem:graph-insert(sem:iri("bookgraph"), $triples, (), "smGraph")
return(fn:collection("smGraph")//sem:triple);
=> (: returns triples as nodes :)
<sem:triple xmlns:sem="http://marklogic.com/semantics">
<sem:subject>urn:isbn:006251587X</sem:subject>
<sem:predicate>http://purl.org/dc/elements/1.1/creator</sem:predicate>
<sem:object>http://www.w3.org/People/Berners-Lee/card#i</sem:object>
</sem:triple>
<sem:triple xmlns:sem="http://marklogic.com/semantics">
<sem:subject>urn:isbn:006251587X</sem:subject>
<sem:predicate>http://purl.org/dc/elements/1.1/title</sem:predicate>
<sem:object datatype="http://www.w3.org/2001/XMLSchema#string">
Weaving the Web</sem:object>
</sem:triple>
<sem:triple xmlns:sem="http://marklogic.com/semantics">
<sem:subject>http://www.w3.org/People/Berners-Lee/card#i</sem:subject>
<sem:predicate>http://www.w3.org/2006/vcard/title</sem:predicate>
<sem:object datatype="http://www.w3.org/2001/XMLSchema#string">
Director</sem:object>
</sem:triple>
<sem:triple xmlns:sem="http://marklogic.com/semantics">
<sem:subject>urn:isbn:9780080540160</sem:subject>
<sem:predicate>http://purl.org/dc/elements/1.1/title</sem:predicate>
<sem:object datatype="http://www.w3.org/2001/XMLSchema#string">
Query XML,XQuery, XPath, and SQL/XML in context</sem:object>
</sem:triple>
|
|
|
|
sem:prefixes(
|
|
$prefixdef as xs:string?,
|
|
[$include-common as xs:boolean?]
|
| ) as map:map |
|
 |
Summary:
This function returns a set of prefix mappings for
use with CURIE processing. Calling this function returns the
internal set of default prefixes. The default mappings include
prefixes that are widely used and agreed upon, including
"cc" (Creative Commons), "dc" (Dublin Core),
"dcterms" (Dublin Core Terms), "foaf" (FOAF),
"media" (MediaRSS), "owl" (OWL), "rdf" (RDF),
"rdfs" (RDF Schema), "skos" (SKOS), "vcard" (VCard vocab),
"void" (Vocabulary of Interlinked Datasets),
"xhtml" (XHTML), and "xs" (XML Schema).
|
Parameters:
$prefixdef
:
A string specifying
prefixes in RDFa @prefix format
("prefix: http://base1 prefix2: http://base2").
|
$include-common
(optional):
Whether to include the default set of
mappings. Default is true
|
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
let $prefixes := sem:prefixes("dc: http://purl.org/dc/elements/1.1/
schema: http://schema.org/")
return sem:curie-expand("dc:title")
=> (: returns an IRI :)
http://purl.org/dc/elements/1.1/title
|
|
|
|
sem:rdf-builder(
|
|
[$prefixes as map:map?],
|
|
[$graph as sem:iri?]
|
| ) as function(item(),item(),item()) as sem:triple |
|
 |
Summary:
This function returns a function that builds triples
from CURIE and blank node syntax. The resulting function takes
three string arguments, representing subject, predicate,
and object respectively, which returns a sem:triple object
using the graph and prefix mappings passed in to the call to
sem:rdf-builder.
Blank nodes specified with a leading underscore (_) will
be assigned blank node identifiers, and will maintain that
identity across multiple invocations; for example,
"_:person1" will refer to the same node as a later
invocation that also mentions "_:person1". In the
predicate position, the special value of "a" will be
interpreted as the same as "rdf:type".
|
Parameters:
$prefixes
(optional):
An
optional set of prefix mappings.
|
$graph
(optional):
The graph
value in which to place triples. Defaults to
"http://marklogic.com/semantics#default-graph".
|
|
Usage Notes:
If you pass in a string to sem:rdf-builder, it will be
interpreted as a CURIE. If you want it to be interpreted as an IRI,
then cast the string to an IRI using sem:iri.
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
let $fac := sem:rdf-builder()
let $triple := $fac("foaf:person1", "foaf:knows", "foaf:person2")
return <result>{$triple}</result>
=>
<result>
<sem:triple xmlns:sem="http://marklogic.com/semantics">
<sem:subject>http://xmlns.com/foaf/0.1/person1</sem:subject>
<sem:predicate>http://xmlns.com/foaf/0.1/knows</sem:predicate>
<sem:object>http://xmlns.com/foaf/0.1/person2</sem:object>
</sem:triple>
</result>
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
let $fac := sem:rdf-builder()
let $t1 := $fac("_:person1", "a", "foaf:Person")
let $t2 := $fac("_:person2", "a", "foaf:Person")
let $t3 := $fac("_:person1", "foaf:knows", "_:person2")
return ($t1,$t2,$t3)
=>
sem:triple(
sem:blank("http://marklogic.com/semantics/blank/3655782280846814211"),
sem:iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
sem:iri("http://xmlns.com/foaf/0.1/Person"))
sem:triple(
sem:blank("http://marklogic.com/semantics/blank/1129346327653055324"),
sem:iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
sem:iri("http://xmlns.com/foaf/0.1/Person"))
sem:triple(
sem:blank("http://marklogic.com/semantics/blank/3655782280846814211"),
sem:iri("http://xmlns.com/foaf/0.1/knows"),
sem:blank("http://marklogic.com/semantics/blank/1129346327653055324"))
|
|
|
|
sem:rdf-get(
|
|
$location as xs:string,
|
|
[$options as xs:string*],
|
|
[$http-opts as element()?]
|
| ) as sem:triple* |
|
 |
Summary:
This function returns sem:triples from a specified location.
|
Parameters:
$location
:
The location of the document.
|
$options
(optional):
Parsing options. Valid options include:
-
base=URI
-
A base URI to use during parsing.
-
graph=URI
-
The graph/context value to give to quads with no
explicit graph specified in the data. Cannot be used with
override-graph=URI (or an exception is thrown).
-
override-graph=URI
-
The graph/context value to give to every quad, whether
specified in the data or not. Cannot be used with
graph-URI (or an exception is thrown).
-
ntriple
-
Specify N-Triples format for input.
-
nquad
-
Specify N-Quads format for input (default).
-
turtle
-
Specify Turtle format for input.
-
rdfxml
-
Specify RDF/XML format for input.
-
rdfjson
-
Specify RDF/JSON format for input.
-
n3
-
Specify N3 format for input.
-
trig
-
Specify TriG format for input.
-
repair
-
Specify to repair if possible, or discard individual triples
that do not parse correctly. Otherwise any malformed input
results in an exception.
-
triplexml
-
Specify
sem:triple XML format for input, either a
single sem:triple element or multiple elements
under a root element. If you use the triplexml
option, you cannot specify a graph.
|
$http-opts
(optional):
An options node as described for the function
xdmp:http-get.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-document-get
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
sem:rdf-get('C:/Data/Semantics/example.ttl', "turtle")
=>
sem:triple(sem:iri("http://example.com/ns/data#item342"),
sem:iri("http://example.com/ns/details#shipped"), xs:date("2013-05-20"))
sem:triple(sem:iri("http://example.com/ns/data#item342"),
sem:iri("http://example.com/ns/details#quantity"), 4)
sem:triple(sem:iri("http://example.com/ns/data#item342"),
sem:iri("http://example.com/ns/details#invoiced"), fn:false())
sem:triple(sem:iri("http://example.com/ns/data#item342"),
sem:iri("http://example.com/ns/details#costPerItem"), 10.5)
|
|
|
|
sem:rdf-load(
|
|
$location as xs:string,
|
|
[$options as xs:string*],
|
|
[$http-opts as element()?],
|
|
[$permissions as element(sec:permission)*],
|
|
[$collections as xs:string*],
|
|
[$quality as xs:int?],
|
|
[$forest-ids as xs:unsignedLong*]
|
| ) as xs:string* |
|
 |
Summary:
This function inserts an RDF document from a specified location
into the designated database. This is an update function that
returns the document URIs of inserted documents.
|
Parameters:
$location
:
The location of the input file. If the file is not a
recognized format, an exception is thrown.
|
$options
(optional):
Parsing options: Only one base, or graph, or override-graph
option along with one format option (ntriple, nquad, turtle, trig,
n3, rdfxml, or rdfjson) is allowed. The graph and override-graph
options cannot be used together. Valid options include:
-
base=URI
-
A base URI to use during parsing.
-
graph=URI
-
The graph/context value to give to quads with no
explicit graph specified in the data. Cannot be used with
override-graph=URI (or an exception is thrown).
-
override-graph=URI
-
The graph/context value to give to every quad,
whether specified in the data or not. Cannot be used with
graph=URI (or an exception is thrown).
-
directory=URI
-
The database directory path.
-
ntriple
-
Specify N-Triples format for input.
-
nquad
-
Specify N-Quads format for input (default).
-
turtle
-
Specify Turtle format for input.
-
rdfxml
-
Specify RDF/XML format for input.
-
rdfjson
-
Specify RDF/JSON format for input.
-
n3
-
Specify N3 format for input.
-
trig
-
Specify TriG format for input.
-
repair
-
Specify to repair if possible, or discard individual triples
that do not parse correctly. Otherwise any malformed input
results in an exception.
|
$http-opts
(optional):
An options node as described for the function
xdmp:http-get.
|
$permissions
(optional):
Permissions to apply to the inserted documents.
|
$collections
(optional):
Additional collections to set on inserted documents. When
additional collections are set, inserted triples will exist
in multiple graphs.
|
$quality
(optional):
The quality setting for inserted documents.
|
$forest-ids
(optional):
The forest-ids to use for inserted documents.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/xdmp-document-get
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
sem:rdf-load('C:/data/example.rdf', "rdfxml")
=>
/triplestore/fbd28af1471b39e9.xml
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
sem:rdf-load(
'C:/data/books.ttl',
("turtle", "graph=http://marklogic.com/semantics/sb/books1/"),
(),
xdmp:permission("demo-reader", "read")
)
=>
(: permissions on graph for demo-reader now set to "read" :)
|
|
|
|
sem:rdf-parse(
|
|
$in as item(),
|
|
[$options as xs:string*]
|
| ) as sem:triple* |
|
 |
Summary:
This function returns parsed sem:triple objects
from a text format or XML.
|
Parameters:
$in
:
The source to parse. This must either be a string or a
node.
|
$options
(optional):
Parsing options. Only one each of the base, graph,
override-graph, and format (ntriple, nquad, turtle, rdfxml,
rdfjson, triplexml) options is allowed. Valid options
include:
-
base=URI
-
A base URI to use during parsing.
-
graph=URI
-
The graph/context value to give to quads with no explicit graph
specified in the data. Cannot be used with
override-graph=URI (or an exception is thrown).
-
override-graph=URI
-
The graph/context value to give to every quad, whether
specified in the data or not. Cannot be used with
graph=URI (or an exception is thrown).
-
ntriple
-
Specify N-Triples format for input.
-
nquad
-
Specify N-Quads format for input (default if the $in
paramater is a string).
-
turtle
-
Specify Turtle format for input.
-
rdfxml
-
Specify RDF/XML format for input (default if the $in
parameter is an element).
-
n3
-
Specify N3 format for input.
-
trig
-
Specify TriG format for input.
-
rdfjson
-
Specify RDF/JSON format for input.
-
triplexml
-
Specify
sem:triple XML format for input, either a
single sem:triple element or multiple elements
under a root element. If you use the triplexml
option, you cannot specify a graph.
-
repair
-
Specify to repair if possible, or discard individual
triples that do not parse correctly. Otherwise any
malformed input results in an exception.
|
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
declare namespace dc = "http://purl.org/dc/elements/1.1/";
declare namespace v="http://www.w3.org/2006/vcard/";
sem:rdf-parse(
<rdf:Description rdf:about="urn:isbn:006251587X">
<dc:title>Weaving the Web</dc:title>
<dc:creator rdf:resource="http://www.w3.org/People/Berners-Lee/card#i"/>
</rdf:Description>,
"rdfxml")
=>
sem:triple(
sem:iri("urn:isbn:006251587X"),
sem:iri("http://purl.org/dc/elements/1.1/title"),
"Weaving the Web")
sem:triple(
sem:iri("urn:isbn:006251587X"),
sem:iri("http://purl.org/dc/elements/1.1/creator"),
sem:iri("http://www.w3.org/People/Berners-Lee/card#i"))
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
let $turtle-document := '
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ex: <http://example.org/people/1.0/> .
<http://www.w3.org/TR/rdf-syntax-grammar>
dc:title "RDF/XML Syntax Specification (Revised)" ;
ex:editor [
ex:fullname "Dave Beckett";
ex:homePage <http://purl.org/net/dajobe/>
] .'
return sem:rdf-parse($turtle-document, ("turtle", "repair" )
=>
sem:triple(
sem:iri("http://www.w3.org/TR/rdf-syntax-grammar"),
sem:iri("http://purl.org/dc/elements/1.1/title"),
"RDF/XML Syntax Specification (Revised)")
sem:triple(
sem:iri("http://www.w3.org/TR/rdf-syntax-grammar"),
sem:iri("http://example.org/people/1.0/editor"),
sem:blank("http://marklogic.com/semantics/blank/15118066541381804840"))
sem:triple(
sem:blank("http://marklogic.com/semantics/blank/15118066541381804840"),
sem:iri("http://example.org/people/1.0/fullname"),
"Dave Beckett")
sem:triple(
sem:blank("http://marklogic.com/semantics/blank/15118066541381804840"),
sem:iri("http://example.org/people/1.0/homePage"),
sem:iri("http://purl.org/net/dajobe/"))
|
|
|
|
sem:sparql(
|
|
$sparql as xs:string,
|
|
[$bindings as map:map?],
|
|
[$options as xs:string*],
|
|
[$query as cts:query?],
|
|
[$forest-ids as xs:unsignedLong*]
|
| ) as item()* |
|
 |
Summary:
Executes a SPARQL query against the database.
SPARQL "SELECT" queries return a sequence of map objects, where
each map represents a set of bindings that satisfies the query.
SPARQL "CONSTRUCT" queries return a sequence of sem:triple values.
SPARQL "ASK" queries return a single xs:boolean value.
|
Parameters:
$sparql
:
The SPARQL query to be executed.
|
$bindings
(optional):
A map containing initial values for variables from the query, or the empty sequence if
no query variables are to be initially bound. This is a way to parameterize
the query.
|
$options
(optional):
Options as a sequence of string values. Available options are:
- "base=IRI"
- The initial base IRI for the query.
- "default-graph=IRI"
- Add the named graph specified by the IRI to the default graph for the query.
- "named-graph=IRI"
- Add the named graph specified by the IRI to the list of named graphs available in the query.
- "any"
- Values from any fragment should be included.
- "document"
- Values from document fragments should be included.
- "properties"
- Values from properties fragments should be included.
- "locks"
- Values from locks fragments should be included.
- "checked"
- Word positions should be checked when resolving the query.
- "unchecked"
- Word positions should not be checked when resolving the query.
- "parse-check"
- Parse the query, but don't perform static checks or execute it.
- "prepare"
- Parse and optimize the query, caching the result. No execution is performed.
- "optimize=N"
- Sets the optimization level to use. Levels of 0 (off), 1, and 2 are recognized, with 1
as the default.
|
$query
(optional):
Only include triples in fragments selected by the cts:query.
The triples do not need to match the query, but they must occur in
fragments selected by the query.
The fragments are not filtered to ensure they match the query,
but instead selected in the same manner as
"unfiltered" cts:search operations. If a string
is entered, the string is treated as a cts:word-query of the
specified string.
|
$forest-ids
(optional):
A sequence of IDs of forests to which the SPARQL query will be constrained.
An empty sequence means to search all forests in the database.
The default is ().
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/sem-sparql
|
Usage Notes:
The options parse-check and prepare cannot be
used at the same time.
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
(: load an rdf triple that will match the SPARQL query :)
sem:rdf-insert(
sem:triple(sem:iri("http://www.example.org/dept/108/invoices/20963"),
sem:iri("http://www.example.org/dept/108/invoices/paid"),
"true")) ;
(: returns the URI of the document that contains the triple :)
sem:sparql('
PREFIX inv: <http://www.example.org/dept/108/invoices/>
SELECT ?predicate ?object
WHERE
{ inv:20963 ?predicate ?object }
')
(: returns the matching triple(s) :)
|
Example:
xquery version "1.0-ml";
(:
this query uses the data from the previous query and shows how to
pass bindings in a parameter to sem:sparql
:)
let $params :=
map:new(map:entry("subject",
sem:iri("http://www.example.org/dept/108/invoices/20963")))
return
sem:sparql("
SELECT ?predicate ?object
WHERE
{ ?subject ?predicate ?object } ",
$params)
(: Returns:
[{"predicate":"<http://www.example.org/dept/108/invoices/paid>",
"object":"\"true\""}]
:)
|
|
|
|
sem:sparql-triples(
|
|
$sparql as xs:string,
|
|
$dataset as sem:triple*,
|
|
[$bindings as map:map?],
|
|
[$options as xs:string*]
|
| ) as item()* |
|
 |
Summary:
Executes a SPARQL query against the in-memory triple/quad
data provided.
SPARQL "SELECT" queries return a sequence of map objects, where
each map represents a set of bindings that satisfies the query.
SPARQL "CONSTRUCT" queries return a sequence of sem:triple values.
SPARQL "ASK" queries return a single xs:boolean value.
|
Parameters:
$sparql
:
The SPARQL query to be executed.
|
$dataset
:
A set of triple values representing the dataset for the
SPARQL query.
The results from a SPARQL construct query or call to sem:rdf-parse()
can be used directly as the value for this argument.
|
$bindings
(optional):
A map containing initial values for variables from the query, or the empty sequence if
no query variables are to be initially bound. This is a way to parameterize
the query.
|
$options
(optional):
Options as a sequence of string values. Available options are:
- "base=IRI"
- The initial base IRI for the query.
- "default-graph=IRI"
- Add the named graph specified by the IRI to the default graph for the query.
- "named-graph=IRI"
- Add the named graph specified by the IRI to the list of named graphs available in the query.
- "parse-check"
- Parse the query, but don't perform static checks or execute it.
- "prepare"
- Parse and optimize the query, but don't actually execute it.
- "optimize=N"
- Sets the optimization level to use. Levels of 0 (off), 1, and 2 are recognized, with 0
as the default.
|
|
Required Privilege:
http://marklogic.com/xdmp/privileges/sem-sparql
|
Usage Notes:
The options parse-check and prepare cannot be
used at the same time.
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
(:find a match in the SPARQL query in the provided triples:)
sem:sparql-triples('
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
WHERE { ?p foaf:knows <http://dbpedia.org/resource/person1> .}',
(sem:triple(
sem:iri ("http://dbpedia.org/resource/person3"),
sem:iri("http://xmlns.com/foaf/0.1/knows"),
sem:iri("http://dbpedia.org/resource/person2")),
sem:triple(
sem:iri ("http://dbpedia.org/resource/person2"),
sem:iri("http://xmlns.com/foaf/0.1/knows"),
sem:iri("http://dbpedia.org/resource/person1")),
sem:triple(
sem:iri ("http://dbpedia.org/resource/person4"),
sem:iri("http://xmlns.com/foaf/0.1/knows"),
sem:iri("http://dbpedia.org/resource/person1"))))
=> (: returns any matching results as a solution :)
<http://dbpedia.org/resource/person2>
<http://dbpedia.org/resource/person4>
|
|
|
|
sem:sparql-values(
|
|
$sparql as xs:string,
|
|
$values as map:map*,
|
|
[$options as xs:string*],
|
|
[$query as cts:query?],
|
|
[$forest-ids as xs:unsignedLong*]
|
| ) as map:map* |
|
 |
Summary:
This function executes a SPARQL SELECT query using
passed-in bindings participating as a starting point for
the query.
|
Parameters:
$sparql
:
The SPARQL query to be executed. Must be a SELECT query
form.
|
$values
:
A map containing initial bindings for variables
used in the query. Unlike sem:sparql, a sequence of
bindings is acceptable and will be processed as the
equivalent of an outermost VALUES block in the query.
|
$options
(optional):
Query options. Valid options values include:
-
"base=IRI"
-
The initial base IRI for the query.
-
"default-graph=IRI"
-
Add the named graph specified by the IRI to the default
graph for the query.
-
"named-graph=IRI"
-
Add the named graph specified by the IRI to the list of
named graphs available in the query.
-
"any"
-
Values from any fragment should be included.
-
"document"
-
Values from document fragments should be included.
-
"properties"
-
Values from properties fragments should be included.
-
"locks"
-
Values from locks fragments should be included.
-
"checked"
-
Word positions should be checked when resolving the query.
Default is false.
-
"unchecked"
-
Word positions should not be checked when resolving the query.
This is the default.
-
"optimize=N"
-
Sets the optimization level to use. Levels of 0 (off),
1, and 2 are recognized. Default is 1.
|
$query
(optional):
Only include triples in fragments selected by the cts:query.
The triples do not need to match the query, but they must
occur in fragments selected by the query. The fragments are
not filtered to ensure they match the query, but instead
selected in the same manner as "unfiltered"
cts:search operations.
|
$forest-ids
(optional):
A sequence of IDs of forests to which the SPARQL query will be
constrained. An empty sequence means to search all forests in
the database. The default is ().
|
|
Usage Notes:
Only one of "any", "document", "properties", or "locks" may specified
in the options parameter. If none of "any", "document", "properties",
or "locks" are specified and there is a $query parameter,
then the default is "document". If there is no $query then
the default is "any".
If $values is an empty sequence, nothing is returned.
A variable can be in both bindings and the VALUES clause.
The binding variable must occur in either the SELECT clause
or the triple patterns, otherwise an "Undefined variable"
exception is thrown.
The sem:sparql-values function performs a join
(SPARQL style, natural join) between the bindings returned
from the SELECT expression and the bindings passed in as
an argument, therefore the results reflect this join.
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
let $bindings := (
map:entry("s",
sem:iri("http://example.net/foaf.rdf#Lenovo_T61")),
map:entry("s",
sem:iri("http://example.net/foaf.rdf#Nokia_N80"))
)
return sem:sparql-values("select * where { ?s ?p ?o }", $bindings)
|
|
|
|
sem:triple(
|
|
$subject_or_node as item(),
|
|
[$predicate as xs:anyAtomicType],
|
|
[$object as xs:anyAtomicType],
|
|
[$graph as sem:iri?]
|
| ) as sem:triple |
|
 |
Summary:
Creates a triple object, which represents an RDF triple
containing atomic values representing the subject, predicate, object, and
optionally graph identifier (graph IRI).
|
Parameters:
$subject_or_node
:
The triple's subject as an atomic value, or the whole triple as an
element. If specifying an element as a triple, this function must be used
as a single-parameter version (that is, you cannot specify a triple
in this parameter and also use the other parameters).
|
$predicate
(optional):
The triple's predicate.
|
$object
(optional):
The triple's object.
|
$graph
(optional):
The triple's graph IRI. This parameter is only available if you have
specified a subject, predicate, and object, and is not available if you
have specified an element as a triple in the first parameter.
|
|
Usage Notes:
It is possible to create triples with sem:triple that might not
be valid RDF triples. For example, you can create a triple with a blank
node (sem:bnode()) as a predicate,
even though that is not allowed in RDF. This is because the triples
you can create with sem:triple are more general that what is
allowed in RDF.
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "MarkLogic/semantics.xqy";
sem:triple(sem:iri("subject"), sem:iri("predicate"), "object")
(: Returns the specified triple. :)
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "MarkLogic/semantics.xqy";
sem:triple(
<sem:triple xmlns:sem="http://marklogic.com/semantics">
<sem:subject>subject</sem:subject>
<sem:predicate>predicate</sem:predicate>
<sem:object
datatype="http://www.w3.org/2001/XMLSchema#string">object</sem:object>
</sem:triple>)
(: Returns the specified triple. :)
|
Example:
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "MarkLogic/semantics.xqy";
sem:triple(
<foo>{sem:triple(sem:iri("subject"), sem:iri("predicate"),
"object")}
</foo>/element())
(: Returns the specified triple. :)
|
|
|