You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (Jira)" <ji...@apache.org> on 2021/07/14 08:42:00 UTC

[jira] [Comment Edited] (JENA-2133) Jena sends multiple media types in accept header when reading knowledge via a url

    [ https://issues.apache.org/jira/browse/JENA-2133?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17380442#comment-17380442 ] 

Andy Seaborne edited comment on JENA-2133 at 7/14/21, 8:41 AM:
---------------------------------------------------------------

I'm not clear why you want it in RDF/XML when it is going to be loaded into a model where the syntax is not retained. You can read in Turtle and write out in RDF/XML.

The contract for {{model.read}} is "get RDF data". For {{model.read}},  conneg information is used to determine the syntax. The string language name is used to choose a syntax when there is no other information - here, that is if content negotiation did not return a {{Content-type}}.

Use {{RDFParser}} for detailed control of the request as [~rvesse] said.

{code}
        RDFParser.create()
            .source("http://localhost:8080/sim")
            .httpAccept("text/turtle")
            .parse(model);
{code}

In model.read(..., "lang"), the {{"lang"}} is the hint language to RDFParser.



was (Author: andy.seaborne):
I'm not clear why you want it in RDF/XML when it is going to be loaded into a model where the syntax is not retained. You can read in Turtle and write out in RDF/XML.

The contract for {{model.read}} is "get RDF data". For {{model.read}},  conneg information is used to determine the syntax. The string language name is used to choose a syntax when there is no other information - here, that is if content negotiation did not return a {{Content-type}}.

Use {{RDFParser}} for detailed control of the request.

{code}
        RDFParser.create()
            .source("http://localhost:8080/sim")
            .httpAccept("text/turtle")
            .parse(model);
{code}

In model.read(..., "lang"), the {{"lang"}} is the hint language to RDFParser.


> Jena sends multiple media types in accept header when reading knowledge via a url
> ---------------------------------------------------------------------------------
>
>                 Key: JENA-2133
>                 URL: https://issues.apache.org/jira/browse/JENA-2133
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: RIOT
>    Affects Versions: Jena 4.1.0
>         Environment: Windows / WSL2 / Maven / Java 14.0.2
>            Reporter: Rem Collier
>            Priority: Major
>             Fix For: Jena 4.2.0
>
>
> When I create a basic model and use the read(...) method to read a remote file, Jena includes multiple media types in the request header.
>  
> {code:java}
> Accept: text/turtle,application/n-triples;q=0.9,application/rdf+xml;q=0.7,application/trig,application/n-quads;q=0.9,application/ld+json;q=0.8,*/*;q=0.5{code}
> The ordering and priorities of the media types does not change, even when different formats are chosen.
> i.e. the following code gives the above list of media types:
>  
>  
> {code:java}
> Model model = ModelFactory.createDefaultModel();
> model.read("http://localhost:8080/sim", "TURTLE");   {code}
> However, the code below also gives the same list of media types:
>  
> {code:java}
> Model model = ModelFactory.createDefaultModel(); model.read("http://localhost:8080/sim", "RDF/XML");{code}
>  
> This results in the knowledge being downloaded in the incorrect format...



--
This message was sent by Atlassian Jira
(v8.3.4#803005)