See the library overview for more information about this project.
xquery version "1.0-ml"; import module namespace sem="http://marklogic.com/semantic" at "semantic.xqy"; 1
The semantic library defines a number of constants, some of which may be useful for queries.
Constant | Description |
---|---|
$sem:O-RDF-CLASS | This constant represents the RDF
Class
object. |
$sem:O-RDF-NIL | This constant represents the RDF
nil
object. |
$sem:P-OWL-INTERSECTION | This constant represents the OWL
intersectionOf
predicate. |
$sem:P-OWL-ON-PROPERTY | This constant represents the OWL
onProperty
predicate. |
$sem:P-RDF-FIRST | This constant represents the RDF
first
predicate. |
$sem:P-RDF-LABEL | This constant represents the RDF
label
predicate. |
$sem:P-RDF-REST | This constant represents the RDF
rest
predicate. |
$sem:P-RDF-SUBCLASS | This constant represents the RDF
subClassOf
predicate. |
$sem:P-RDF-SUBPROPERTY | This constant represents the RDF
subPropertyOf
predicate. |
$sem:P-RDF-TYPE | This constant represents the RDF
type
predicate. |
Name | Parameters | Returns | Description |
---|---|---|---|
sem:object-for-predicate | $p as xs:string+ | xs:string* | This function returns the object values of all tuples that match the supplied predicate values. |
sem:subject-for-predicate | $p as xs:string+ | xs:string* | This function returns the subject values of all tuples that match the supplied predicate values. |
sem:object-for-subject-predicate | $s as xs:string*, $p as xs:string+ |
xs:string* | This function returns the object values of all tuples that match the supplied subject and predicate values. |
sem:subject-for-object-predicate | $o as xs:string*, $p as xs:string+ |
xs:string* | This function returns the subject values of all tuples that match the supplied object and predicate values. |
sem:subject-for-subject-predicate | $s as xs:string*, $p as xs:string+ |
xs:string* | This function returns the subject values of all tuples that match the supplied subject and predicate values. |
sem:object-by-subject-object-predicate | $s as xs:string+, $o as xs:string+, $p as xs:string+ | xs:string* | This function returns the object values of all tuples that match the supplied subject, object, and predicate values. |
sem:subject-by-subject-object-predicate | $s as xs:string+, $o as xs:string+, $p as xs:string+ | xs:string* | This function returns the subject values of all tuples that match the supplied subject, object, and predicate values. |
sem:transitive-closure | $m as map:map, $seeds as xs:string*, $gen as xs:integer, $relation as xs:string, $direction as xs:boolean, $filters as xs:string* |
empty-sequence() |
This function performs transitive closure over an edge type.
This can be used for friend-of-a-friend (FOAF) queries:
see the library overview for an example.
The resulting network is used to populate the supplied map,
which can be serialized using sem:serialize() .
|
sem:serialize | $m as map:map, $max-gen as xs:integer |
item()+ |
This function serializes the network map created by
sem:transitive-closure() .
|
sem:object-predicate-join | $o as xs:string*, $p as xs:string* | element(sem:join)? |
This function returns an XML element
which describes a join on the supplied object and predicate values.
Use this with the
sem:subject-for-join()
and
sem:object-for-join()
functions.
|
sem:predicate-join | $p as xs:string* | element(sem:join)? |
This function returns an XML element
which describes a join on the supplied predicate values.
Use this with the
sem:subject-for-join()
and
sem:object-for-join()
functions.
|
sem:subject-predicate-join | $s as xs:string*, $p as xs:string* | element(sem:join)? |
This function returns an XML element
which describes a join on the supplied subject and predicate values.
Use this with the
sem:subject-for-join()
and
sem:object-for-join()
functions.
|
sem:type-join | $type as xs:string+ | element(sem:join) |
This function returns an XML element
which describes a join on the supplied RDF type values.
This is equivalent to
sem:object-predicate-join($type, $sem:P-RDF-TYPE)
Use this with the
sem:subject-for-join()
and
sem:object-for-join()
functions.
|
sem:object-for-join | $joins as element(sem:join)+ | xs:string* |
This function returns object values
of all tuples matching the supplied
sem:join
elements.
These elements can be generated using the constructors
described above.
|
sem:object-for-join | $seeds as xs:string*, $joins as element(sem:join)* | xs:string* |
This function returns object values
of all tuples matching the supplied
sem:join
elements, starting from the supplied seed values.
These elements can be generated using the constructors
described above.
|
sem:subject-for-join | $joins as element(sem:join)+ | xs:string* |
This function returns subject values
of all tuples matching the supplied
sem:join
elements.
These elements can be generated using the constructors
described above.
|
sem:subject-for-join | $seeds as xs:string*, $joins as element(sem:join)* | xs:string* |
This function returns subject values
of all tuples matching the supplied
sem:join
elements, starting from the supplied seed values.
These elements can be generated using the constructors
described above.
|
sem:owl-on-property | $prop as xs:string* | xs:string* | This function uses the OWL onProperty predicate to find subject values matching the supplied property. |
sem:owl-subclasses | $class as xs:string* | xs:string* | This function expands any available OWL ontology for the supplied class value. |
sem:rdf-subclasses | $class as xs:string* | xs:string* | This function uses the RDF subClassOf predicate to expand the definition of the supplied class. |
sem:rdf-subproperties | $prop as xs:string* | xs:string* | This function uses the RDF subPropertyOf predicate to recursively expand the ancestor properties of the supplied property. |
sem:relate | $a as xs:QName, $b as xs:QName, $a-seed as xs:string*, $b-seed as xs:string*, $join as element(sem:join)* | map:map | This function populates a map representing the co-occurrences of values in the supplied elements ($a and $b), using the supplied seed values and joins. |
sem:relate-join | $a as xs:QName, $b as xs:QName, $a-seed as xs:string*, $b-seed as xs:string*, $join as element(sem:join)* | element(cts:co-occurrence)* | This function returns an XML representation of the co-occurrences of values in the supplied elements ($a and $b), using the supplied seed values and joins. |
sem:uri-for-tuple | $s as xs:string, $p as xs:string, $o as xs:string, $c as xs:string? | xs:string | This function generates a unique document URI from the supplied subject, predicate, object, and (optional) context. |
sem:uri-for-tuple | $t as element(t) | xs:string | This function generates a unique document URI from the supplied tuple element. |
sem:tuple | $s as xs:string, $p as xs:string, $o as xs:string, $c as xs:string? | element(t) | This function creates a tuple element from the supplied subject, predicate, object, and (optional) context. |
sem:tuple-insert-as-property | $s as xs:string, $p as xs:string, $o as xs:string, $c as xs:string? | empty-sequence() | This function inserts a new tuple into the current database, using the supplied subject, predicate, object, and (optional) context. The document URI will be generated automatically. The tuple is inserted as part of an empty document's property fragment. (aka naked properties) |
sem:tuple-insert-as-property | $t as element(t) | empty-sequence() | This function inserts a new tuple into the current database. The tuple must contain children s, o, and p; it may contain a child c. The document URI will be generated automatically. The tuple is inserted as part of an empty document's property fragment. (aka naked properties) |
sem:tuple-insert | $s as xs:string, $p as xs:string, $o as xs:string, $c as xs:string? | empty-sequence() | This function inserts a new tuple into the current database, using the supplied subject, predicate, object, and (optional) context. The document URI will be generated automatically. |
sem:tuple-insert | $t as element(t) | empty-sequence() | This function inserts a new tuple into the current database. The tuple must contain children s, o, and p; it may contain a child c. The document URI will be generated automatically. |
sem:tuples-for-query | $q as cts:query | element(t)* |
This function returns all tuple elements
matching the supplied query.
The query may be generated
using standard
cts:query
constructors.
|
sem:tuples-for-predicate | $p as xs:string+ | element(t)* | This function returns all tuple elements matching the supplied predicate values. |