Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

mapping - Is there any way in rml / r2rml to take a value as an IRI?

I'm using RMLMapper to transfrom JSON to RDF. One of the values stored in the JSON is a URL. I would like to use this as the basis of an IRI for the object of RDF statements.

The input is

{
  "documentId": {
    "value": "http://example.org/345299"
  },
...

I want the IRI for the subject of statements to be http://example.org/345299#item, e.g. <http://example.org/345299#item> a <http://schema.org/Thing> .

I tried

@prefix rr: <http://www.w3.org/ns/r2rml#>.
@prefix rml: <http://semweb.mmlab.be/ns/rml#>.
@prefix ql: <http://semweb.mmlab.be/ns/ql#>.
<#Mapping> a rr:TriplesMap ;
  rml:logicalSource [
    rml:source "input.json";
    rml:referenceFormulation ql:JSONPath;
    rml:iterator "$"
  ];

  rr:subjectMap [
    rr:template "{documentId.value}#item" ;
    rr:class schema:Thing
  ]

gives and error that rr:template "{documentId.value}#item" doesn't produce a valid IRI.

Providing a value for @base gives a valid IRI, but it is the base with the url-encoded value appended to the base, e.g. <http://example.org/http%3A%2F%2Fexample.org%2Fjobposts%2F345299#item>

So is there any way in r2rml / rml to take a value and just use it as an IRI? Or to convert a string in to an IRI?

question from:https://stackoverflow.com/questions/65900785/is-there-any-way-in-rml-r2rml-to-take-a-value-as-an-iri

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

rml:reference is close enough.

  rr:subjectMap [
    rml:reference "documentId.value" ;
    rr:class schema:Thing
  ]

Doesn't seem to let me append #item but it'll do for now.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...