rdf - Jena: property name cannot be resolved to a variable? -
i'm using jena query ontology, , i'm following step 8: querying model of this tutorial. rdf file vc-db-1.rdf being queried here generated step 3: writing rdf , shown below:
<rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#" > <rdf:description rdf:nodeid="a0"> <vcard:family>smith</vcard:family> <vcard:given>john</vcard:given> </rdf:description> <rdf:description rdf:about="http://somewhere/johnsmith"> <vcard:n rdf:nodeid="a0"/> <vcard:fn>john smith</vcard:fn> </rdf:description> </rdf:rdf> the sample code tutorial 7 , can downloaded here.
i noticed in line
resiterator iter = model.listresourceswithproperty(vcard.fn); vcard.fn property name rdf, not defined variable in code. however, can recognized here , code runs without problem.
but not case own rdf file. created ontology pottery.owl protege , saved in rdf/xml language. file content followed:
<?xml version="1.0"?> <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#" xmlns:xsp="http://www.owl-ontologies.com/2005/08/07/xsp.owl#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:xsd="http://www.w3.org/2001/xmlschema#" xmlns:swrl="http://www.w3.org/2003/11/swrl#" xmlns="http://www.owl-ontologies.com/ontology1369190090.owl#" xmlns:swrlb="http://www.w3.org/2003/11/swrlb#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base="http://www.owl-ontologies.com/ontology1369190090.owl" > <rdf:description rdf:about=""> <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ontology"/> </rdf:description> <rdf:description rdf:about="#pottery"> <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#class"/> </rdf:description> <rdf:description rdf:about="#pottery_instance_1"> <rdf:type rdf:resource="#pottery"/> <pottery.colors rdf:datatype="http://www.w3.org/2001/xmlschema#string">blue</pottery.colors> </rdf:description> <rdf:description rdf:about="#pottery.colors"> <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#datatypeproperty"/> <rdfs:range rdf:resource="http://www.w3.org/2001/xmlschema#string"/> <rdfs:domain rdf:resource="#pottery"/> </rdf:description> </rdf:rdf> <!-- created protege (with owl plugin 3.4.8, build 629) http://protege.stanford.edu --> the ontology contains class pottery, instance pottery_instance_1, , datatype property pottery.colors.
and modified these lines in original code:
static final string inputfilename = "pottery.owl"; // ... resiterator iter = model.listresourceswithproperty(pottery.colors); // ... system.out.println(" " + iter.nextresource() .getproperty(pottery.colors) .getstring()); this time got error "pottery cannot resolved variable."
what's trick here? have difference between formats of 2 rdfs? or else? thank you.
vcard java class define in package com.hp.hpl.jena.vocabulary. contains java constants items in (now, old) vcard vocabulary.
if want generate own class ontology, @ schemagen application shipped jena.
Comments
Post a Comment