ResourceUtils.renameResource (the Resource class covers both blank nodes and URIs) provides some machinery for this task.

As Charles says, if you have a large amount of data in syntax form, then treating as a text processing problem is well-worth considering.

        Andy


On 27/07/18 18:09, Charles Greer wrote:
It looks like a reasonable solution to me if you have to work with parsed RDF.

It might be higher performance to treat it as a text processing problem... if 
your data is available in ntriples or nquads

you can use regular expressions to accomplish the task.


Charles


Charles Greer
Lead Engineer
MarkLogic Corporation
cgr...@marklogic.com
Cell:  +1 707 318 0442
@grechaw
www.marklogic.com

________________________________
From: Fajar Juang <fajar.ju...@gmail.com>
Sent: Friday, July 27, 2018 10:06:12 AM
To: users@jena.apache.org
Subject: Converting BNode to Resource

Dear all,

I am curious whether there is exist a method in Jena that can conveniently 
“convert” a blank node to a resource.

e.g., suppose that I have a model M1 that contains a blank node _:a which has 
several properties (e.g., rdfs:label, etc),
I would like to execute something like:  M1.convertBNodeToResource(M1, _:a, 
“http://example.org/ns#test <http://example.org/ns#test>”)
to replace BNode _:a with Resource with URI “http://example.org/ns#test 
<http://example.org/ns#test>” (note: the URI in my use case will be taken from 
the BNode label + namespace)

The current (naive) solution that I have is to:
- add statements (?s ?p <http://example.org/ns#test <http://example.org/ns#test>> & 
<http://example.org/ns#test <http://example.org/ns#test>> ?p ?o); and
- remove (?s ?p _:a & _:a ?p ?o) afterwards.

Do you have any suggestions to improve this code?

Thanks in advance for your help!

Best regards,
--
Fajar J. Ekaputra
194/1 Information & Software Engineering Group,
Technische Universität Wien (TUWien).
W: http://juang.id Skype: fajar.juang


Reply via email to