如何在apache jena中加载N-TRIPLE文件? [英] How to load N-TRIPLE file in apache jena?

查看:257
本文介绍了如何在apache jena中加载N-TRIPLE文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对RDF和Jena相当陌生.我想将.nt (N- TRIPLE)文件加载到模型中.我尝试了read(inputStream, "N-TRIPLE"),但没有帮助.

I am quite new to RDF and Jena. I want load a .nt (N- TRIPLE) file to a model. I have tried read(inputStream, "N-TRIPLE") but did not help.

它抛出

org.apache.jena.riot.RiotException: Element or attribute do not match QName production: QName::=(NCName':')?NCName.

有人可以指出我的错吗?

Can anyone point me out what is wrong?

这是我尝试加载的N-TRiple文件的链接: http://dbpedia. org/data/Berlin.ntriples

Here is the link for the N-TRiple file which I tried to load : http://dbpedia.org/data/Berlin.ntriples

推荐答案

read(inputStream, string)使用字符串参数作为基本URI,而不是语法语言.它正在尝试使用默认的RDF/XML.检查Javadoc中的Model#read(InputStream输入,字符串基数,字符串lang)获取更多信息.

read(inputStream, string) uses the string argument as the base URI, not the syntax language. It's trying the default, which is RDF/XML. Check the javadoc for Model#read(InputStream in, String base) and Model#read(InputStream in, String base, String lang) for more information.

model.read(inputStream, null, "N-TRIPLES") ;

RDFDataMgr.read(model, inputStream, LANG.NTRIPLES) ;

如果您只是从文件(或URL)打开流,那么Apache Jena会整理出详细信息.例如,

If you are just opening the stream from a file (or URL) then Apache Jena will sort out the details. E.g.,

RDFDataMgr.read(model, "file:///myfile.nt") ;

有各种相关的操作.有关模型 RDFDataMgr .

There are various related operations. See the javadoc for Model and RDFDataMgr.

这篇关于如何在apache jena中加载N-TRIPLE文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆