Loading TOC...

MarkLogic 12 EA 1 Product Documentation
sem.rdfLoad

sem.rdfLoad(
   location as String,
   [options as String[]],
   [http-opts as Node?],
   [permissions as Sequence],
   [collections as String[]],
   [quality as xs.int?],
   [forest-ids as (Number|String)[]]
) as Sequence

Summary

This function inserts an RDF document from a specified location into the designated database. It also creates the graph metadata for the graph specified by the "graph=URI" or "override-graph=URI" option. 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 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.
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.
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 An options node as described for the function xdmp:http-get.
permissions Permissions to apply to the inserted documents. When run in an XQuery context, the permissions are a sequence of XML elements (sec:permission). When importing this module into a Server-Side JavaScript context, the permissions are an array of Objects.
collections Additional collections to set on inserted documents. If you use the collections argument when inserting triples, no graph document will be created for these collections.
quality The quality setting for inserted documents.
forest-ids The forest-ids to use for inserted documents.

Required Privileges

http://marklogic.com/xdmp/privileges/xdmp-document-get

Usage Notes

Using additional collections with sem:rdf-load in the context of SPARQL Update can result in undefined behavior.

Example

declareUpdate();
const sem = require("/MarkLogic/semantics.xqy");
 
sem.rdfLoad('C:/data/example.rdf', "rdfxml")
 
 => 
    /triplestore/fbd28af1471b39e9.xml

Example

declareUpdate();
const sem = require("/MarkLogic/semantics.xqy");
	  
sem.rdfLoad(
    'C:/data/books.ttl',
    ["turtle", "graph=http://marklogic.com/semantics/sb/books1/"],
    null,
    xdmp.permission("demo-reader", "read")
    );
    
=>
    /triplestore/fbd28af1471b39e9.xml
// permissions on graph for demo-reader now set to "read" 

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