Question

I'm annotating sensor observations using JENA, RDF and the W3C SSNXG's sensor ontology.

I've created an individual of the SSNXG's SensingDevice using a local namespace for the individual. When I use the individual's URI to create an RDF Resource all I get is a description. However, no rdf:type metadata is created. Must this been done explicitly in code?

I've tried adding this information like this:

OntClass sensingDevice = ssn.getOntClass(NS + "SensingDevice");
Individual ard = ssn.createIndividual(DTPNS + arduino, sensingDevice);
Property type = incomingData.createProperty(RDFNS, "type");
Statement stmt0 = incomingData.createStatement(ardu, type, NS + "SensingDevice");
incomingData.add(stmt0);

However, this results in...

<rdf:Description rdf:about="http://dtp-126.sncs.abdn.ac.uk#CD7514">
    <rdf:type>http://purl.oclc.org/NET/ssnx/ssn#SensingDevice</rdf:type
</rdf:Description>

This doesn't seem to be visible to SPARQL. How do I properly add type metadata?

Was it helpful?

Solution

You were close:

Statement stmt0 = incomingData.createStatement(ardu, type, sensingDevice);

The call you used set rdf:type to the string "http://purl.oclc.org/NET/..." rather than the resource with that URL.

However you can simplify this in two ways. Firstly, Property type already exists in jena as RDF.type. Secondly, you don't need to create a statement, just add to the model directly:

incomingData.add(ard, RDF.type, sendingDevice);

(You can create java constants from ontologies using jena's schemagen, btw)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top