MarkLogic 10 Product Documentation
sem.rdfBuilder

sem.rdfBuilder(
   [prefixes as Object?],
   [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 An optional set of prefix mappings.
graph 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

const sem = require("/MarkLogic/semantics.xqy");
const prefixes = {"a": "http://marklogic.com/a"};
const fac = sem.rdfBuilder();
xdmp.apply(fac, "_:person1", "a", "foaf:Person");
	
=>
sem.triple(
  sem.blank("http://marklogic.com/semantics/blank/6198496751368939587"), 
  sem.iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), 
  sem.iri("http://xmlns.com/foaf/0.1/Person"))
    
Powered by MarkLogic Server | Terms of Use | Privacy Policy