You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Dr. Chavdar Ivanov" <ch...@outlook.de> on 2019/10/31 13:36:02 UTC

Navigating to RDF schema extensions

Hello,

I am trying to process RDFS and have trouble how to get to the values from the extensions.

I can iterate using for example
model.listSubjects().next().getRequiredProperty(RDFS.label)
model.listSubjects().next().getLocalName()
model.listSubjects().next().listProperties().next().getResource()

to get labels, etc.


But I need to also get to the extensions. There is example 42 here: https://www.w3.org/TR/rdf-primer/



 <rdf:Property rdf:ID="Breaker.OperatedBy">

   <rdfs:label xml:lang="en">OperatedBy</rdfs:label>

   <rdfs:domain rdf:resource="#Breaker" />

   <rdfs:range rdf:resource="#ProtectionEquipment" />

   <cims:inverseRoleName rdf:resource="#ProtectionEquipment.Operates" />

   <cims:multiplicity rdf:resource="http://www.cim-logic.com/schema/990530#M:0..n" />

   <rdfs:comment>"Circuit breakers may be operated by

       protection relays."</rdfs:comment>

</rdf:Property>



<rdf:Property rdf:ID="ProtectionEquipment.Operates">

   <rdfs:label xml:lang="en">Operates</rdfs:label>

   <rdfs:domain rdf:resource="#ProtectionEquipment" />

   <rdfs:range rdf:resource="#Breaker" />

   <cims:inverseRoleName rdf:resource="#Breaker.OperatedBy" />

   <cims:multiplicity rdf:resource="http://www.cim-logic.com/schema/990530#M:0..n" />

   <rdfs:comment>"Circuit breakers may be operated by

       protection relays."</rdfs:comment>

</rdf:Property>

I would like to know if there is a method that I can use to get the values of cims:inverseRoleName or cims:multiplicity? So that I get #ProtectionEquipment.Operates and http://www.cim-logic.com/schema/990530#M:0..n as an answer

Regards
Chavdar

RE: Navigating to RDF schema extensions

Posted by "Dr. Chavdar Ivanov" <ch...@outlook.de>.
Thank you Lorenz,
I could manage what I wanted now.

Best regards
Chavdar 

-----Original Message-----
From: Lorenz Buehmann <bu...@informatik.uni-leipzig.de> 
Sent: Friday, November 1, 2019 8:01 AM
To: users@jena.apache.org
Subject: Re: Navigating to RDF schema extensions

Not sure if I understand correctly. The "extensions" in the document are most likely not be part of the Jena API in any sense - or at least I don't know about it. So you have to just treat those properties like
|cims:inverseRoleName| as any other plain RDF property - CIM/XML is a
subset of RDF/XML, thus, it can be porccessed like any other RDF in Jena.


The Jena Model class allows for getting anything here via e.g.
listStatements() method, which is the most generic method to get things out of the RDF dataset.

For your example, the subject is |Breaker.OperatedBy |and the predicate is |cims:inverseRoleName| - but you have to provide the full URI and create RDF entities out of it first:


|model.listStatements(model.createResource(SUBJECT_URI),
model.createProperty(PREDICATE_URI), (RDFNode) null);|


which returns an iterator of the statements matching subject and predicate.


or you use |listObjectsOfProperty(Resource s, Property p)| method to get an iterator just of the objects.


On 31.10.19 14:36, Dr. Chavdar Ivanov wrote:
> Hello,
>
> I am trying to process RDFS and have trouble how to get to the values from the extensions.
>
> I can iterate using for example
> model.listSubjects().next().getRequiredProperty(RDFS.label)
> model.listSubjects().next().getLocalName()
> model.listSubjects().next().listProperties().next().getResource()
>
> to get labels, etc.
>
>
> But I need to also get to the extensions. There is example 42 here: 
> https://www.w3.org/TR/rdf-primer/
>
>
>
>  <rdf:Property rdf:ID="Breaker.OperatedBy">
>
>    <rdfs:label xml:lang="en">OperatedBy</rdfs:label>
>
>    <rdfs:domain rdf:resource="#Breaker" />
>
>    <rdfs:range rdf:resource="#ProtectionEquipment" />
>
>    <cims:inverseRoleName rdf:resource="#ProtectionEquipment.Operates" 
> />
>
>    <cims:multiplicity 
> rdf:resource="http://www.cim-logic.com/schema/990530#M:0..n" />
>
>    <rdfs:comment>"Circuit breakers may be operated by
>
>        protection relays."</rdfs:comment>
>
> </rdf:Property>
>
>
>
> <rdf:Property rdf:ID="ProtectionEquipment.Operates">
>
>    <rdfs:label xml:lang="en">Operates</rdfs:label>
>
>    <rdfs:domain rdf:resource="#ProtectionEquipment" />
>
>    <rdfs:range rdf:resource="#Breaker" />
>
>    <cims:inverseRoleName rdf:resource="#Breaker.OperatedBy" />
>
>    <cims:multiplicity 
> rdf:resource="http://www.cim-logic.com/schema/990530#M:0..n" />
>
>    <rdfs:comment>"Circuit breakers may be operated by
>
>        protection relays."</rdfs:comment>
>
> </rdf:Property>
>
> I would like to know if there is a method that I can use to get the 
> values of cims:inverseRoleName or cims:multiplicity? So that I get 
> #ProtectionEquipment.Operates and 
> http://www.cim-logic.com/schema/990530#M:0..n as an answer
>
> Regards
> Chavdar

Re: Navigating to RDF schema extensions

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
Not sure if I understand correctly. The "extensions" in the document are
most likely not be part of the Jena API in any sense - or at least I
don't know about it. So you have to just treat those properties like
|cims:inverseRoleName| as any other plain RDF property - CIM/XML is a
subset of RDF/XML, thus, it can be porccessed like any other RDF in Jena.


The Jena Model class allows for getting anything here via e.g.
listStatements() method, which is the most generic method to get things
out of the RDF dataset.

For your example, the subject is |Breaker.OperatedBy |and the predicate
is |cims:inverseRoleName| - but you have to provide the full URI and
create RDF entities out of it first:


|model.listStatements(model.createResource(SUBJECT_URI),
model.createProperty(PREDICATE_URI), (RDFNode) null);|


which returns an iterator of the statements matching subject and predicate.


or you use |listObjectsOfProperty(Resource s, Property p)| method to get
an iterator just of the objects.


On 31.10.19 14:36, Dr. Chavdar Ivanov wrote:
> Hello,
>
> I am trying to process RDFS and have trouble how to get to the values from the extensions.
>
> I can iterate using for example
> model.listSubjects().next().getRequiredProperty(RDFS.label)
> model.listSubjects().next().getLocalName()
> model.listSubjects().next().listProperties().next().getResource()
>
> to get labels, etc.
>
>
> But I need to also get to the extensions. There is example 42 here: https://www.w3.org/TR/rdf-primer/
>
>
>
>  <rdf:Property rdf:ID="Breaker.OperatedBy">
>
>    <rdfs:label xml:lang="en">OperatedBy</rdfs:label>
>
>    <rdfs:domain rdf:resource="#Breaker" />
>
>    <rdfs:range rdf:resource="#ProtectionEquipment" />
>
>    <cims:inverseRoleName rdf:resource="#ProtectionEquipment.Operates" />
>
>    <cims:multiplicity rdf:resource="http://www.cim-logic.com/schema/990530#M:0..n" />
>
>    <rdfs:comment>"Circuit breakers may be operated by
>
>        protection relays."</rdfs:comment>
>
> </rdf:Property>
>
>
>
> <rdf:Property rdf:ID="ProtectionEquipment.Operates">
>
>    <rdfs:label xml:lang="en">Operates</rdfs:label>
>
>    <rdfs:domain rdf:resource="#ProtectionEquipment" />
>
>    <rdfs:range rdf:resource="#Breaker" />
>
>    <cims:inverseRoleName rdf:resource="#Breaker.OperatedBy" />
>
>    <cims:multiplicity rdf:resource="http://www.cim-logic.com/schema/990530#M:0..n" />
>
>    <rdfs:comment>"Circuit breakers may be operated by
>
>        protection relays."</rdfs:comment>
>
> </rdf:Property>
>
> I would like to know if there is a method that I can use to get the values of cims:inverseRoleName or cims:multiplicity? So that I get #ProtectionEquipment.Operates and http://www.cim-logic.com/schema/990530#M:0..n as an answer
>
> Regards
> Chavdar