Jena TDB assembler syntax

1 introduction

Assembler is a DSL of Jena to specify something to build, models and dataset, for example.

2 examples

Jena Assembler's syntax seems like turtle, here is commonly used prefixes:

@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .

2.1 dataset

// trigger TDB initialization
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
tdb:GraphTDB    rdfs:subClassOf  ja:Model      .

// specification of the TDB dataset
<#dataset> rdf:type tdb:DatasetTDB ;
    tdb:location "DB" ;// location, relative to CWD
    .

<#dataset> rdf:type tdb:DatasetTDB ;
    tdb:location "DB" ;
    // set the default graph for query is the union of named graphs
    tdb:unionDefaultGraph true ;
    .

2.2 graph

It's for the purpose of working with a single graph in TDB's RDF dataset.

the default graph

[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
<#dataset> rdf:type tdb:DatasetTDB ;
    tdb:location "DB" ;

<#graph> rdf:type tdb:GraphTDB ;
    tdb:dataset <#dataset> .

the named graph

<#graphNamed> rdf:type tdb:GraphTDB ;
    tdb:dataset <#dataset> .
    tdb:graphName <http://example/graph1> ;
    .

2.3 mixed datasets

It's for the purpose of a dataset may be composed of different sourced graphs.

[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
tdb:GraphTDB    rdfs:subClassOf  ja:Model .

<#dataset> rdf:type      ja:RDFDataset ;
     ja:defaultGraph <#graph> ;// the default graph
     ja:namedGraph             // the named graph
        [ ja:graphName      <http://example.org/name1> ;
          ja:graph          <#graph2> ] ;
     .

<#graph> rdf:type tdb:GraphTDB ;
    tdb:location "DB" ;
    .

// a graph using external sources
<#graph2> rdf:type ja:MemoryModel ;
     ja:content [ja:externalContent <file:Data/books.n3> ] ;
     .

Note ja:RDFDataset and ja:Model support more settings of datasets and models.

3 related namespaces

ja
com.hp.hpl.jena.assembler.JA(jena-core-2.11.1-sources.jar)

tdb
com.hp.hpl.jena.tdb.assembler.VocabTDB(jena-tdb-1.0.1-sources.jar)

上一篇:Photoshop 打造淡紫色人物特写照片


下一篇:RMAN备份与恢复之删除过期备份