I found the problem.
the correct validationRule is this: String validationRule = "[validationRule: (?v rb:validation on()) -> " +
"[(?X rb:violation error('conflict', 'x86 with MacOs', ?X)) <- " +
"(?X rdf:type laico:PersonalComputer) (?X laico:hasArchitecture ?Z) (?Z rdf:type laico:X86)" +
"(?X laico:hasOS ?O) (?O rdf:type laico:MacOS)]]";
"[(?X rb:violation error('conflict', 'x86 with MacOs', ?X)) <- " +
"(?X rdf:type laico:PersonalComputer) (?X laico:hasArchitecture ?Z) (?Z rdf:type laico:X86)" +
"(?X laico:hasOS ?O) (?O rdf:type laico:MacOS)]]";
Because the hasArchitecture property has range in a class, not in a literal.
thanks all.
----- Original Message -----From: José Geraldo CamposSent: Thursday, August 04, 2005 1:07 PMSubject: Re: [jena-dev] Rules for validationHi, made the changes, but it still doesn´t work.Any other idea?I have also made the rule using no prefixes, http://laico.cic.unb.br/laico#PersonalComputer.public static void main(String[] args)
{
OntModel model = MomUtil.leOnto("ruleTest.owl");String validationRule = "[validationRule: (?v rb:validation on()) -> " +
"[(?X rb:violation error('conflict', 'x86 with MacOs', ?X)) <- " +
"(?X rdf:type laico:PersonalComputer) (?X laico:hasArchitecture 'X86')" +
"(?X laico:hasOS ?O) (?O rdf:type laico:MacOS)]]";PrintUtil.registerPrefix("laico", "http://laico.cic.unb.br/laico#");List rules = Rule.parseRules(validationRule);
System.out.println(rules);
Reasoner reasoner = new GenericRuleReasoner(rules);
InfModel inf = ModelFactory.createInfModel(reasoner, model);
ValidityReport validityReport = inf.validate();
if (!validityReport.isValid())
{
System.out.println("Error!!!!");
Iterator iterator = validityReport.getReports();
while (iterator.hasNext())
{
System.out.println(iterator.next());
}
}
}xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns="http://laico.cic.unb.br/laico#" xml:base="http://laico.cic.unb.br/laico#"><?xml version="1.0"?><rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:xsd="http://www.w3.org/2001/XMLSchema#"xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"<owl:Ontology rdf:about=""/><owl:Class rdf:ID="Windows"><rdfs:subClassOf> <owl:Class rdf:ID="OperatingSystem"/> </rdfs:subClassOf> </owl:Class><owl:Class rdf:ID="Mac"><rdfs:subClassOf> <owl:Class rdf:ID="Architecture"/> </rdfs:subClassOf> </owl:Class><owl:Class rdf:ID="MacOS"><rdfs:subClassOf> <owl:Class rdf:about="#OperatingSystem"/> </rdfs:subClassOf> </owl:Class><owl:Class rdf:about="#Architecture"><rdfs:subClassOf> <owl:Class rdf:ID="Recurso"/> </rdfs:subClassOf> </owl:Class><owl:Class rdf:ID="Unix"><rdfs:subClassOf> <owl:Class rdf:about="#OperatingSystem"/> </rdfs:subClassOf> </owl:Class><owl:Class rdf:ID="Solaris"><rdfs:subClassOf> <owl:Class rdf:about="#OperatingSystem"/> </rdfs:subClassOf></owl:Class><owl:Class rdf:about="#OperatingSystem"> <rdfs:subClassOf rdf:resource="#Recurso"/> </owl:Class><owl:Class rdf:ID="PersonalComputer"> <rdfs:subClassOf rdf:resource="#Recurso"/> </owl:Class><owl:Class rdf:ID="X86"> <rdfs:subClassOf rdf:resource="#Architecture"/> </owl:Class><owl:ObjectProperty rdf:ID="hasArchitecture"> <rdfs:range rdf:resource="#Architecture"/> <rdfs:domain rdf:resource="#PersonalComputer"/> <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#TransitiveProperty"/> </owl:ObjectProperty><owl:TransitiveProperty rdf:ID="hasOS"> <rdfs:domain rdf:resource="#PersonalComputer"/> <rdfs:range rdf:resource="#OperatingSystem"/> <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/> </owl:TransitiveProperty><MacOS rdf:ID="MacOS_15"/> <X86 rdf:ID="X86_14"/> <PersonalComputer rdf:ID="PersonalComputer_13"> <hasOS rdf:resource="#MacOS_15"/> <hasArchitecture rdf:resource="#X86_14"/> </PersonalComputer></rdf:RDF><!--Created with Protege (with OWL Plugin 2.1, Build 284) http://protege.stanford.edu -->----- Original Message -----From: "Dave Reynolds" <der@...>To: <jena-dev@yahoogroups.com>Sent: Thursday, August 04, 2005 12:01 PMSubject: Re: [jena-dev] Rules for validationJosé Geraldo Campos wrote:
> Hi Dave, I think I´ve done the rigth thing, but it seems that it didn´t
> work.
> here is the code and the owl i used:
This may not be the only problem but:
> String validationRule = "[validationRule: (?v rb:validation on())
> -> " +
> "[rule1: (?X rb:violation error('x86 with MacOs')) <- " +
> "(?X rdf:type eg:PersonalComputer) (?X eg:hasArchitecture 'X86')" +
> "(?X eg:hasOS ?O) (?O rdf:type eg:MacOS)]]";
You need to match up the "eg:" prefix to the namespace you are using in
your ontology. Either put your rules in a file and use @prefix to declare
it or make an explicit call to PrintUtil to register a prefix for your
namespace and use that in the rules.
Dave