How to test RDF with your RDF schema

I use the Jena framework to manage RDF files, but I cannot find a way to test RDF with your corresponding RDFSchema. I try this method below:

Model mod1 = new ModelMem(); Model modSchema = new ModelMem(); String baseURI = "http://iec.ch/TC57/2007/network"; String rdfPath = "file:D:\\modelo.rdf"; InputStream model = FileManager.get().open(rdfPath); String rdfPathSchema = "file:D:\\Schema.rdf"; InputStream modelSchema = FileManager.get().open(rdfPathSchema); mod1.read(model, baseURI, "RDF/XML-ABBREV"); modSchema.read(modelSchema,baseURI, "RDF/XML-ABBREV"); InfModel infmodel = ModelFactory.createRDFSModel(mod1, modSchema); ValidityReport validity = infmodel.validate(); return validity.isValid(); 

But it always returns true.

+4
source share
3 answers

I found a solution to validate RDF using the RDF schema. There is a tool called CIMValidation. We can use this in a java application, just add .jar to the build path and use the RDFSValidator class. Thanks for the answer.

0
source

Are you sure that this does not always return the truth simply because all the inputs you tried are valid? Have you tried to create input that is clearly invalid with respect to the circuit and tested it?

Regardless of the schema, RDF is not a strict schema just like an XML schema, you can take a look at Jena Eyeball , which is another Jena-based tool for checking RDF, although it’s not sure that it will do what you want.

If you still have problems, try talking about the Jena mailing list - users@jena.apache.org

Edit

Note that validation will only return false if you used something in a way that is incompatible with the schema. Typos and other user errors that create data that may be considered invalid may be fully compatible with the RDF Schema.

For example, suppose you have a simple RDF schema:

 :ValidType a rdfs:Class . :property a rdf:Property ; rdfs:domain :ValidType . 

So, this diagram claims that you have one class and a property that has the domain of this class.

Then the user makes a typo and includes the following data:

 :subj a :InvalidType . 

This is not in itself incompatible, because RDF has an open world speculation. Claiming that something is of a type not covered by your RDF schema does not invalidate the validation, from the point of view of validation this is simply false information.

However, if the user then stated that :subj used your specific property as follows:

 :subj a :InvalidType ; :property "value" . 

Validation should now return false, because the data will not be compatible with the schema, you indicated that :property has only the domain :ValidType , but it was used with a resource like :InvalidType , so this is inconsistent, and the check should fail.

+1
source

Not a strict solution using Jena or through RDFS, but the ICV Pellet Capability information (ported to Stardog, described here ) may be useful. But, as Rob says, it really comes down to an open and closed world, it makes it a little complicated.

+1
source

Source: https://habr.com/ru/post/1440845/


All Articles