Recorded as JENA-1316
https://issues.apache.org/jira/browse/JENA-1316
On 03/04/17 21:08, Donald Smith wrote:
Use Case:
Our applications must be able to run inside closed intranet environments where
outside communication is not possible. The applications use third party
ontologies as well as internal ontologies that represent our domain of
knowledge.
Since outside communication is not possible, we perform a build time step of
our ontologies which include verification via Pellet and then are
bundled together as a software artifact that our applications depend on through
Nuget. Any third party ontologies need to be downloaded and included
in the artifact. Also, there are internal ontologies that are managed by
different groups and repositories. Each of the internal ontologies need to
be fetched via HTTP as well.
Our internal server that serves our ontologies only supports text/html and
text/turtle. Tools such as Protege can handle loading our ontologies and
importing of internal and external ontologies. I was expecting the following
code to work in a similar manner. It appears however that Model.read
expects imported ontologies to be of type rdf xml and does not inspect the
Content-Type returned from the server.
Code to load the Ontology from disk:
import org.apache.jena.ontology.OntModel;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
public class App {
public static void main(String[] args) {
try {
OntModel ontModel = ModelFactory.createOntologyModel(OWL_DL_MEM);
ontModel.read(new FileInputStream("D:/temp/Documents.owl.ttl"),
null,
RDFLanguages.strLangTurtle);
} catch (ParseException exp) {
System.err.println("Error: " + exp.getMessage());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
Documents Ontology Contents:
@prefix argo-doc-doc: <http://vocab.argodata.com/Documents/Documents.owl#> .
@prefix argo-pty-usr: <http://vocab.argodata.com/Parties/Users.owl#> .
@prefix argo-doc-mime: <http://vocab.argodata.com/Documents/MimeTypes.owl#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix vann: <http://purl.org/vocab/vann/> .
<http://vocab.argodata.com/Documents/Documents.owl> a owl:Ontology ;
owl:imports <http://vocab.argodata.com/Documents/MimeTypes.owl#> ;
rdfs:label "Document Handling Ontology" ;
owl:versionInfo "1.0.0-draft"^^xsd:string ;
dc:dateSubmitted "2016-02-11"^^xsd:date ;
dc:publisher <http://argodata.com> ;
rdfs:comment "Defines the base level concepts of Documents."@en ;
vann:preferredNamespacePrefix "argo-doc-doc" ;
vann:preferredNamespaceUri "http://vocab.argodata.com/Documents/Documents.owl#"
.
****** Truncated *******
Debug Trace:
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 >> "GET /Documents/MimeTypes.owl
HTTP/1.1[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 >> "Accept:
text/turtle,application/n-triples;q=0.9,application/rdf+xml;q=0.7,application/trig,application/n-quads;q=0.9,text/x-nquads;q=0.8,application/x-trig;q=0.7,application/ld+json;q=0.6,*/*;q=0.5[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 >> "User-Agent:
Apache-Jena-ARQ/3.2.0[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 >> "Host:
vocab.argodata.com[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 >> "Connection:
Keep-Alive[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 >> "Accept-Encoding:
gzip,deflate[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 >> "Via: 1.1 localhost
(Apache-HttpClient/4.5.2 (cache))[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 >> "[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "Cache-Control:
no-cache[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "Pragma:
no-cache[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "Content-Type:
text/turtle[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "Expires: -1[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "Last-Modified: Fri, 31 Mar
2017 16:59:17 GMT[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "Accept-Ranges:
bytes[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "ETag:
"10ed582240aad21:0"[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "Server:
Microsoft-IIS/7.5[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "X-Powered-By:
ASP.NET[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "Date: Mon, 03 Apr 2017
15:05:15 GMT[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "Content-Length:
17526[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "[\r][\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "@prefix argo-doc-mime:
<http://vocab.argodata.com/Documents/MimeTypes.owl#> .[\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "@prefix dc:
<http://purl.org/dc/elements/1.1/> .[\n]"
***** Truncated *****
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 <<
"<http://vocab.argodata.com/Documents/MimeTypes.owl#application/vnd.oasis.opendocument.graphics>
a argo-doc-mime:MediaType,[\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << " owl:NamedIndividual
;[\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << " rdfs:label
"application/vnd.oasis.opendocument.graphics" ;[\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << " argo-doc-mime:fileExtension
".odg" ;[\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << " rdfs:seeAlso
<http://www.iana.org/assignments/media-types/application/vnd.oasis.opendocument.graphics>
.[\n]"
2017-04-03 10:05:15 DEBUG wire:72 - http-outgoing-0 << "[\n]"
2017-04-03 10:05:15 DEBUG wire:86 - http-outgoing-0 << "<http://voc"
2017-04-03 10:05:15 DEBUG headers:124 - http-outgoing-0 << HTTP/1.1 200 OK
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << Cache-Control:
no-cache
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << Pragma: no-cache
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << Content-Type:
text/turtle
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << Expires: -1
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << Last-Modified: Fri,
31 Mar 2017 16:59:17 GMT
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << Accept-Ranges: bytes
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << ETag:
"10ed582240aad21:0"
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << Server:
Microsoft-IIS/7.5
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << X-Powered-By: ASP.NET
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << Date: Mon, 03 Apr
2017 15:05:15 GMT
2017-04-03 10:05:15 DEBUG headers:127 - http-outgoing-0 << Content-Length: 17526
2017-04-03 10:05:15 DEBUG MainClientExec:284 - Connection can be kept alive
indefinitely
2017-04-03 10:05:15 DEBUG StreamManager:142 - Found:
http://vocab.argodata.com/Documents/MimeTypes.owl# (LocatorHTTP)
2017-04-03 10:05:15 ERROR riot:84 - [line: 1, col: 1 ] Content is not allowed
in prolog.
Jena is using the following Accept header as shown above:
"Accept:
text/turtle,application/n-triples;q=0.9,application/rdf+xml;q=0.7,application/trig,application/n-quads;q=0.9,text/x-nquads;q=0.8,application/x-trig;q=0.7,application/ld+json;q=0.6,*/*;q=0.5[\r][\n]"
And the response returned has Content-Type: text/turtle, but fails to parse
because it assumes the format is rdf/xml.
In order to get this working I will be making our internal server return
rdf/xml instead of text/turtle as that seems to work just fine.
Thanks for the help and apologies for not sending all of this info before.
-----Original Message-----
From: Lorenz B. [mailto:[email protected]]
Sent: Monday, April 3, 2017 12:58 AM
To: [email protected]
Subject: [!!Mass Mail]Re: Ontology Imports
Good catch!
As Adam pointed out, you're using the read() method with a wrong second
argument, i.e. when you use
model.read(String url,
String base)
the second argument is the base IRI. What you probably want is to use the
read() method with three arguments having the signature
model.read(String url,
String base,
String lang)
and the language beeing the third argument:
model.read("http://example.com/ExampleOntology.owl", null, "TURTLE");
See Javadoc [1] for more information.
[1]
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/rdf/model/Model.html#read-java.io.InputStream-java.lang.String-
I cannot find a method read(InputStream stream, String Lang) on Model (from which
OntModel inherits its "read" methods). Are you by chance using read(InputStream
in, String base), which is a very different semantic?
---
A. Soroka
The University of Virginia Library
On Mar 31, 2017, at 2:38 PM, Donald Smith <[email protected]> wrote:
RDFDataMgr does fine while loading a given RDF file, but what I'm trying to do
is to use OntModel to read an ontology from local disk which would intern fetch
the imported ontologies. For any imported ontology that is fetched via HTTP
that is returned as RDF/XML works fine. For any imported ontology that is of
any other type, such as turtle, it fails.
Does OntModel.read(InputStream stream, String Lang) not use RDFDataMgr itself
to load imported ontologies?
-----Original Message-----
From: Dave Reynolds [mailto:[email protected]]
Sent: Thursday, March 30, 2017 2:57 AM
To: [email protected]
Subject: Re: Ontology Imports
On 29/03/17 20:54, Donald Smith wrote:
Given I have an ontology that imports one or more other ontologies, when I read
that ontology:
model.read("http://example.com/ExampleOntology.owl", "TURTLE");
That should be "Turtle" or, better, RDFLanguages.strLangTurtle or better still
use RDFDataMgr and let it work out the language.
Dave
--------------------------------------------------- Confidentiality Notice:
This electronic mail transmission is confidential, may be privileged and should
be read or retained only by the intended recipient. If you have received this
transmission in error, please immediately notify the sender and delete it from
your system.
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
--------------------------------------------------- Confidentiality Notice:
This electronic mail transmission is confidential, may be privileged and should
be read or retained only by the intended recipient. If you have received this
transmission in error, please immediately notify the sender and delete it from
your system.