You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Rafał Trójczak <t....@gmail.com> on 2014/02/24 19:28:56 UTC
Getting RDF file for one class
Hello Everyone!
I have an ontology with more than 2k classes. What I want to do in Jena is
to get RDF file with all statements concerning one particular class.
Suppose I have something like this:
OntModel model = ...;
model.read(...);
OntClass c1 = model.getOntClass("http://example.com#c1");
In the end I want to get something like this:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Class rdf:about="http://example.com#c1">
<skos:prefLabel>foo1</skos:prefLabel>
...
...
</owl:Class>
</rdf:RDF>
I was looking at Jena javadoc, but I didn't find anything useful. Is there
simple way to do this in Jena?
Best wishes,
Rafał
P.S. Sorry for my poor English.
Re: Getting RDF file for one class
Posted by Ralph Perniciaro <ra...@eagles.usm.edu>.
It is in the documentation, but can be hard to find. Try the following:
Model m = ResourceUtils.reachableClosure(r);
where r is your resource. Now you can export m to rdf.
On Mon, Feb 24, 2014 at 12:28 PM, Rafał Trójczak <t....@gmail.com> wrote:
> Hello Everyone!
>
> I have an ontology with more than 2k classes. What I want to do in Jena is
> to get RDF file with all statements concerning one particular class.
> Suppose I have something like this:
>
>
> OntModel model = ...;
> model.read(...);
> OntClass c1 = model.getOntClass("http://example.com#c1");
>
>
>
> In the end I want to get something like this:
>
>
> <rdf:RDF
> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> xmlns:skos="http://www.w3.org/2004/02/skos/core#"
> xmlns:owl="http://www.w3.org/2002/07/owl#"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
> xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
> <owl:Class rdf:about="http://example.com#c1">
> <skos:prefLabel>foo1</skos:prefLabel>
> ...
> ...
> </owl:Class>
> </rdf:RDF>
>
>
>
> I was looking at Jena javadoc, but I didn't find anything useful. Is there
> simple way to do this in Jena?
>
>
>
> Best wishes,
>
> Rafał
>
>
> P.S. Sorry for my poor English.
>