Hi there,
First, even the base URI is made absolute. In Turtle
BASE <http://example/>
BASE <ns>
is legal to set the base from that point onward as <http://example/ns>
and parsing starts with a base URI related to what the current directory
is, or something (if in Fuseki where the file system is hidden - the
security issue you mention).
The StackOverflow answer suggest creating a base URI that can be spotted
<null:null> then in the StreamRDF that is the output for parsing, test
for this error marking URI. Thsi works for any language.
To move it a step earlier, in parsing, subclass FactoryRDF and set that.
FactoryRDF.createURI(x) is what is creating the URI nodes (after URI
resolution - you still need the base trick). This may not work with
JsonLDReader.
JsonLDReader is slightly different to other parsers because it's
external and because it internally does all parsing, then passes over an
abstract syntax tree to Jena. And line/col info is lost :-(
If desperate, you can call JsonLDReader directly with a customized
ParserProfile (subclass ParserProfileStd) but the StreamRDF way is general.
Andy
On 13/08/18 21:05, [email protected] wrote:
On 2018/08/13 19:44:57, [email protected]
<[email protected]> wrote:
On 2018/08/13 19:42:52, ajs6f <[email protected]> wrote:
That response to that question is from Jan 10 of this year. RDFParser didn't
even exist until recently. Andy and Rob give a set of pretty complete answers
at that question starting in December, and the information is completely
up-to-date, as far as I can see.
ajs6f
On Aug 13, 2018, at 3:36 PM, [email protected] wrote:
I'm converting from JSON-LD to Jena using the following:
Model model = ModelFactory.createDefaultModel()
RDFParser.create.fromString(json).base("").lang(Lang.JSONLD).parse(StreamRDFLib.graph(model.getGraph))
And having the following JSON-LD:
{
"@id": "http://example.com/id",
"@type": "Person",
"name": "a"
}
It will generate a model with the triple:
http://example.com/id @http://www.w3.org/1999/02/22-rdf-syntax-ns#type
file:///some/path/Person
I want the model to fail, throw an exception when some field is supposed to be
an @id but it isn't and not to make up an id from my file path (If I expose
this to the outside world is a big security issue).
Is the way to go as described on this StackOverflow response:
https://stackoverflow.com/questions/47763738/jena-relative-uri-base#answer-48178761
or is there a better way (note the response is from 2010)
My bad, I just misread the reply time. Sorry. Then I will do it this way.
Thanks a lot
In any case
I see when the method createURI in FactoryRDFStd gets called, the "file:///some/path"
fragment has already been prepended to the "Person" string (in the JSON-LD example). Is
there a way or a place to intercept it before this happens? Because now I don't know if the
customer really put that or if it got prepended by Jena