Jena TDB Assembler
TDB Assembler
Assemblers (装配器) 是Jena中用于描述将要构建的对象(通常是模型和数据集 models & datasets)的一种通用机制。例如, Fuseki 严重依赖使用 Assemblers 来描述模型和数据集.
SPARQL 查询是在RDF数据集上操作的。RDF 数据集由一个未命名的默认图( a unnamed, default graph) 和 0个或多个命名图(named graphs)构成。
将数据描述存储在一个文件中,意味着应用程序工作时依赖的数据可以随时改变而不需要修改程序代码。
Dataset
This is needed for use in Fuseki.
可以使用一个装配文件来构造一个数据集:
@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#> .
[] ja:loadClass "org.apache.jena.tdb.TDB" .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "DB" ;
.
一个位置只能存储一个数据集。 (filing system directory).
第一部分声明了后面使用的前缀:
@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#> .
紧接着是一条加载TDB的陈述(a statement). TDB 在加载时会自动初始化. 但TDB的 jar文件必须在 Java 的classpath目录下.
对于机器来说,此陈述在本文件中的顺序并不影响其功能,因为 jena 的装配文件系统( assembler system)会在尝试装配任何对象之前,先检查所有的 ja:loadClass 陈述,。将此陈述放在文件的前面,是为了帮助使用者阅读文件.
[] ja:loadClass "org.apache.jena.tdb.TDB" .
最后是一个关于TDB数据集自身的描述:
<#graph> rdf:type tdb:DatasetTDB ;
tdb:location "DB" ;
属性 tdb:location 将文件名作为一个字符串. 它相对于应用程序当前的工作目录, 而与 assembler 文件位置无关.
通过观察 tdb:GraphDataset的一个主语(subject)可以获得数据集的描述。若在一个文件中定义了多个 graph,应用程序必须明确指定使用哪一个描述( description).
Union Default Graph
一个 assembler 可以指明用于查询的默认图(default graph )是多个命名图的集合(union of the named graphs)。通过加入 tdb:unionDefaultGraph可以实现此功能.
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "DB" ;
tdb:unionDefaultGraph true ;
.
Graph
TDB 总是将数据存储在一个 RDF 数据集中. 可以只使用数据集中的一个图. 通常的做法是使用数据集中的默认图。
TDB数据集中一个单一的图可以采用下述描述:
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
[] ja:loadClass "org.apache.jena.tdb.TDB" .
# 声明一个数据集,并指明其位置
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "DB" ;
# 声明一个图,并指明其数据集
<#graph> rdf:type tdb:GraphTDB ;
tdb:dataset <#dataset> .
某位置下的数据集中的一个特定的命名图可以这样装配:
<#graphNamed> rdf:type tdb:GraphTDB ;
tdb:dataset <#dataset> .
tdb:graphName <http://example/graph1> ;
.
Mixed Datasets
可以使用不同存储子系统支持的图来创建数据集,尽管此时查询不一定高效. 要在数据集中包含命名图,请使用下面的词汇:
@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#> .
[] ja:loadClass "org.apache.jena.tdb.TDB" .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
# A dataset of one TDB-backed graph as the default graph and
# an in-memory graph as a named graph.
<#dataset> rdf:type ja:RDFDataset ;
ja:defaultGraph <#graph> ;
ja:namedGraph
[ ja:graphName <http://example.org/name1> ;
ja:graph <#graph2> ] ;
.
<#graph> rdf:type tdb:GraphTDB ;
tdb:location "DB" ;
.
<#graph2> rdf:type ja:MemoryModel ;
ja:content [ja:externalContent <file:Data/books.n3> ] ;
.
注意,此处我们增加了一些内容:
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
这提供了与复杂模型设置(如推理机)的集成。
RDFS
一些定义
@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#> .
tdb:Dataset a rdfs:Class .
tdb:GraphTDB a rdfs:Class .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
# tdb:location 是一个 rdf:Property
# 定义域(domain,subject)是tdb:Dataset 或 tdb:GraphTDB
# 值域(range,object)是简单文本值
tdb:location a rdf:Property ;
# domain is tdb:Dataset or tdb:GraphTDB
# The range is simple literal
.
tdb:unionDefaultGraph a rdf:Property ;
rdfs:domain tdb:Dataset ;
# The range is xsd:boolean
.
tdb:graphName a rdf:Property ;
rdfs:domain tdb:GraphTDB ;
# range is a URI
.
Jena TDB Assembler的更多相关文章
- Jena TDB assembler syntax
1 introduction Assembler is a DSL of Jena to specify something to build, models and dataset, for exa ...
- Jena TDB 102
1 Introduction TDB is a RDF storage of Jena. official guarantees and limitations TDB support full ra ...
- Jena TDB 101 Java API without Assembler
Update on 2015/05/12 ongoing tutorials site on https://github.com/zhoujiagen/semanticWebTutorialUsin ...
- 【转载】Apache Jena TDB CRUD operations
Apache Jena TDB CRUD operations June 11, 2015 by maltesander http://tutorial-academy.com/apache-jena ...
- 导入本体到Jena TDB数据库
本体的存储方法或称本体持久化,大致分为基于内存的方式.基于文件的方式.基于数据库的方式和专门的管理工具方式4种(傅柱等, 2013).其中,基于数据库的方式又有基于关系数据库.基于面向对象数据库.基于 ...
- Outline of Apache Jena Notes
1 description 这篇是语义网应用框架Apache Jena学习记录的索引. 初始动机见Apache Jena - A Bootstrap 2 Content 内容组织基本上遵循Jena首页 ...
- Jena Fuseki 101
前言 正如其承诺的那样 Expose your triples as a SPARQL end-point accessible over HTTP. Fuseki provides REST-sty ...
- Jena Fuseki 102
Version Fuseki v1 Fuseki v2 since Jena 2.13.0 Both v1 and v2 are active and maintained.[2015/06/29] ...
- Apache jena SPARQL endpoint及推理
一.Apache Jena简介 Apache Jena(后文简称Jena),是一个开源的Java语义网框架(open source Semantic Web Framework for Java),用 ...
随机推荐
- 使用axis2的wsdl2java把wsdl生成java文件
原文地址:http://blog.csdn.net/walkcode/article/details/7661674 有时在我们的开发中可能会有这种情况就是你要使用webservice但是对方没有给你 ...
- vs2015 去除 git 源代码 绑定,改成向tfs添加源码管理
除了下文的方法是将源码管理从git改成tfs之外,还要做以下几步即可 向tfs添加源码 打开源码管理(管理连接),双击打开你要向其中添加的tfs连接 选中该解决方案,右键 将解决方案添加到源码管理 嵌 ...
- win10的坑之wifi找不到
安装了win10一周以来,win10的坑太多太多,微软搞什么pc/mobile二合一,真是脑残行为. 首先是usb设备无缘无故找不到,据说是和杀毒软件/防火墙有关,后来是关掉了windows defe ...
- Jade模板引擎使用详解
在 Express 中调用 jade 模板引擎 jade 变量调用 if 判断 循环 Case 选择 在模板中调用其他语言 可重用的 jade 块 (Mixins) 模板包含 (Includes) 模 ...
- onmouseenter和onmouseleave的兼容性问题
<div onmouseenter="displayMyCon($(this))" onmouseleave="hideMyCon(event,$(this))&q ...
- Linux系统查看系统硬件配置信息
1.查看CPU信息 # 查看cpu负载 uptime # cpu使用率 (没有sar 则yum -y install sysstat) sar top bn1 |grep %Cpu # 每个cpu使用 ...
- 简单工厂法( Factory Method)
工厂方法 (Factory Method) Define an interface for creating an object ,but let subclasses decide which cl ...
- 深入分析Java Web技术内幕 修订版 pdf
百度网盘:http://pan.baidu.com/s/1slHCCw9
- Bogart gGrid.vb
Namespace BogartMis.Cls Public Class gGrid '設定表格控的列標題的別名 '說明:strItem字符串的格式為"01,02,03,04,05" ...
- 搭建 yum 仓库
翻译来自:https://wiki.centos.org/HowTos/CreateLocalRepos 本地仓库 http 仓库 测试 Steps: 1.把rpm包放在一个目录中.可以根据需要在该目 ...