Sorry! Your email said "Or https://github.com/afs/iri4ld"
On Thu, Mar 5, 2020 at 4:18 AM Andy Seaborne <[email protected]> wrote: > Not quite! > > You've raise an issue with afs/iri4ld - my personal project for IRI > parsing. > > Which isn't jsonld-java (https://github.com/jsonld-java/jsonld-java/) > nor is it used by jsonld-java. > > afs/iri4ld that aims to be standard's compliant but faster and easier to > maintain than jena-iri (because it has less functionality than > jena-iri). And it does get this case right. > > Andy > > PS It has a companion project xsd4ld - doing XSD datatypes. > > > On 04/03/2020 23:39, Erich Bremer wrote: > > Andy - done. > > > > On Wed, Mar 4, 2020 at 12:25 PM Andy Seaborne <[email protected]> wrote: > > > >> java.net.URI is not perfect and it is also a mixture of RFC2396, RFC3896 > >> and some pragmatics. > >> > >> Jena's own jena-iri gets it right. > >> > >> // NB The argument order can catch you out. > >> IRI iri = IRIResolver.resolve("picture.jpg", "http://mysite.net" ); > >> System.out.println(iri); > >> > >> but jsonld-java uses java.net.URI. > >> > >> Erich - please could you raise an issue with jsonld-java? > >> > >> Andy > >> > >> Or https://github.com/afs/iri4ld > >> > >> On 04/03/2020 16:57, Erich Bremer wrote: > >>> Thanks for the reference Martynas! According to the section > referenced, > >>> the following two URLs are equivalent. > >>> > >>> http://example.com > >>> http://example.com/ > >>> > >>> I can modify my own code to do the check and fix it for myself, but I > >>> would think URI.resolve should treat them as equivalents and not > >>> mindlessly concatenate them. How the jsonld-java people or the Jena > >>> community, which uses jsonld-java, will have to make the call on how > >>> to handle it. - Erich > >>> > >>> > >>> On Wed, Mar 4, 2020 at 11:24 AM Martynas Jusevičius < > >> [email protected]> > >>> wrote: > >>> > >>>> URI.resolve() will not assume anything. > >>>> > >>>> Base URI normally ends with a /. Don’t know if this is the best > >> reference, > >>>> but close: > >>>> https://tools.ietf.org/html/rfc3986#section-6.2.3 > >>>> > >>>> You need to check the URI RFC and its resolution algorithm. > >>>> > >>>> On Wed, 4 Mar 2020 at 16.57, Erich Bremer <[email protected]> wrote: > >>>> > >>>>> This also works: > >>>>> > >>>>> URI uri = new URI("http://mysite.net"); > >>>>> System.out.println(uri.resolve("/picture.jpg")); > >>>>> > >>>>> but if no trailing "/" and no leading "/" on path will yield the > >>>>> concatenated http://mysite.netpicture.jpg which then gets tossed > and a > >>>>> blank node is formed. > >>>>> > >>>>> Should URI.resolve assume a "/" if no trailing nor leading "/" is > >>>> present? > >>>>> - Erich > >>>>> > >>>>> On Wed, Mar 4, 2020 at 10:52 AM Erich Bremer <[email protected]> > >> wrote: > >>>>> > >>>>>> The program works if I specify the base with a trailing slash as " > >>>>>> http://mysite.net/" > >>>>>> I ran through the code and the problem appears to be here: > >>>>>> > >>>>>> > >>>>> > >>>> > >> > https://github.com/jsonld-java/jsonld-java/blob/66012db2f53b009cedeae50c83b5594b9dd05e11/core/src/main/java/com/github/jsonldjava/utils/JsonLdUrl.java#L283 > >>>>>> > >>>>>> In the short code segment here, you can see: > >>>>>> URI uri = new URI("http://mysite.net"); > >>>>>> System.out.println(uri.resolve("picture.jpg")); > >>>>>> > >>>>>> Output: > >>>>>> http://mysite.netpicture.jpg > >>>>>> > >>>>>> > >>>>>> On Wed, Mar 4, 2020 at 10:05 AM Erich Bremer <[email protected]> > >>>> wrote: > >>>>>> > >>>>>>> Same thing: > >>>>>>> Source JSONLD > >>>>>>> { > >>>>>>> "@context": [ > >>>>>>> "http://schema.org" > >>>>>>> ], > >>>>>>> "@graph": [ > >>>>>>> { > >>>>>>> "@type": "CreativeWork", > >>>>>>> "@id": "picture.jpg" > >>>>>>> }, > >>>>>>> { > >>>>>>> "@id": "./", > >>>>>>> "@type": "DataSet" > >>>>>>> } > >>>>>>> ] > >>>>>>> } > >>>>>>> AFTER loading > >>>>> ============================================================ > >>>>>>> Base : http://mysite.net > >>>>>>> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". > >>>>>>> SLF4J: Defaulting to no-operation (NOP) logger implementation > >>>>>>> SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for > >>>>>>> further details. > >>>>>>> [ { > >>>>>>> "@type" : [ "http://schema.org/CreativeWork" ] > >>>>>>> }, { > >>>>>>> "@id" : "http://mysite.net", > >>>>>>> "@type" : [ "http://schema.org/DataSet" ] > >>>>>>> } ] > >>>>>>> > >>>>>>> > >>>>>>> CODE ==================================== > >>>>>>> package com.mycompany.tesjsonld; > >>>>>>> > >>>>>>> import com.github.jsonldjava.core.JsonLdOptions; > >>>>>>> import com.github.jsonldjava.core.JsonLdProcessor; > >>>>>>> import com.github.jsonldjava.utils.JsonUtils; > >>>>>>> import java.io.ByteArrayInputStream; > >>>>>>> import java.io.FileNotFoundException; > >>>>>>> import java.io.IOException; > >>>>>>> import java.io.InputStream; > >>>>>>> import java.nio.charset.Charset; > >>>>>>> > >>>>>>> /** > >>>>>>> * > >>>>>>> * @author erich > >>>>>>> */ > >>>>>>> public class tryme { > >>>>>>> > >>>>>>> public static void main(String[] args) throws > >>>> FileNotFoundException, > >>>>>>> IOException { > >>>>>>> String json = "{\n" + > >>>>>>> " \"@context\": [\n" + > >>>>>>> " \"http://schema.org\"\n" + > >>>>>>> " ],\n" + > >>>>>>> " \"@graph\": [\n" + > >>>>>>> " {\n" + > >>>>>>> " \"@type\": \"CreativeWork\",\n" + > >>>>>>> " \"@id\": \"picture.jpg\"\n" + > >>>>>>> " },\n" + > >>>>>>> " {\n" + > >>>>>>> " \"@id\": \"./\",\n" + > >>>>>>> " \"@type\": \"DataSet\"\n" + > >>>>>>> " }\n" + > >>>>>>> " ]\n" + > >>>>>>> "}"; > >>>>>>> > >>>>>>> System.out.println(json); > >>>>>>> > >>>>>>> > >>>>> > >>>> > >> > System.out.println("============================================================"); > >>>>>>> InputStream inputStream = new > >>>>>>> ByteArrayInputStream(json.getBytes(Charset.forName("UTF-8"))); > >>>>>>> Object jsonObject = > JsonUtils.fromInputStream(inputStream); > >>>>>>> JsonLdOptions options = new JsonLdOptions(" > >> http://mysite.net > >>>> "); > >>>>>>> System.out.println("Base : "+options.getBase()); > >>>>>>> //Object compact = JsonLdProcessor.compact(jsonObject, > null, > >>>>>>> options); > >>>>>>> Object compact = JsonLdProcessor.expand(jsonObject, > >> options); > >>>>>>> System.out.println(JsonUtils.toPrettyString(compact)); > >>>>>>> } > >>>>>>> } > >>>>>>> > >>>>>>> On Wed, Mar 4, 2020 at 9:44 AM Erich Bremer <[email protected]> > >>>> wrote: > >>>>>>> > >>>>>>>> I will try with the other library to check. > >>>>>>>> > >>>>>>>> On Wed, Mar 4, 2020 at 4:29 AM Rob Vesse <[email protected]> > >>>> wrote: > >>>>>>>> > >>>>>>>>> This may be an upstream bug or it could be a bug in how we > >> configure > >>>>>>>>> the underlying parser > >>>>>>>>> > >>>>>>>>> Jena's JSON-LD support is based upon the > >>>>>>>>> https://github.com/jsonld-java/jsonld-java library so you could > >> try > >>>>>>>>> and reproduce your test case just using their library directly > >> which > >>>>> would > >>>>>>>>> determine if it is their bug or our bug > >>>>>>>>> > >>>>>>>>> Rob > >>>>>>>>> > >>>>>>>>> On 04/03/2020, 00:11, "Erich Bremer" <[email protected]> wrote: > >>>>>>>>> > >>>>>>>>> I'm trying to use a "@id": "./" in a jsonld file and in > >> another > >>>>>>>>> triple > >>>>>>>>> "@id": "picture.jpg". The "./" will be correctly changed > to > >> the > >>>>>>>>> base URL, > >>>>>>>>> but the "@id": "picture.jpg" just gets dropped and a blank > >> node > >>>> is > >>>>>>>>> created. Below is the code segment that I used to generate > >> this > >>>>>>>>> output: > >>>>>>>>> { > >>>>>>>>> "@context": [ > >>>>>>>>> "http://schema.org" > >>>>>>>>> ], > >>>>>>>>> "@graph": [ > >>>>>>>>> { > >>>>>>>>> "@type": "CreativeWork", > >>>>>>>>> "@id": "picture.jpg" > >>>>>>>>> }, > >>>>>>>>> { > >>>>>>>>> "@id": "./", > >>>>>>>>> "@type": "DataSet" > >>>>>>>>> } > >>>>>>>>> ] > >>>>>>>>> } > >>>>>>>>> _:Bd42dbcf4e4ffb76e199766bf5e4c1e4b < > >>>>>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type> < > >>>>>>>>> http://schema.org/CreativeWork> . > >>>>>>>>> <http://mydomain.com> < > >>>>>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type> < > >>>>>>>>> http://schema.org/DataSet> . > >>>>>>>>> > >>>>>>>>> If I use https://json-ld.org/playground/ on the same > jsonld, > >> I > >>>>> get: > >>>>>>>>> > >>>>>>>>> <https://json-ld.org/playground/> < > >>>>>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type> < > >>>>>>>>> http://schema.org/DataSet> > >>>>>>>>> . > >>>>>>>>> <https://json-ld.org/playground/picture.jpg> < > >>>>>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type> < > >>>>>>>>> http://schema.org/CreativeWork> . > >>>>>>>>> > >>>>>>>>> which is what I expected. Am I missing something here? - > >> Erich > >>>>>>>>> > >>>>>>>>> String json = "{\n" + > >>>>>>>>> " \"@context\": [\n" + > >>>>>>>>> " \"http://schema.org\"\n" + > >>>>>>>>> " ],\n" + > >>>>>>>>> " \"@graph\": [\n" + > >>>>>>>>> " {\n" + > >>>>>>>>> " \"@type\": \"CreativeWork\",\n" + > >>>>>>>>> " \"@id\": \"picture.jpg\"\n" + > >>>>>>>>> " },\n" + > >>>>>>>>> " {\n" + > >>>>>>>>> " \"@id\": \"./\",\n" + > >>>>>>>>> " \"@type\": \"DataSet\"\n" + > >>>>>>>>> " }\n" + > >>>>>>>>> " ]\n" + > >>>>>>>>> "}"; > >>>>>>>>> System.out.println(json); > >>>>>>>>> Model m = ModelFactory.createDefaultModel(); > >>>>>>>>> InputStream inputStream = new > >>>>>>>>> > ByteArrayInputStream(json.getBytes(Charset.forName("UTF-8"))); > >>>>>>>>> RDFParser.create() > >>>>>>>>> .base("http://mydomain.com") > >>>>>>>>> .source(inputStream) > >>>>>>>>> .lang(RDFLanguages.JSONLD) > >>>>>>>>> .parse(m); > >>>>>>>>> RDFDataMgr.write(System.out, m, RDFFormat.NQUADS) ; > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>> > >>>> > >>> > >> > > >
