sparql - Create data property XSD:string with Jena -
the problem sounds simple: create data property individual xsd:string in ontology.
i can create properties of xsd:datetime, xsd:float or xsd:int, if use xsd:string, untyped property!
i created minimal example, create ontology 1 class, 1 individual 2 data properties. datetime, works expected , 1 string, has no type in ontology.
i tried jena versions 3.4 , 3.0.1 , have no idea fix it.
package dataproperty; import java.io.fileoutputstream; import org.apache.jena.datatypes.xsd.xsddatatype; import org.apache.jena.ontology.ontmodel; import org.apache.jena.rdf.model.modelfactory; import org.apache.jena.rdf.model.property; import org.apache.jena.rdf.model.resource; import org.apache.jena.rdf.model.resourcefactory; public class dataproperty { public static void main(string[] args) throws exception { ontmodel model = modelfactory.createontologymodel(); string owlpath = "dataprop.owl"; try{ string ns = "http://www.example.org/ontology.owl#"; //create ontology model.createclass(ns+"test"); resource r = model.createresource(ns+"test"); model.createindividual(ns+"indi1", r); r = model.createresource(ns+"indi1"); model.createdatatypeproperty(ns+"name"); model.createdatatypeproperty(ns+"date"); //add data properties property p = model.getproperty(ns+"name"); model.add(r, p, resourcefactory.createtypedliteral("myname", xsddatatype.xsdstring)); p = model.getproperty(ns+"date"); model.add(r, p, resourcefactory.createtypedliteral("2017-08-12t09:03:40", xsddatatype.xsddatetime)); //store ontology fileoutputstream output = null; output = new fileoutputstream(owlpath); model.write(output); }catch (exception e) { system.out.println("error occured: " + e); throw new exception(e.getmessage()); } } }
it not untyped in rdf 1.1 - it's written in short form (better compatibility).
e.g. https://www.w3.org/tr/turtle/ section 2.5.1
"if there no datatype iri , no language tag, datatype xsd:string."
Comments
Post a Comment