使用耶拿编辑现有资源的uri [英] edit uri of existing resource using jena

查看:65
本文介绍了使用耶拿编辑现有资源的uri的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试修改本体模型现有资源的uri.我想创建一个新模型,新资源(包括新的所需uri)并复制旧资源的内容.

I try to modify the uri of an existing resource of a ontology model. I thought of creating a new model, new resource (including the new desired uri) and duplicating the content of the old resource.

通过迭代和添加语句无法正常工作.还有其他解决方法吗?

By iterating and adding the statements doens't work properly. Is there another workaround?

我正在用java和RDF/XML模型中的jena.

I'm working with jena in java and RDF/XML models.

推荐答案

您发现资源是不可变的.您可以使用

As you've found resources are immutable. You can bring about the same effect using ResourceUtils.renameResource(resource, newName). This goes through your model removing statements mentioning the old resource and adding the equivalents with the new, which is as close as you're going to get to a rename.

示例:

Resource renamed = 
  ResourceUtils.renameResource(originalResource, "http://example.com/new");

这篇关于使用耶拿编辑现有资源的uri的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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