You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Donald Smith <Do...@argodata.com> on 2017/03/29 19:54:23 UTC

Ontology Imports

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");

I get the exception:
2017-03-29 14:41:04 WARN  OntDocumentManager:1076 - An error occurred while attempting to read from http://example.com/OtherImportedOntology.owl. Msg was '[line: 1, col: 1 ] Content is not allowed in prolog.'.
org.apache.jena.riot.RiotException: [line: 1, col: 1 ] Content is not allowed in prolog.
        at org.apache.jena.riot.system.ErrorHandlerFactory$ErrorHandlerStd.fatal(ErrorHandlerFactory.java:136)
        at org.apache.jena.riot.lang.LangRDFXML$ErrorHandlerBridge.fatalError(LangRDFXML.java:238)
        at org.apache.jena.rdfxml.xmlinput.impl.ARPSaxErrorHandler.fatalError(ARPSaxErrorHandler.java:47)
        at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.warning(XMLHandler.java:199)
        at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.fatalError(XMLHandler.java:229)
        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)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.jena.rdfxml.xmlinput.impl.RDFXMLParser.parse(RDFXMLParser.java:150)
        at org.apache.jena.rdfxml.xmlinput.ARP.load(ARP.java:118)
        at org.apache.jena.riot.lang.LangRDFXML.parse(LangRDFXML.java:134)
        at org.apache.jena.riot.RDFParserRegistry$ReaderRIOTLang.read(RDFParserRegistry.java:179)
        at org.apache.jena.riot.RDFDataMgr.process(RDFDataMgr.java:859)
        at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:259)
        at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:245)
        at org.apache.jena.riot.adapters.RDFReaderRIOT.read(RDFReaderRIOT.java:69)
        at org.apache.jena.rdf.model.impl.ModelCom.read(ModelCom.java:305)
        at org.apache.jena.riot.adapters.AdapterFileManager.readModelWorker(AdapterFileManager.java:289)
        at org.apache.jena.util.FileManager.readModel(FileManager.java:341)
        at org.apache.jena.util.FileManager.readModel(FileManager.java:325)
        at org.apache.jena.ontology.OntDocumentManager.read(OntDocumentManager.java:1062)
        at org.apache.jena.ontology.OntDocumentManager$1.readModel(OntDocumentManager.java:1032)
        at org.apache.jena.rdf.model.impl.ModelMakerImpl.getModel(ModelMakerImpl.java:104)
        at org.apache.jena.ontology.OntDocumentManager.fetchLoadedImportModel(OntDocumentManager.java:1029)
        at org.apache.jena.ontology.OntDocumentManager.fetchPossiblyCachedImportModel(OntDocumentManager.java:1001)
        at org.apache.jena.ontology.OntDocumentManager.loadImport(OntDocumentManager.java:974)
        at org.apache.jena.ontology.OntDocumentManager.loadImports(OntDocumentManager.java:768)
        at org.apache.jena.ontology.OntDocumentManager.loadImports(OntDocumentManager.java:706)
        at org.apache.jena.ontology.impl.OntModelImpl.loadImports(OntModelImpl.java:1964)
        at org.apache.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2200)
        at org.apache.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:2148)

The imported ontology that Jena does an HTTP GET to retrieve (http://example.com/OtherImportedOntology.owl) is served as text/turtle, but it appears Jena is trying to parse as RDF/XML. The ontology is served with the correct Content-Type header:

2017-03-29 14:45:59 DEBUG headers:124 - http-outgoing-0 << HTTP/1.1 200 OK
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << Cache-Control: no-cache
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << Pragma: no-cache
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << Content-Type: text/turtle
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << Expires: -1
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << Last-Modified: Wed, 14 Dec 2016 16:51:09 GMT
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << Accept-Ranges: bytes
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << ETag: "48c33e452a56d21:0"
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << Server: Microsoft-IIS/7.5
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << X-Powered-By: ASP.NET
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << Date: Wed, 29 Mar 2017 19:45:59 GMT
2017-03-29 14:45:59 DEBUG headers:127 - http-outgoing-0 << Content-Length: 17526

Does Jena not use the mime-type that is supplied by the Content-Type response header? I don't see a way of forcing the lang to be used for imports.

Thanks,

Donald Smith

--------------------------------------------------- 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.

Re: [!!Mass Mail]Re: Ontology Imports

Posted by Andy Seaborne <an...@apache.org>.
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:buehmann@informatik.uni-leipzig.de]
> Sent: Monday, April 3, 2017 12:58 AM
> To: users@jena.apache.org
> 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 <Do...@argodata.com> 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:dave.e.reynolds@gmail.com]
>>> Sent: Thursday, March 30, 2017 2:57 AM
>>> To: users@jena.apache.org
>>> 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 Bhmann
> 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.
>

RE: [!!Mass Mail]Re: Ontology Imports

Posted by Donald Smith <Do...@argodata.com>.
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:buehmann@informatik.uni-leipzig.de]
Sent: Monday, April 3, 2017 12:58 AM
To: users@jena.apache.org
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 <Do...@argodata.com> 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:dave.e.reynolds@gmail.com]
>> Sent: Thursday, March 30, 2017 2:57 AM
>> To: users@jena.apache.org
>> 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.

Re: Ontology Imports

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
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 <Do...@argodata.com> 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:dave.e.reynolds@gmail.com]
>> Sent: Thursday, March 30, 2017 2:57 AM
>> To: users@jena.apache.org
>> 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


Re: Ontology Imports

Posted by "A. Soroka" <aj...@virginia.edu>.
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 <Do...@argodata.com> 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:dave.e.reynolds@gmail.com]
> Sent: Thursday, March 30, 2017 2:57 AM
> To: users@jena.apache.org
> 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.


Re: [!!Mass Mail]Re: Ontology Imports

Posted by Donald Smith <Do...@argodata.com>.
Thanks for helping. Let me get an example in place that demonstrates what I'm seeing.

> On Apr 2, 2017, at 10:15 AM, Andy Seaborne <an...@apache.org> wrote:
>
>
>
>> On 31/03/17 23:53, Martynas Jusevičius wrote:
>> Some of the code (at least OntDocumentManager) is still using
>> FileManager I believe.
>
> It does go through to RIOT -
>
> org.apache.jena.riot.lang.LangRDFXML.parse
>
> is on the stacktrace.
>
> But "http://example.com/ExampleOntology.owl" is an HTML page generated by example.com for the 404.
>
> If http://example.com/ExampleOntology.owl is in the document manage cache, the code may be confused and using ".owl" as the syntax indicator (that gets to RDF/XML).
>
> Or it may be processing the HTML 404 error page and "Content-Type: text/html" is taken as definitive.
>
>    Andy
>
>>
>> The proper way IMO is to have a location-mapping and read ontology
>> (namespace) URI, not physical file URIs, and let LocationMapper take
>> care of the rest.
>> https://jena.apache.org/documentation/notes/file-manager.html
>>
>>> On Fri, Mar 31, 2017 at 8:38 PM, Donald Smith <Do...@argodata.com> 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:dave.e.reynolds@gmail.com]
>>> Sent: Thursday, March 30, 2017 2:57 AM
>>> To: users@jena.apache.org
>>> 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.
--------------------------------------------------- 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.

Re: Ontology Imports

Posted by Andy Seaborne <an...@apache.org>.

On 31/03/17 23:53, Martynas Jusevi\u010dius wrote:
> Some of the code (at least OntDocumentManager) is still using
> FileManager I believe.

It does go through to RIOT -

org.apache.jena.riot.lang.LangRDFXML.parse

is on the stacktrace.

But "http://example.com/ExampleOntology.owl" is an HTML page generated 
by example.com for the 404.

If http://example.com/ExampleOntology.owl is in the document manage 
cache, the code may be confused and using ".owl" as the syntax indicator 
(that gets to RDF/XML).

Or it may be processing the HTML 404 error page and "Content-Type: 
text/html" is taken as definitive.

	Andy

>
> The proper way IMO is to have a location-mapping and read ontology
> (namespace) URI, not physical file URIs, and let LocationMapper take
> care of the rest.
> https://jena.apache.org/documentation/notes/file-manager.html
>
> On Fri, Mar 31, 2017 at 8:38 PM, Donald Smith <Do...@argodata.com> 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:dave.e.reynolds@gmail.com]
>> Sent: Thursday, March 30, 2017 2:57 AM
>> To: users@jena.apache.org
>> 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.

Re: Ontology Imports

Posted by Martynas Jusevičius <ma...@graphity.org>.
Some of the code (at least OntDocumentManager) is still using
FileManager I believe.

The proper way IMO is to have a location-mapping and read ontology
(namespace) URI, not physical file URIs, and let LocationMapper take
care of the rest.
https://jena.apache.org/documentation/notes/file-manager.html

On Fri, Mar 31, 2017 at 8:38 PM, Donald Smith <Do...@argodata.com> 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:dave.e.reynolds@gmail.com]
> Sent: Thursday, March 30, 2017 2:57 AM
> To: users@jena.apache.org
> 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.

RE: Ontology Imports

Posted by Donald Smith <Do...@argodata.com>.
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:dave.e.reynolds@gmail.com]
Sent: Thursday, March 30, 2017 2:57 AM
To: users@jena.apache.org
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.

Re: Ontology Imports

Posted by Dave Reynolds <da...@gmail.com>.
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