On 31/07/12 19:37, Jim Karavias wrote:
Hi,
I've been trying to load a dataset using an assembler when starting Fuseki.
I have no trouble loading RDF/XML when specifying external content using
an http: url. Fuseki fails to load n3 data served the same way.
Hi there - there was a bug in determining the syntax. Nothing to do with
> ja:contentEncoding "N3" ;
which (and the documentation is not clear here) only affects inline
string data.
It should have poked around and found the ".n3" to guess the syntax. A
complete system replacement for reading files with proper content
negotiation is in the works but for now I've fixed the in-place code to
work.
The bug is now fixed (in jena-core) and will be in the incorporated into
the overnight build of everything including Fuseki tonight.
Andy
For example, if i use the following assembler, fuseki loads the dataset
just fine:
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix jpk: <http://jpk.iag.com/assembler#> .
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
jpk:root rdf:type ja:RDFDataset ;
ja:defaultGraph jpk:testgraph;
.
jpk:testgraph rdf:type ja:MemoryModel ;
ja:content [
ja:externalContent <http://localhost:8080/test/resources/IDTestModel.rdf
;
];
.
However the following fails with a SAX parser error that I believe
indicates that its still trying to parse RDF/XML when the external content
is N3:
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix jpk: <http://jpk.iag.com/assembler#> .
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
jpk:root rdf:type ja:RDFDataset ;
ja:defaultGraph jpk:testgraph;
.
jpk:testgraph rdf:type ja:MemoryModel ;
ja:content [
ja:contentEncoding "N3" ;
ja:externalContent <http://localhost:8080/test/resources/IDTestModel.n3>
];
.
Exception:
C:\Program Files\jena-fuseki-0.2.1-incubating>java -jar fuseki-server.jar
--update --desc=C:\git-repositories\snap-client\src\test\
resources\IDTestAssembler.ttl /DB
11:15:03 INFO Server :: Dataset from assembler
11:15:03 ERROR RDFDefaultErrorHandler ::
http://localhost:8080/test/resources/IDTestModel.n3(line 1 column 1):
Content is not allowe
d in prolog.
com.hp.hpl.jena.assembler.exceptions.AssemblerException: caught:
org.xml.sax.SAXParseException; systemId: http://localhost:8080/test
/resources/IDTestModel.n3; lineNumber: 1; columnNumber: 1; Content is not
allowed in prolog.
doing:
root: 4243f4d7:138de3f8d93:-7ffe with type:
http://jena.hpl.hp.com/2005/11/Assembler#ContentItem assembler class: class
com.hp.h
pl.jena.assembler.assemblers.ContentAssembler
root: 4243f4d7:138de3f8d93:-7fe8 with type:
http://jena.hpl.hp.com/2005/11/Assembler#Content assembler class: class
com.hp.hpl.j
ena.assembler.assemblers.ContentAssembler
root: http://jpk.iag.com/assembler#testgraph with type:
http://jena.hpl.hp.com/2005/11/Assembler#MemoryModel assembler class: cl
ass com.hp.hpl.jena.assembler.assemblers.MemoryModelAssembler
root: http://jpk.iag.com/assembler#root with type:
http://jena.hpl.hp.com/2005/11/Assembler#RDFDataset assembler class: class
co
m.hp.hpl.jena.sparql.core.assembler.DatasetAssembler
at
com.hp.hpl.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:138)
at
com.hp.hpl.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.open(AssemblerGroup.java:117)
at
com.hp.hpl.jena.assembler.assemblers.AssemblerGroup$ExpandingAssemblerGroup.open(AssemblerGroup.java:81)
at
com.hp.hpl.jena.assembler.assemblers.AssemblerBase.open(AssemblerBase.java:52)
...(omitted)...
at arq.cmdline.CmdArgModule.process(CmdArgModule.java:51)
at arq.cmdline.CmdMain.mainMethod(CmdMain.java:96)
at arq.cmdline.CmdMain.mainRun(CmdMain.java:59)
at arq.cmdline.CmdMain.mainRun(CmdMain.java:46)
at org.apache.jena.fuseki.FusekiCmd.main(FusekiCmd.java:101)
Caused by: com.hp.hpl.jena.shared.JenaException:
org.xml.sax.SAXParseException; systemId:
http://localhost:8080/test/resources/IDTes
tModel.n3; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at
com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler.fatalError(RDFDefaultErrorHandler.java:60)
at
com.hp.hpl.jena.rdf.arp.impl.ARPSaxErrorHandler.fatalError(ARPSaxErrorHandler.java:51)
at
com.hp.hpl.jena.rdf.arp.impl.XMLHandler.warning(XMLHandler.java:211)
at
com.hp.hpl.jena.rdf.arp.impl.XMLHandler.fatalError(XMLHandler.java:241)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown
Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source)
...(omitted) ...
at
com.hp.hpl.jena.assembler.assemblers.ContentAssembler.objectAsContent(ContentAssembler.java:154)
at
com.hp.hpl.jena.assembler.assemblers.ContentAssembler.addExternalContents(ContentAssembler.java:82)
at
com.hp.hpl.jena.assembler.assemblers.ContentAssembler.loadContent(ContentAssembler.java:68)
at
com.hp.hpl.jena.assembler.assemblers.ContentAssembler.open(ContentAssembler.java:44)
at
com.hp.hpl.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:130)
... 36 more
Caused by: org.xml.sax.SAXParseException; systemId:
http://localhost:8080/test/resources/IDTestModel.n3; lineNumber: 1;
columnNumber
: 1; Content is not allowed in prolog.
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source)
... 61 more
I've tried with and without the .n3 extension on the URL. I've also
ensured that the content is being served as "text/n3" from apache.
Here are the first few lines of n3 I'm trying to load:
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix urn: <http://www.iag.com/2012/snap#>.
<urn:1> a <urn:ID>;
<http://www.w3.org/2000/01/rdf-schema#label> "This is the title"@en;
<urn:hasTitle> "this is the title"@en;
<urn:hasDescription> "this is the description"@en;
<urn:hasCreator> <urn:2>;
<urn:hasOrganization> <urn:3>...
Am I using ja:contentEncoding property correctly?
Regards,
Jim Karavias