On 23/07/15 16:44, Erich Bremer wrote:
I had used Land.JSONLD and it goesn't work.

Model m = RDFDataMgr.loadModel("data.json", Lang.JSONLD);

However, I renamed the file to .jsonld and made the change in the code

Model m = RDFDataMgr.loadModel("data.jsonld", Lang.JSONLD);

and now it is reading it in.  It seems both things need to be done for
it to work.  - Erich

Ah - the delicate balance of content negotiation + the real world.

The algorithm is for choosing the language is a precarious tower of practical choices.

When there are choices the order of deciding is:

1/ File extension
2/ Content negotiation (HTTP) but ignore "text/plain"
3/ Lang -- that's treated as a hint rather than an override.

It can be impossible, or just very hard, to set the content type in some publishing/hosting environments so file extension trumps content negotiation. People seem to understand getting that right.

The next one, hint or override, is arguable - it used to the other way round but that also caused problems. Hint is definitely better for when conneg returns something reasonable (and no extension); things like ".owl" are dubious and may not even be RDF. Maybe it ought to be different if it is a local file or remote

The decision is made in RDFMgr.process calling WebContent.determineCT.

In this example, removing ".json" from the registered extensions for RDF/JSON would make RDFDataMgr.loadModel("data.json", Lang.JSONLD) work.

JENA-997 and I think we ought to make that change in time for 3.0.0 (= very, very soon).


        Andy


On Thu, 23 Jul 2015 16:23:21 +0100
  Andy Seaborne <a...@apache.org> wrote:
On 23/07/15 15:58, Erich Bremer wrote:
Hi,
I downloaded:
http://www.w3.org/People/Berners-Lee/card.rdf
read and dumped with Jena with:

Model m = RDFDataMgr.loadModel("tbl.rdf", Lang.RDFXML);

m.write(System.out,"JSON-LD");
then tried to read the JSON-LD with Jena RDFDataMgr and got the

following error:
Exception in thread "main" org.apache.jena.riot.RiotException: [line: 2,

col: 3 ] Relative IRI: @graph

** LangRDFJSON.runParser **

Looks like you reading with the wrong RDF-in-JSON language.

Either you are not using fiel extension "jsonld" (the offical
extension) or using Lang.JSONLD, not Lang.RDFJSON.


The javadoc for RDFJSON is

"RDF/JSON. This is not JSON-LD."

http://www.w3.org/TR/rdf-json/
vs
http://www.w3.org/TR/json-ld/


    Andy

PS Erich - your emails are not getting passed through. Are you using
AWS SES?  These seem to not present a valid sender to check against
the subscription list. erich...ebremer.com is subscribed.

Possibly this is because the sending machine jumps around:
a8-42.smtp-out.amazonses.com. And because of that, adding an "allow"
exception does not work.  There's not a lot the list admin can do
about that.


  at

org.apache.jena.riot.system.ErrorHandlerFactory$ErrorHandlerStd.error(ErrorHandlerFactory.java:128)


  at

org.apache.jena.riot.checker.CheckerIRI.iriViolations(CheckerIRI.java:140)


  at

org.apache.jena.riot.checker.CheckerIRI.iriViolations(CheckerIRI.java:102)


  at

org.apache.jena.riot.system.ParserProfileChecker.makeIRI(ParserProfileChecker.java:67)


  at

org.apache.jena.riot.system.ParserProfileChecker.resolveIRI(ParserProfileChecker.java:60)


  at

org.apache.jena.riot.system.ParserProfileChecker.createURI(ParserProfileChecker.java:113)


  at

org.apache.jena.riot.lang.LangRDFJSON.tryParseTriples(LangRDFJSON.java:122)


  at

org.apache.jena.riot.lang.LangRDFJSON.tryParseGraph(LangRDFJSON.java:69)

  at
org.apache.jena.riot.lang.LangRDFJSON.runParser(LangRDFJSON.java:57)

  at org.apache.jena.riot.lang.LangBase.parse(LangBase.java:42)

  at

org.apache.jena.riot.RDFParserRegistry$ReaderRIOTLang.read(RDFParserRegistry.java:185)


  at org.apache.jena.riot.RDFDataMgr.process(RDFDataMgr.java:906)

  at org.apache.jena.riot.RDFDataMgr.parse(RDFDataMgr.java:687)

  at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:210)

  at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:183)

  at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:121)

  at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:112)

  at org.apache.jena.riot.RDFDataMgr.loadModel(RDFDataMgr.java:338)

  at spatialimage.json2jsonld.<init>(json2jsonld.java:20)

  at spatialimage.json2jsonld.main(json2jsonld.java:27)
converted TBL file to JSON-LD:
{

  "@graph" : [ {

  "@id" : "_:b0",

  "lat" : "42.361860",

  "long" : "-71.091840"

  }, {

  "@id" : "_:b1",

  "address" : "_:b4",

  "con:phone" : {

  "@id" : "tel:+1-617-253-5702"

  },

  "location" : "_:b3"

  }, {

  "@id" : "_:b2",

  "@type" : "cert:RSAPublicKey",

  "cert:exponent" : 65537,

  "modulus" :

"ebe99c737bd3670239600547e5e2eb1d1497da39947b6576c3c44ffeca32cf0f2f7cbee3c47001278a90fc7fc5bcf292f741eb1fcd6bbe7f90650afb519cf13e81b2bffc6e02063ee5a55781d420b1dfaf61c15758480e66d47fb0dcb5fa7b9f7f1052e5ccbd01beee9553c3b6b51f4daf1fce991294cd09a3d1d636bc6c7656e4455d0aff06daec740ed0084aa6866fcae1359de61cc12dbe37c8fa42e977c6e727a8258bb9a3f265b27e3766fe0697f6aa0bcc81c3f026e387bd7bbc81580dc1853af2daa099186a9f59da526474ef6ec0a3d84cf400be3261b6b649dea1f78184862d34d685d2d587f09acc14cd8e578fdd2283387821296f0af39b8d8845"


  }, {

  "@id" : "_:b3",

  "lat" : "42.361860",

  "long" : "-71.091840"

  }, {

  "@id" : "_:b4",

  "city" : "Cambridge",

  "country" : "USA",

  "postalCode" : "02139",

  "street" : "32 Vassar Street",

  "street2" : "MIT CSAIL Room 32-G524"

  }, {

  "@id" : "file:///D:/google/erich.bremer/DesignIssues/Overview.html",

  "title" : "Design Issues for the World Wide Web",

  "maker" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" :
"file:///D:/google/erich.bremer/projects/SpatialImage/tbl.rdf",

  "@type" : ":PersonalProfileDocument",

  "license" : "http://creativecommons.org/licenses/by-nc/3.0/";,

  "title" : "Tim Berners-Lee's FOAF file",

  "maker" : "https://www.w3.org/People/Berners-Lee/card#i";,

  "primaryTopic" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" :

"file:///D:/google/erich.bremer/projects/SpatialImage/tbl.rdf#findMyLoc",


  "description" : "Share your location with your friends.",

  "endpoint" : "https://timbl.data.fm/test2/locator/location";,

  "web:name" : "FindMyLoc",

  "service" : "https://findmyloc.rww.io/";

  }, {

  "@id" :

"file:///D:/google/erich.bremer/projects/SpatialImage/tbl.rdf#i",

  "key" : "_:b2"

  }, {

  "@id" : "http://dig.csail.mit.edu/2005/ajar/ajaw/data#Tabulator";,

  "developer" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" : "http://dig.csail.mit.edu/2007/01/camp/data#course";,

  "maker" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" : "http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf";,

  "@type" : ":PersonalProfileDocument",

  "license" : "http://creativecommons.org/licenses/by-nc/3.0/";,

  "title" : "Tim Berners-Lee's editable FOAF file",

  "maker" : "https://www.w3.org/People/Berners-Lee/card#i";,

  "primaryTopic" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" : "http://dig.csail.mit.edu/breadcrumbs/blog/4";,

  "title" : "timbl's blog",

  "seeAlso" : "http://dig.csail.mit.edu/breadcrumbs/blog/feed/4";,

  "maker" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" : "http://dig.csail.mit.edu/data#DIG";,

  "member" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" : "http://wiki.ontoworld.org/index.php/_IRW2006";,

  "title" : "Identity, Reference and the Web workshop 2006",

  "participant" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" :

"http://www.ecs.soton.ac.uk/~dt2/dlstuff/www2006_data#panel-panelk01";,

  "label" : "The Next Wave of the Web (Plenary Panel)",

  "participant" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" :

"http://www.gutenberg.org/catalog/world/readfile?fk_files=2372108&pageno=11";,


  "title" : "Moby Dick, or, the whale"

  }, {

  "@id" : "http://www.w3.org/2000/10/swap/data#Cwm";,

  "developer" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" : "http://www.w3.org/2011/Talks/0331-hyderabad-tbl/data#talk";,

  "dct:title" : "Designing the Web for an Open Society",

  "maker" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" : "http://www.w3.org/People/Berners-Lee/card#i";,

  "sameAs" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" : "http://www.w3.org/data#W3C";,

  "member" : "https://www.w3.org/People/Berners-Lee/card#i";

  }, {

  "@id" :
"http://www4.wiwiss.fu-berlin.de/booksMeshup/books/006251587X";,

  "creator" : "https://www.w3.org/People/Berners-Lee/card#i";,

  "title" : "Weaving the Web: The Original Design and Ultimate Destiny

of the World Wide Web"

  }, {

  "@id" : "https://webid.mit.edu/timbl#";,

  "storage" : "https://timbl.rww.io/";

  }, {

  "@id" : "https://www.w3.org/People/Berners-Lee/card#i";,

  "@type" : [ "con:Male", ":Person" ],

  "uses" :

"file:///D:/google/erich.bremer/projects/SpatialImage/tbl.rdf#findMyLoc",


  "label" : "Tim Berners-Lee",

  "seeAlso" : [ "http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf";,

"http://www.w3.org/2007/11/Talks/search/query?date=All+past+and+future+talks&event=None&activity=None&name=Tim+Berners-Lee&country=None&language=None&office=None&rdfOnly=yes&submit=Submit";



],

  "assistant" : "https://www.w3.org/People/Berners-Lee/card#amy";,

  "homePage" : "file:///D:/google/erich.bremer/projects/SpatialImage/",

  "likes" :

"http://www.gutenberg.org/catalog/world/readfile?fk_files=2372108&pageno=11";,


  "office" : "_:b1",

  "preferredURI" : "https://www.w3.org/People/Berners-Lee/card#i";,

  "publicHomePage" :

"file:///D:/google/erich.bremer/projects/SpatialImage/",

  "sameAs" : [

"http://www4.wiwiss.fu-berlin.de/dblp/resource/person/100007";,

"http://www4.wiwiss.fu-berlin.de/bookmashup/persons/Tim+Berners-Lee";,

"http://www.advogato.org/person/timbl/foaf.rdf#me";,

"http://graph.facebook.com/512908782#";,
"https://webid.mit.edu/timbl#"; ],

  "preferencesFile" : "https://localhost/TimBL/Data/preferences.n3";,

  "storage" : "https://timbl.rww.io/";,

  "account" : [ "http://twitter.com/timberners_lee";,

"http://www.reddit.com/user/timbl/";,

"http://en.wikipedia.org/wiki/User:Timbl"; ],

  "based_near" : "_:b0",

  "family_name" : "Berners-Lee",

  "givenname" : "Timothy",

  "homepage" : "https://www.w3.org/People/Berners-Lee/";,

  "img" :

"http://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg";,

  "mbox" : "mailto:ti...@w3.org";,

  "mbox_sha1sum" : "965c47c5a70db7407210cef6e4e6f5374a525c5c",

  "name" : "Timothy Berners-Lee",

  "nick" : [ "TimBL", "timbl" ],

  "openid" : "https://www.w3.org/People/Berners-Lee/";,

  "phone" : "tel:+1-(617)-253-5702",

  ":title" : "Sir",

  "weblog" : "http://dig.csail.mit.edu/breadcrumbs/blog/4";,

  "workplaceHomepage" : "http://www.w3.org/";

  } ],

  "@context" : {

  "long" : "http://www.w3.org/2003/01/geo/wgs84_pos#long";,

  "lat" : "http://www.w3.org/2003/01/geo/wgs84_pos#lat";,

  "storage" : {

  "@id" : "http://www.w3.org/ns/pim/space#storage";,

  "@type" : "@id"

  },

  "member" : {

  "@id" : "http://xmlns.com/foaf/0.1/member";,

  "@type" : "@id"

  },

  "primaryTopic" : {

  "@id" : "http://xmlns.com/foaf/0.1/primaryTopic";,

  "@type" : "@id"

  },

  "maker" : {

  "@id" : "http://xmlns.com/foaf/0.1/maker";,

  "@type" : "@id"

  },

  "title" : "http://purl.org/dc/elements/1.1/title";,

  "license" : {

  "@id" : "http://creativecommons.org/ns#license";,

  "@type" : "@id"

  },

  "homePage" : {

  "@id" : "http://www.w3.org/2000/10/swap/pim/contact#homePage";,

  "@type" : "@id"

  },

  "assistant" : {

  "@id" : "http://www.w3.org/2000/10/swap/pim/contact#assistant";,

  "@type" : "@id"

  },

  "sameAs" : {

  "@id" : "http://www.w3.org/2002/07/owl#sameAs";,

  "@type" : "@id"

  },

  "family_name" : "http://xmlns.com/foaf/0.1/family_name";,

  "mbox" : {

  "@id" : "http://xmlns.com/foaf/0.1/mbox";,

  "@type" : "@id"

  },

  "workplaceHomepage" : {

  "@id" : "http://xmlns.com/foaf/0.1/workplaceHomepage";,

  "@type" : "@id"

  },

  "weblog" : {

  "@id" : "http://xmlns.com/foaf/0.1/weblog";,

  "@type" : "@id"

  },

  "seeAlso" : {

  "@id" : "http://www.w3.org/2000/01/rdf-schema#seeAlso";,

  "@type" : "@id"

  },

  "givenname" : "http://xmlns.com/foaf/0.1/givenname";,

  "label" : "http://www.w3.org/2000/01/rdf-schema#label";,

  "openid" : {

  "@id" : "http://xmlns.com/foaf/0.1/openid";,

  "@type" : "@id"

  },

  "based_near" : {

  "@id" : "http://xmlns.com/foaf/0.1/based_near";,

  "@type" : "@id"

  },

  "name" : "http://xmlns.com/foaf/0.1/name";,

  "likes" : {

  "@id" : "http://www.w3.org/2000/10/swap/pim/contact#likes";,

  "@type" : "@id"

  },

  "account" : {

  "@id" : "http://xmlns.com/foaf/0.1/account";,

  "@type" : "@id"

  },

  "publicHomePage" : {

  "@id" : "http://www.w3.org/2000/10/swap/pim/contact#publicHomePage";,

  "@type" : "@id"

  },

  "phone" : {

  "@id" : "http://xmlns.com/foaf/0.1/phone";,

  "@type" : "@id"

  },

  "nick" : "http://xmlns.com/foaf/0.1/nick";,

  "homepage" : {

  "@id" : "http://xmlns.com/foaf/0.1/homepage";,

  "@type" : "@id"

  },

  "office" : {

  "@id" : "http://www.w3.org/2000/10/swap/pim/contact#office";,

  "@type" : "@id"

  },

  "img" : {

  "@id" : "http://xmlns.com/foaf/0.1/img";,

  "@type" : "@id"

  },

  "mbox_sha1sum" : "http://xmlns.com/foaf/0.1/mbox_sha1sum";,

  "uses" : {

  "@id" : "http://my-profile.eu/ns/webapp#uses";,

  "@type" : "@id"

  },

  "preferencesFile" : {

  "@id" : "http://www.w3.org/ns/pim/space#preferencesFile";,

  "@type" : "@id"

  },

  "preferredURI" :

"http://www.w3.org/2000/10/swap/pim/contact#preferredURI";,

  "participant" : {

  "@id" : "http://www.w3.org/2000/10/swap/pim/contact#participant";,

  "@type" : "@id"

  },

  "modulus" : {

  "@id" : "http://www.w3.org/ns/auth/cert#modulus";,

  "@type" : "http://www.w3.org/2001/XMLSchema#hexBinary";

  },

  "exponent" : {

  "@id" : "http://www.w3.org/ns/auth/cert#exponent";,

  "@type" : "http://www.w3.org/2001/XMLSchema#integer";

  },

  "developer" : {

  "@id" : "http://usefulinc.com/ns/doap#developer";,

  "@type" : "@id"

  },

  "location" : {

  "@id" : "http://www.w3.org/2003/01/geo/wgs84_pos#location";,

  "@type" : "@id"

  },

  "address" : {

  "@id" : "http://www.w3.org/2000/10/swap/pim/contact#address";,

  "@type" : "@id"

  },

  "creator" : {

  "@id" : "http://purl.org/dc/elements/1.1/creator";,

  "@type" : "@id"

  },

  "street2" : "http://www.w3.org/2000/10/swap/pim/contact#street2";,

  "street" : "http://www.w3.org/2000/10/swap/pim/contact#street";,

  "postalCode" :
"http://www.w3.org/2000/10/swap/pim/contact#postalCode";,

  "country" : "http://www.w3.org/2000/10/swap/pim/contact#country";,

  "city" : "http://www.w3.org/2000/10/swap/pim/contact#city";,

  "service" : {

  "@id" : "http://my-profile.eu/ns/webapp#service";,

  "@type" : "@id"

  },

  "endpoint" : {

  "@id" : "http://my-profile.eu/ns/webapp#endpoint";,

  "@type" : "@id"

  },

  "description" : "http://my-profile.eu/ns/webapp#description";,

  "key" : {

  "@id" : "http://www.w3.org/ns/auth/cert#key";,

  "@type" : "@id"

  },

  "" : "http://xmlns.com/foaf/0.1/";,

  "cc" : "http://creativecommons.org/ns#";,

  "con" : "http://www.w3.org/2000/10/swap/pim/contact#";,

  "owl" : "http://www.w3.org/2002/07/owl#";,

  "cert" : "http://www.w3.org/ns/auth/cert#";,

  "space" : "http://www.w3.org/ns/pim/space#";,

  "geo" : "http://www.w3.org/2003/01/geo/wgs84_pos#";,

  "s" : "http://www.w3.org/2000/01/rdf-schema#";,

  "dct" : "http://purl.org/dc/terms/";,

  "doap" : "http://usefulinc.com/ns/doap#";,

  "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#";,

  "web" : "http://my-profile.eu/ns/webapp#";,

  "foaf" : "http://xmlns.com/foaf/0.1/";,

  "dc" : "http://purl.org/dc/elements/1.1/";

  }

}



Reply via email to