使用 Apache Jena在 Java 中读取 Turtle 文件的问题

问题描述

我正在尝试从使用 RDF4J 的服务器读取数据。服务器将 TURTLE 内容返回给我的客户端,我正在尝试使用 Apache Jena 将该内容加载到模型中。 Jena 代码非常简单:

 Model model = ModelFactory.createDefaultModel();
 model.read("http://localhost:8080/sim","TURTLE");

代码有效,但模型仍然是空的。

为了解决这个问题,我下载了 HTTP 响应并将其存储在一个名为 example.ttl文件中:

@prefix : <http://ti.rw.fau.de/sim#> .
@prefix time: <http://www.w3.org/2006/time#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://127.0.1.1:8080/sim> :currentIteration 171;
  :currentTime _:node1fag55oecx346 .

_:node1fag55oecx346 time:inDateTime _:node1fag55oecx347 .

_:node1fag55oecx347 time:day 21;
  time:hour 10;
  time:minute 51;
  time:month 5;
  time:second 0.0;
  time:year 2020 .

_:node1fag55oecx346 time:inXSDDateTimeStamp "2020-05-21T10:51:00.000Z"^^xsd:dateTime .

<http://127.0.1.1:8080/sim> :initialTime "2020-05-21T08:00:00Z"^^xsd:dateTime;
  :iterations 1440;
  :sunriseTime _:node1fag55oecx3 .

_:node1fag55oecx3 time:inXSDDateTimeStamp "2020-05-21T06:00:00Z"^^xsd:dateTime .

<http://127.0.1.1:8080/sim> :sunsetTime _:node1fag55oecx4 .

_:node1fag55oecx4 time:inXSDDateTimeStamp "2020-05-21T21:00:00Z"^^xsd:dateTime .

<http://127.0.1.1:8080/sim> :timeslotDuration 60000 .

我现在正在尝试使用以下代码将此文件加载到模型中:

Model model = ModelFactory.createDefaultModel();
model.read("example.ttl");

代码现在“有效”,只是它不创建中间资源(例如“node1fag55oecx346”)。

null inXSDDateTimeStamp  "2020-05-21T06:00:00Z^^http://www.w3.org/2001/XMLSchema#dateTime" .
null inXSDDateTimeStamp  "2020-05-21T21:00:00Z^^http://www.w3.org/2001/XMLSchema#dateTime" .
null year  "2020^^http://www.w3.org/2001/XMLSchema#integer" .
null second  "0.0^^http://www.w3.org/2001/XMLSchema#decimal" .
null month  "5^^http://www.w3.org/2001/XMLSchema#integer" .
null minute  "51^^http://www.w3.org/2001/XMLSchema#integer" .
null hour  "10^^http://www.w3.org/2001/XMLSchema#integer" .
null day  "21^^http://www.w3.org/2001/XMLSchema#integer" .
null inXSDDateTimeStamp  "2020-05-21T10:51:00.000Z^^http://www.w3.org/2001/XMLSchema#dateTime" .
null inDateTime deab4047bb2762830ec586ecdbb6ebf7 .
sim timeslotDuration  "60000^^http://www.w3.org/2001/XMLSchema#integer" .
sim sunsetTime de28266990fc799c9dde46e9a902ff55 .
sim sunriseTime ccdbc2858add8f74d995dffcdcec5a22 .
sim iterations  "1440^^http://www.w3.org/2001/XMLSchema#integer" .
sim initialTime  "2020-05-21T08:00:00Z^^http://www.w3.org/2001/XMLSchema#dateTime" .
sim currentTime 1806f92a70aa91903b714f6ba5bdb68f .
sim currentIteration  "171^^http://www.w3.org/2001/XMLSchema#integer" .

谁能就可能导致问题的原因以及解决方法提出建议?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)