Loading TOC...

MarkLogic 12 EA 2 Product Documentation
op:pattern

op:pattern(
   $subjects as item()+,
   $predicates as item()+,
   $objects as item()+,
   [$systemCols as map:map*]
) as map:map

Summary

This function builds the parameters for the op:from-triples function. The result is passed to op:from-triples to project rows from the graph of triples. The columns in a pattern become the columns of the row. The literals in a pattern are used to match triples. You should specify at least one literal in each pattern, usually the predicate. Where a column appears in more than one pattern, the matched triples are joined to form the row. You can specify optional triples with a op:join-left-outer with a separate op:from-triples.

Parameters
$subjects One column or one or more literal values, such as the literal returned by a sem:iri call.
$predicates One column or one or more literal values, such as the literal returned by a sem.iri call.
$objects One column or one or more literal values, such as the literal returned by a sem:iri call.
$systemCols Specifies the result of an op:fragment-id-col or op:graph-col function to add columns for the fragment id or graph iri.

Example

xquery version "1.0-ml";

import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";

let $resource := op:prefixer("http://dbpedia.org/resource/")
let $foaf     := op:prefixer("http://xmlns.com/foaf/0.1/")
let $onto     := op:prefixer("http://dbpedia.org/ontology/")
let $person   := op:col("person")

return op:from-triples((
   op:pattern($person, $onto("birthPlace"), $resource("Brooklyn")),
   op:pattern($person, $foaf("name"), op:col("name"))))
   => op:result()
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.