Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
475 views
in Technique[技术] by (71.8m points)

model - edit uri of existing resource using jena

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?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

Example:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...