Search code examples
validationrdfjenardfs

How to validate a RDF with your RDF schema


I'm using the Jena framework to manipulate RDF files, but I can't find a way to validate a RDF with your respective RDFSchema. I'm trying this method bellow:

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.


Solution

  • I found the solution for validate a RDF with a RDF Schema. Exists a tool called CIMValidation. We can use this in a application java, just add the .jar to the buildpath and use the RDFSValidator class. Thanks for all answer.