微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决使用 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 举报,一经查实,本站将立刻删除。