Thanks a lot Dave! -----Original Message----- From: Dave Reynolds [mailto:[email protected]] Sent: Friday, September 16, 2011 11:30 AM To: [email protected] Subject: Re: Assembler question, could really use help before the weekend...
On Fri, 2011-09-16 at 14:56 +0000, David Jordan wrote: > This should be easy… > I have the following assembler file. > > @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . > @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . > @prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> . > @prefix sdb: <http://jena.hpl.hp.com/2007/sdb#> . > @prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> . > > [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" . > tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset . > tdb:GraphTDB rdfs:subClassOf ja:Model . > > <#tdbstore> rdf:type tdb:DatasetTDB ; > tdb:location "DB" ; > . > > <#ICD9> rdf:type tdb:GraphTDB ; > tdb:graphName <http://purl.bioontology.org/ontology/HOM_ICD9/> ; > tdb:dataset <#tdbstore> ; > . > > With the following Java code: > > Model assemblerSpec = FileManager.get().loadModel( "db.ttl" ); > Resource root = assemblerSpec.createResource( > assemblerSpec.expandPrefix( "ICD9" ) ); > Model model = Assembler.general.openModel( root ); > > An exception is thrown on the 3rd line (the assemblerSpec and root are not > null): > Exception in thread "main" > com.hp.hpl.jena.assembler.exceptions.NoSpecificTypeException: the root ICD9 > has no most specific type that is a subclass of ja:Object > at > com.hp.hpl.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.open(AssemblerGroup.java:101) > at > com.hp.hpl.jena.assembler.assemblers.AssemblerGroup$ExpandingAssemblerGroup.open(AssemblerGroup.java:69) > at > com.hp.hpl.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:37) > at > com.hp.hpl.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:34) > at > com.hp.hpl.jena.assembler.assemblers.AssemblerGroup.openModel(AssemblerGroup.java:23) > at com.sas.hls.hoa.ontology.Test.main(Test.java:18) > > > ICD9 is a tdb:GraphTDB, (its most specific type) > tdb:GraphTDB rdfs:subClassOf ja:Model, > ja:Model is a subclass of ja:Object. > > So why would this be occurring? You are not referring to the #ICD9 you think you are :) In your assembler file you have no base specified so the relative URI #ICD9 will become something like: <file:/path/to/assembler/file#ICD9> Whereas the thing you are passing to createResource to generate root is totally different and won't match up. I would suggest using an explicit prefix in your assembler file: @prefix eg: <http://some/useful/URI#> . eg:ICD9 rdf:type tdb:GraphTDB ; tdb:graphName <http://purl.bioontology.org/ontology/HOM_ICD9/> ; tdb:dataset <#tdbstore> ; . Then you can find the root by: Resource root = assemblerSpec.createResource( assemblerSpec.expandPrefix( "eg:ICD9" ) ); Dave
