DB.DBA.TTLP — parses TTL (TURTLE or N3 resource) and places its triples into DB.DBA.RDF_QUAD.


DB.DBA.TTLP ( in strg any ,
  in base varchar ,
  in graph varchar ,
  in flags integer );


Parses TTL (TURTLE or N3 resource) and places its triples into DB.DBA.RDF_QUAD.



text of the resource


base IRI to resolve relative IRIs to absolute


target graph IRI, parsed triples will appear in that graph.


bitmask of parsing flags. Permits some sorts of syntax errors in resource. Default is 0, meaning no permitted deviations from the spec. Other supported bits are:

   1 - Single quoted and double quoted strings may with newlines.
   2 - Allows bnode predicates (but SPARQL processor may ignore them!).
   4 - Allows variables, but triples with variables are ignored.
   8 - Allows literal subjects, but triples with them are ignored.
  16 - Allows '/', '#', '%' and '+' in local part of QName ("Qname with path")
  32 - Allows invalid symbols between '<' and '>', i.e. in relative IRIs.
  64 - Relax TURTLE syntax to include popular violations.
 128 - Try to recover from lexical errors as much as it is possible.
 256 - Allows TriG syntax, thus loading data in more than one graph.
 512 - Allows loading N-quad dataset files with and optional context value to indicate provenance as detailed.
8192 - Enables searching for Turtle within the string.
<ulink url="">here</ulink>.

Return Types

The return value is not specified and may be changed in future versions.


Example 24.266. 

For loading a file of any greater length, it is most practical to use the file_to_string_output function.

It is important the file to be accessible for the Virtuoso server. You need to have set properly the DirsAllowed parameter value in section [Parameters] of the Virtuoso database INI file. For example on Windows it could be:

virtuoso.ini file:
DirsAllowed =  .\tmp

So in the example the file you want to import from, should be in the tmp folder or in its subfolder. Note that this example folder is a subfolder of the Virtuoso Server working directory.

Sample Example 1

SQL> ttlp (file_to_string_output ('.\tmp\data.ttl'), '', 'http://my_graph', 0);

Forth item in record of NQuad format is optional. If present then it is used as a graph. If missed then the default graph is used. The purpose is to make SPARQL dataset serialization possible in a "natural" way: the content of default graph is written without any graph name specified whereas the content of named graphs is written with fouth field in place. Similarly, TriG uses default graph for triples outside graph blocks. In all these cases, base IRI is used to resolve all relative IRIs of the document, no matter what is the destination graph. Here is a simple example:

Sample Example 2 Suppose we have the simple nquad.nq file:

<> <> "W3C Standards and Technical Reports" <> .
<> <> <> <> .
<> <> <> <> .
<> <> "Tim Berners-Lee's FOAF file" <> .
<> <> <> <> .
<> <> <> <> .
<> <> <> <> .
<> <> <> <> .
<> <> <> <> .
<> <> "Coralie Mercier" <> .

Load the file:

SQL>DB.DBA.TTLP (file_to_string_output ('./nquad.nq'), '', '', 512);
Done. -- 48 msec.

Select all triples from the graph with URI the fourth provenance URI from the NQuad file i.e.: <>:

 SQL> sparql select * from <> where {?s ?p ?o};
 s                                               p                                                  o
 VARCHAR                                         VARCHAR                                            VARCHAR
 ________________________________________________              W3C Standards and Technical Reports                 Tim Berners-Lee's FOAF file                                              Coralie Mercier

 10 Rows. -- 7 msec.