You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Laura Morales <la...@mail.com> on 2018/11/05 07:34:20 UTC

Loosely converting JSON/XML to RDF

I have a mixed set of datasets in XML, JSON, and RDF formats. I would like to convert all the XML/JSON ones to RDF such that I can only use one query language/library to access all the data, instead of having three different ones. I'm also not interested in using any particular ontology or vocabulary for the conversion, so anything will work as long as I can make the conversion.
What would be an appropriate strategy for this? Since RDF requires absolute IRIs, would it be a good idea for example to convert all properties to http://example.org/property-name-1, http://example.org/property-name-2, ...? And maybe use UUIDs for nodes? Or is there a better way of doing this?

Re: Loosely converting JSON/XML to RDF

Posted by Laura Morales <la...@mail.com>.
> you are choosing between a standard with
> multiple implementations, widely supported by the industry, vs. an
> extension of a standard that is supported by a single research project
> only

I guess this consideration can also be made for RML and YARRRML...

 
 

Sent: Wednesday, November 07, 2018 at 2:37 PM
From: "Martynas Jusevičius" <ma...@atomgraph.com>
To: jena-users-ml <us...@jena.apache.org>
Subject: Re: Loosely converting JSON/XML to RDF
Just to add: if the choice comes down to, for example, XSLT vs.
SPARQL-Generate, then you are choosing between a standard with
multiple implementations, widely supported by the industry, vs. an
extension of a standard that is supported by a single research project
only. To me, that's a no-brainer.
On Wed, Nov 7, 2018 at 2:22 PM Conal Tuohy <co...@gmail.com> wrote:
>
> Hi Laura
>
> If I recall correctly, not every JSON document can be parsed as JSON-LD
> merely by supplying a JSON-LD context. I think it is still the case that
> arrays of arrays are not valid in JSON-LD, so you may want to check your
> JSON data to ensure that it complies with that restriction.
>
> I think Martynas Jusevičius is absolutely right to say that different RDF
> syntaxes and RDF conversion techniques are better suited to different types
> of data sources. Personally, I like to use XSLT to convert both XML and
> JSON data to RDF/XML, because although XSLT generally allows use to use a
> simple templating style like SPARQL-Generate or CSVW, it also allows you to
> the flexibility to define more complex mapping operations where that's
> necessary (since XSLT is a Turing-complete programming language).
>
> Good luck with your conversions!
>
> Con
>
>
> On Wed, 7 Nov 2018 at 20:41, Laura Morales <la...@mail.com> wrote:
>
> > This made me thinking... if I can convert CSV, XML, and other formats to
> > JSON, and then use JSON-LD context and framing to change the data to my
> > linking, why do tools such as RML, YARRRML, and SPARQL-Generate exist at
> > all? Do they do anything at all that can't be done with JSON-LD?
> >
> >
> >
> >
> > Sent: Monday, November 05, 2018 at 9:10 AM
> > From: "Christopher Johnson" <ch...@gmail.com>
> > To: users@jena.apache.org
> > Subject: Re: Loosely converting JSON/XML to RDF
> > Another approach is to use JSON-LD. A JSON document can be "converted" to
> > RDF by adding a context and using the toRDF method[1] in one of the JSON-LD
> > libraries. Defining the context is similar to what is done with RML,
> > basically mapping data objects to structured vocabulary terms. If your XML
> > is sufficiently denormalized, you can also convert that to JSON and repeat
> > the same process as above.
> >
> > Christopher Johnson
> > Scientific Associate
> > Universitätsbibliothek Leipzig
> >
> > [1] https://json-ld.org/spec/latest/json-ld-api/#object-to-rdf-conversion
> >
> > On Mon, 5 Nov 2018 at 08:55, Alex To <to...@gmail.com> wrote:
> >
> > > We have web services returning XML and JSON in our environment. We use
> > >
> > https://github.com/RMLio/rmlmapper-java[https://github.com/RMLio/rmlmapper-java][https://github.com/RMLio/rmlmapper-java[https://github.com/RMLio/rmlmapper-java]]
> > to map XML/JSON to RDF with
> > > satisfied results.
> > >
> > > Or course you need a valid URI for your XML or Json elements for e.g. in
> > > our XML, if we have <Student id="...">...</Student> then we use RML to
> > map
> > > it to
> > >
> > >
> > http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/][http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/]]{id}
> > rdfs:type
> > > http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student][http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student]]
> > >
> > > You can define your own URI generation scheme whatever works for you
> > >
> > > You can read more about RDF Mapping Language (RML) from W3C website.
> > >
> > > Regards
> > >
> > > On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:
> > >
> > > > I have a mixed set of datasets in XML, JSON, and RDF formats. I would
> > > like
> > > > to convert all the XML/JSON ones to RDF such that I can only use one
> > > query
> > > > language/library to access all the data, instead of having three
> > > different
> > > > ones. I'm also not interested in using any particular ontology or
> > > > vocabulary for the conversion, so anything will work as long as I can
> > > make
> > > > the conversion.
> > > > What would be an appropriate strategy for this? Since RDF requires
> > > > absolute IRIs, would it be a good idea for example to convert all
> > > > properties to
> > http://example.org/property-name-1[http://example.org/property-name-1][http://example.org/property-name-1[http://example.org/property-name-1]],
> > > > http://example.org/property-name-2[http://example.org/property-name-2][http://example.org/property-name-2[http://example.org/property-name-2]],
> > ...? And maybe use UUIDs for nodes?
> > > > Or is there a better way of doing this?
> > > >
> > >
> >
>
>
> --
> Conal Tuohy
> http://conaltuohy.com/[http://conaltuohy.com/]
> @conal_tuohy
> +61-466-324297

Re: Loosely converting JSON/XML to RDF

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Just to add: if the choice comes down to, for example, XSLT vs.
SPARQL-Generate, then you are choosing between a standard with
multiple implementations, widely supported by the industry, vs. an
extension of a standard that is supported by a single research project
only. To me, that's a no-brainer.
On Wed, Nov 7, 2018 at 2:22 PM Conal Tuohy <co...@gmail.com> wrote:
>
> Hi Laura
>
> If I recall correctly, not every JSON document can be parsed as JSON-LD
> merely by supplying a JSON-LD context. I think it is still the case that
> arrays of arrays are not valid in JSON-LD, so you may want to check your
> JSON data to ensure that it complies with that restriction.
>
> I think Martynas Jusevičius is absolutely right to say that different RDF
> syntaxes and RDF conversion techniques are better suited to different types
> of data sources. Personally, I like to use XSLT to convert both XML and
> JSON data to RDF/XML, because although XSLT generally allows use to use a
> simple templating style like SPARQL-Generate or CSVW, it also allows you to
> the flexibility to define more complex mapping operations where that's
> necessary (since XSLT is a Turing-complete programming language).
>
> Good luck with your conversions!
>
> Con
>
>
> On Wed, 7 Nov 2018 at 20:41, Laura Morales <la...@mail.com> wrote:
>
> > This made me thinking... if I can convert CSV, XML, and other formats to
> > JSON, and then use JSON-LD context and framing to change the data to my
> > linking, why do tools such as RML, YARRRML, and SPARQL-Generate exist at
> > all? Do they do anything at all that can't be done with JSON-LD?
> >
> >
> >
> >
> > Sent: Monday, November 05, 2018 at 9:10 AM
> > From: "Christopher Johnson" <ch...@gmail.com>
> > To: users@jena.apache.org
> > Subject: Re: Loosely converting JSON/XML to RDF
> > Another approach is to use JSON-LD. A JSON document can be "converted" to
> > RDF by adding a context and using the toRDF method[1] in one of the JSON-LD
> > libraries. Defining the context is similar to what is done with RML,
> > basically mapping data objects to structured vocabulary terms. If your XML
> > is sufficiently denormalized, you can also convert that to JSON and repeat
> > the same process as above.
> >
> > Christopher Johnson
> > Scientific Associate
> > Universitätsbibliothek Leipzig
> >
> > [1] https://json-ld.org/spec/latest/json-ld-api/#object-to-rdf-conversion
> >
> > On Mon, 5 Nov 2018 at 08:55, Alex To <to...@gmail.com> wrote:
> >
> > > We have web services returning XML and JSON in our environment. We use
> > >
> > https://github.com/RMLio/rmlmapper-java[https://github.com/RMLio/rmlmapper-java]
> > to map XML/JSON to RDF with
> > > satisfied results.
> > >
> > > Or course you need a valid URI for your XML or Json elements for e.g. in
> > > our XML, if we have <Student id="...">...</Student> then we use RML to
> > map
> > > it to
> > >
> > >
> > http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/]{id}
> > rdfs:type
> > > http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student]
> > >
> > > You can define your own URI generation scheme whatever works for you
> > >
> > > You can read more about RDF Mapping Language (RML) from W3C website.
> > >
> > > Regards
> > >
> > > On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:
> > >
> > > > I have a mixed set of datasets in XML, JSON, and RDF formats. I would
> > > like
> > > > to convert all the XML/JSON ones to RDF such that I can only use one
> > > query
> > > > language/library to access all the data, instead of having three
> > > different
> > > > ones. I'm also not interested in using any particular ontology or
> > > > vocabulary for the conversion, so anything will work as long as I can
> > > make
> > > > the conversion.
> > > > What would be an appropriate strategy for this? Since RDF requires
> > > > absolute IRIs, would it be a good idea for example to convert all
> > > > properties to
> > http://example.org/property-name-1[http://example.org/property-name-1],
> > > > http://example.org/property-name-2[http://example.org/property-name-2],
> > ...? And maybe use UUIDs for nodes?
> > > > Or is there a better way of doing this?
> > > >
> > >
> >
>
>
> --
> Conal Tuohy
> http://conaltuohy.com/
> @conal_tuohy
> +61-466-324297

Re: JSON-LD Was: Loosely converting JSON/XML to RDF

Posted by Paul Houle <on...@gmail.com>.
I did some projects last year where I converted XML to JSON in some 
formulaic way (dependent on the kind of document you have) and then 
stuffed the JSON into databases such as CouchDB or arangodb.  At that 
point I would sometimes pass the JSON data into RDF-world through 
JSON/RDF or alternately put RDF-world data into JSON blobs in the 
aforesaid databases.

There are many problems that could turn up in XML-to-JSON translation,  
for instance dealing with the attribute-vs-element distinction,  
maintaining ordering,  namespaces,  mixed content,  etc.  In practice I 
find that most document collections have one or two problems like that 
to deal with,  but that they did not all come up at the same time so I 
was always able to come up with a simple transformation that was 
idiomatic.

Note also that the JSON model is an approximation of the data model 
common in languages like Perl,  Python,  etc.  With the right idioms 
that data model is easy to work with in Java,  C++,  etc.

I imagine some kind of system that round trips these all as simply as 
possible with a small amount of metadata and that might be the next 
"JSON-LD" but this time it has to be marketed better.


------ Original Message ------
From: "ajs6f" <aj...@apache.org>
To: users@jena.apache.org
Sent: 11/7/2018 10:21:05 AM
Subject: JSON-LD Was: Loosely converting JSON/XML to RDF

>On the particular topic of JSON-LD 1.1, because it has some relevance 
>to the Jena community, I'd like to note again that there are several 
>different groups working out things we can call "1.1", in concert. 
>There is the current Community Group [1] and there is the current 
>Working Group [2].
>
>The difference is that the CG (like all W3C Community Groups) uses a 
>much simpler and less-burdensome process to develop its products. This 
>makes it more flexible and speedy. On the other hand, the WG is slower, 
>very careful, and goes though the whole W3C process [3] to create a 
>recommendation (the highest level of certification that W3C provides to 
>a specification). The WG is sceheduled to deliver its products by 15 
>June 2020.
>
>You can track the work of either group easily, keeping in mind that 
>implementators make independent choices about if and when to implement 
>new features.
>
>The reason I mention all this here is as preface to pointing out that 
>both CG and WG have agreed to add "arrays of arrays" or "lists of 
>lists" to 1.1 [4]. That doesn't refute Conal's basic point about not 
>all JSON being usable for JSON-LD. There might very well be other 
>places where that is still true. But (wearing my "member of the WG" 
>hat) we hope we've gotten the vast majority of potential use cases.
>
>It is worth repeating what others have mentioned in passing-- JSON-LD's 
>primary use case is what used to be called "semantic lifting": adding 
>semantic information to data that lacks it (JSON => JSON-LD). Of 
>course, it's also meant to function as an RDF serialization, but if 
>your first interest is moving from something that isn't JSON to RDF, 
>you may very well find other tools to be more natural and helpful.
>
>ajs6f
>
>
>[1]https://www.w3.org/community/json-ld/ and https://json-ld.org
>[2[] https://www.w3.org/2018/json-ld-wg/
>[3] https://www.w3.org/2018/Process-20180201/
>[4] 
>https://www.w3.org/2018/json-ld-wg/Meetings/Minutes/2018/2018-08-03-json-ld#section4 
>.  For an example, see 
>https://w3c.github.io/json-ld-syntax/#ex-57-coordinates-expressed-in-geojson 
>and above.
>
>>On Nov 7, 2018, at 8:22 AM, Conal Tuohy <co...@gmail.com> wrote:
>>
>>Hi Laura
>>
>>If I recall correctly, not every JSON document can be parsed as 
>>JSON-LD
>>merely by supplying a JSON-LD context. I think it is still the case 
>>that
>>arrays of arrays are not valid in JSON-LD, so you may want to check 
>>your
>>JSON data to ensure that it complies with that restriction.
>>
>>I think Martynas Jusevičius is absolutely right to say that different 
>>RDF
>>syntaxes and RDF conversion techniques are better suited to different 
>>types
>>of data sources. Personally, I like to use XSLT to convert both XML 
>>and
>>JSON data to RDF/XML, because although XSLT generally allows use to 
>>use a
>>simple templating style like SPARQL-Generate or CSVW, it also allows 
>>you to
>>the flexibility to define more complex mapping operations where that's
>>necessary (since XSLT is a Turing-complete programming language).
>>
>>Good luck with your conversions!
>>
>>Con
>>
>>
>>On Wed, 7 Nov 2018 at 20:41, Laura Morales <la...@mail.com> wrote:
>>
>>>This made me thinking... if I can convert CSV, XML, and other formats 
>>>to
>>>JSON, and then use JSON-LD context and framing to change the data to 
>>>my
>>>linking, why do tools such as RML, YARRRML, and SPARQL-Generate exist 
>>>at
>>>all? Do they do anything at all that can't be done with JSON-LD?
>>>
>>>
>>>
>>>
>>>Sent: Monday, November 05, 2018 at 9:10 AM
>>>From: "Christopher Johnson" <ch...@gmail.com>
>>>To: users@jena.apache.org
>>>Subject: Re: Loosely converting JSON/XML to RDF
>>>Another approach is to use JSON-LD. A JSON document can be 
>>>"converted" to
>>>RDF by adding a context and using the toRDF method[1] in one of the 
>>>JSON-LD
>>>libraries. Defining the context is similar to what is done with RML,
>>>basically mapping data objects to structured vocabulary terms. If 
>>>your XML
>>>is sufficiently denormalized, you can also convert that to JSON and 
>>>repeat
>>>the same process as above.
>>>
>>>Christopher Johnson
>>>Scientific Associate
>>>Universitätsbibliothek Leipzig
>>>
>>>[1] 
>>>https://json-ld.org/spec/latest/json-ld-api/#object-to-rdf-conversion
>>>
>>>On Mon, 5 Nov 2018 at 08:55, Alex To <to...@gmail.com> wrote:
>>>
>>>>We have web services returning XML and JSON in our environment. We 
>>>>use
>>>>
>>>https://github.com/RMLio/rmlmapper-java[https://github.com/RMLio/rmlmapper-java]
>>>to map XML/JSON to RDF with
>>>>satisfied results.
>>>>
>>>>Or course you need a valid URI for your XML or Json elements for 
>>>>e.g. in
>>>>our XML, if we have <Student id="...">...</Student> then we use RML 
>>>>to
>>>map
>>>>it to
>>>>
>>>>
>>>http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/]{id}
>>>rdfs:type
>>>>http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student]
>>>>
>>>>You can define your own URI generation scheme whatever works for you
>>>>
>>>>You can read more about RDF Mapping Language (RML) from W3C website.
>>>>
>>>>Regards
>>>>
>>>>On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> 
>>>>wrote:
>>>>
>>>>>I have a mixed set of datasets in XML, JSON, and RDF formats. I 
>>>>>would
>>>>like
>>>>>to convert all the XML/JSON ones to RDF such that I can only use 
>>>>>one
>>>>query
>>>>>language/library to access all the data, instead of having three
>>>>different
>>>>>ones. I'm also not interested in using any particular ontology or
>>>>>vocabulary for the conversion, so anything will work as long as I 
>>>>>can
>>>>make
>>>>>the conversion.
>>>>>What would be an appropriate strategy for this? Since RDF requires
>>>>>absolute IRIs, would it be a good idea for example to convert all
>>>>>properties to
>>>http://example.org/property-name-1[http://example.org/property-name-1],
>>>>>http://example.org/property-name-2[http://example.org/property-name-2],
>>>...? And maybe use UUIDs for nodes?
>>>>>Or is there a better way of doing this?
>>>>>
>>>>
>>>
>>
>>
>>--
>>Conal Tuohy
>>http://conaltuohy.com/
>>@conal_tuohy
>>+61-466-324297
>


JSON-LD Was: Loosely converting JSON/XML to RDF

Posted by ajs6f <aj...@apache.org>.
On the particular topic of JSON-LD 1.1, because it has some relevance to the Jena community, I'd like to note again that there are several different groups working out things we can call "1.1", in concert. There is the current Community Group [1] and there is the current Working Group [2].

The difference is that the CG (like all W3C Community Groups) uses a much simpler and less-burdensome process to develop its products. This makes it more flexible and speedy. On the other hand, the WG is slower, very careful, and goes though the whole W3C process [3] to create a recommendation (the highest level of certification that W3C provides to a specification). The WG is sceheduled to deliver its products by 15 June 2020. 

You can track the work of either group easily, keeping in mind that implementators make independent choices about if and when to implement new features. 

The reason I mention all this here is as preface to pointing out that both CG and WG have agreed to add "arrays of arrays" or "lists of lists" to 1.1 [4]. That doesn't refute Conal's basic point about not all JSON being usable for JSON-LD. There might very well be other places where that is still true. But (wearing my "member of the WG" hat) we hope we've gotten the vast majority of potential use cases.

It is worth repeating what others have mentioned in passing-- JSON-LD's primary use case is what used to be called "semantic lifting": adding semantic information to data that lacks it (JSON => JSON-LD). Of course, it's also meant to function as an RDF serialization, but if your first interest is moving from something that isn't JSON to RDF, you may very well find other tools to be more natural and helpful.

ajs6f


[1]https://www.w3.org/community/json-ld/ and https://json-ld.org
[2[] https://www.w3.org/2018/json-ld-wg/
[3] https://www.w3.org/2018/Process-20180201/
[4] https://www.w3.org/2018/json-ld-wg/Meetings/Minutes/2018/2018-08-03-json-ld#section4 .  For an example, see https://w3c.github.io/json-ld-syntax/#ex-57-coordinates-expressed-in-geojson and above.

> On Nov 7, 2018, at 8:22 AM, Conal Tuohy <co...@gmail.com> wrote:
> 
> Hi Laura
> 
> If I recall correctly, not every JSON document can be parsed as JSON-LD
> merely by supplying a JSON-LD context. I think it is still the case that
> arrays of arrays are not valid in JSON-LD, so you may want to check your
> JSON data to ensure that it complies with that restriction.
> 
> I think Martynas Jusevičius is absolutely right to say that different RDF
> syntaxes and RDF conversion techniques are better suited to different types
> of data sources. Personally, I like to use XSLT to convert both XML and
> JSON data to RDF/XML, because although XSLT generally allows use to use a
> simple templating style like SPARQL-Generate or CSVW, it also allows you to
> the flexibility to define more complex mapping operations where that's
> necessary (since XSLT is a Turing-complete programming language).
> 
> Good luck with your conversions!
> 
> Con
> 
> 
> On Wed, 7 Nov 2018 at 20:41, Laura Morales <la...@mail.com> wrote:
> 
>> This made me thinking... if I can convert CSV, XML, and other formats to
>> JSON, and then use JSON-LD context and framing to change the data to my
>> linking, why do tools such as RML, YARRRML, and SPARQL-Generate exist at
>> all? Do they do anything at all that can't be done with JSON-LD?
>> 
>> 
>> 
>> 
>> Sent: Monday, November 05, 2018 at 9:10 AM
>> From: "Christopher Johnson" <ch...@gmail.com>
>> To: users@jena.apache.org
>> Subject: Re: Loosely converting JSON/XML to RDF
>> Another approach is to use JSON-LD. A JSON document can be "converted" to
>> RDF by adding a context and using the toRDF method[1] in one of the JSON-LD
>> libraries. Defining the context is similar to what is done with RML,
>> basically mapping data objects to structured vocabulary terms. If your XML
>> is sufficiently denormalized, you can also convert that to JSON and repeat
>> the same process as above.
>> 
>> Christopher Johnson
>> Scientific Associate
>> Universitätsbibliothek Leipzig
>> 
>> [1] https://json-ld.org/spec/latest/json-ld-api/#object-to-rdf-conversion
>> 
>> On Mon, 5 Nov 2018 at 08:55, Alex To <to...@gmail.com> wrote:
>> 
>>> We have web services returning XML and JSON in our environment. We use
>>> 
>> https://github.com/RMLio/rmlmapper-java[https://github.com/RMLio/rmlmapper-java]
>> to map XML/JSON to RDF with
>>> satisfied results.
>>> 
>>> Or course you need a valid URI for your XML or Json elements for e.g. in
>>> our XML, if we have <Student id="...">...</Student> then we use RML to
>> map
>>> it to
>>> 
>>> 
>> http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/]{id}
>> rdfs:type
>>> http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student]
>>> 
>>> You can define your own URI generation scheme whatever works for you
>>> 
>>> You can read more about RDF Mapping Language (RML) from W3C website.
>>> 
>>> Regards
>>> 
>>> On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:
>>> 
>>>> I have a mixed set of datasets in XML, JSON, and RDF formats. I would
>>> like
>>>> to convert all the XML/JSON ones to RDF such that I can only use one
>>> query
>>>> language/library to access all the data, instead of having three
>>> different
>>>> ones. I'm also not interested in using any particular ontology or
>>>> vocabulary for the conversion, so anything will work as long as I can
>>> make
>>>> the conversion.
>>>> What would be an appropriate strategy for this? Since RDF requires
>>>> absolute IRIs, would it be a good idea for example to convert all
>>>> properties to
>> http://example.org/property-name-1[http://example.org/property-name-1],
>>>> http://example.org/property-name-2[http://example.org/property-name-2],
>> ...? And maybe use UUIDs for nodes?
>>>> Or is there a better way of doing this?
>>>> 
>>> 
>> 
> 
> 
> -- 
> Conal Tuohy
> http://conaltuohy.com/
> @conal_tuohy
> +61-466-324297


Re: Loosely converting JSON/XML to RDF

Posted by Conal Tuohy <co...@gmail.com>.
Hi Laura

If I recall correctly, not every JSON document can be parsed as JSON-LD
merely by supplying a JSON-LD context. I think it is still the case that
arrays of arrays are not valid in JSON-LD, so you may want to check your
JSON data to ensure that it complies with that restriction.

I think Martynas Jusevičius is absolutely right to say that different RDF
syntaxes and RDF conversion techniques are better suited to different types
of data sources. Personally, I like to use XSLT to convert both XML and
JSON data to RDF/XML, because although XSLT generally allows use to use a
simple templating style like SPARQL-Generate or CSVW, it also allows you to
the flexibility to define more complex mapping operations where that's
necessary (since XSLT is a Turing-complete programming language).

Good luck with your conversions!

Con


On Wed, 7 Nov 2018 at 20:41, Laura Morales <la...@mail.com> wrote:

> This made me thinking... if I can convert CSV, XML, and other formats to
> JSON, and then use JSON-LD context and framing to change the data to my
> linking, why do tools such as RML, YARRRML, and SPARQL-Generate exist at
> all? Do they do anything at all that can't be done with JSON-LD?
>
>
>
>
> Sent: Monday, November 05, 2018 at 9:10 AM
> From: "Christopher Johnson" <ch...@gmail.com>
> To: users@jena.apache.org
> Subject: Re: Loosely converting JSON/XML to RDF
> Another approach is to use JSON-LD. A JSON document can be "converted" to
> RDF by adding a context and using the toRDF method[1] in one of the JSON-LD
> libraries. Defining the context is similar to what is done with RML,
> basically mapping data objects to structured vocabulary terms. If your XML
> is sufficiently denormalized, you can also convert that to JSON and repeat
> the same process as above.
>
> Christopher Johnson
> Scientific Associate
> Universitätsbibliothek Leipzig
>
> [1] https://json-ld.org/spec/latest/json-ld-api/#object-to-rdf-conversion
>
> On Mon, 5 Nov 2018 at 08:55, Alex To <to...@gmail.com> wrote:
>
> > We have web services returning XML and JSON in our environment. We use
> >
> https://github.com/RMLio/rmlmapper-java[https://github.com/RMLio/rmlmapper-java]
> to map XML/JSON to RDF with
> > satisfied results.
> >
> > Or course you need a valid URI for your XML or Json elements for e.g. in
> > our XML, if we have <Student id="...">...</Student> then we use RML to
> map
> > it to
> >
> >
> http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/]{id}
> rdfs:type
> > http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student]
> >
> > You can define your own URI generation scheme whatever works for you
> >
> > You can read more about RDF Mapping Language (RML) from W3C website.
> >
> > Regards
> >
> > On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:
> >
> > > I have a mixed set of datasets in XML, JSON, and RDF formats. I would
> > like
> > > to convert all the XML/JSON ones to RDF such that I can only use one
> > query
> > > language/library to access all the data, instead of having three
> > different
> > > ones. I'm also not interested in using any particular ontology or
> > > vocabulary for the conversion, so anything will work as long as I can
> > make
> > > the conversion.
> > > What would be an appropriate strategy for this? Since RDF requires
> > > absolute IRIs, would it be a good idea for example to convert all
> > > properties to
> http://example.org/property-name-1[http://example.org/property-name-1],
> > > http://example.org/property-name-2[http://example.org/property-name-2],
> ...? And maybe use UUIDs for nodes?
> > > Or is there a better way of doing this?
> > >
> >
>


-- 
Conal Tuohy
http://conaltuohy.com/
@conal_tuohy
+61-466-324297

Re: Loosely converting JSON/XML to RDF

Posted by Alex To <to...@gmail.com>.
Perhaps you want to review JSON-LD and RML to understand what the two
standards are doing then suddenly your question become very obvious.

With JSON-LD, you add "extra elements" to existing JSON data to translate
JSON to triples with almost no control about how should subjects,
predicates and objects in the triples be generated from JSON.

With RML, you specify exactly what XML/JSON elements should become whether
subjects or predicates or objects. You can even specify the format of the
URI to be generated etc...

Have a look at the example here http://rml.io/RML_examples.html

On Wed, Nov 7, 2018 at 9:41 PM Laura Morales <la...@mail.com> wrote:

> This made me thinking... if I can convert CSV, XML, and other formats to
> JSON, and then use JSON-LD context and framing to change the data to my
> linking, why do tools such as RML, YARRRML, and SPARQL-Generate exist at
> all? Do they do anything at all that can't be done with JSON-LD?
>
>
>
>
> Sent: Monday, November 05, 2018 at 9:10 AM
> From: "Christopher Johnson" <ch...@gmail.com>
> To: users@jena.apache.org
> Subject: Re: Loosely converting JSON/XML to RDF
> Another approach is to use JSON-LD. A JSON document can be "converted" to
> RDF by adding a context and using the toRDF method[1] in one of the JSON-LD
> libraries. Defining the context is similar to what is done with RML,
> basically mapping data objects to structured vocabulary terms. If your XML
> is sufficiently denormalized, you can also convert that to JSON and repeat
> the same process as above.
>
> Christopher Johnson
> Scientific Associate
> Universitätsbibliothek Leipzig
>
> [1] https://json-ld.org/spec/latest/json-ld-api/#object-to-rdf-conversion
>
> On Mon, 5 Nov 2018 at 08:55, Alex To <to...@gmail.com> wrote:
>
> > We have web services returning XML and JSON in our environment. We use
> >
> https://github.com/RMLio/rmlmapper-java[https://github.com/RMLio/rmlmapper-java]
> to map XML/JSON to RDF with
> > satisfied results.
> >
> > Or course you need a valid URI for your XML or Json elements for e.g. in
> > our XML, if we have <Student id="...">...</Student> then we use RML to
> map
> > it to
> >
> >
> http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/]{id}
> rdfs:type
> > http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student]
> >
> > You can define your own URI generation scheme whatever works for you
> >
> > You can read more about RDF Mapping Language (RML) from W3C website.
> >
> > Regards
> >
> > On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:
> >
> > > I have a mixed set of datasets in XML, JSON, and RDF formats. I would
> > like
> > > to convert all the XML/JSON ones to RDF such that I can only use one
> > query
> > > language/library to access all the data, instead of having three
> > different
> > > ones. I'm also not interested in using any particular ontology or
> > > vocabulary for the conversion, so anything will work as long as I can
> > make
> > > the conversion.
> > > What would be an appropriate strategy for this? Since RDF requires
> > > absolute IRIs, would it be a good idea for example to convert all
> > > properties to
> http://example.org/property-name-1[http://example.org/property-name-1],
> > > http://example.org/property-name-2[http://example.org/property-name-2],
> ...? And maybe use UUIDs for nodes?
> > > Or is there a better way of doing this?
> > >
> >
>


--

Re: Loosely converting JSON/XML to RDF

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
The same could be said about RDF/XML. It depends in what context (e.g.
ETL pipeline, client/server side) you want to use the data. That's the
beauty of RDF as an abstract model - you can choose the syntax that
best fits your use case, and convert between them if necessary,
without losing information.
On Wed, Nov 7, 2018 at 11:41 AM Laura Morales <la...@mail.com> wrote:
>
> This made me thinking... if I can convert CSV, XML, and other formats to JSON, and then use JSON-LD context and framing to change the data to my linking, why do tools such as RML, YARRRML, and SPARQL-Generate exist at all? Do they do anything at all that can't be done with JSON-LD?
>
>
>
>
> Sent: Monday, November 05, 2018 at 9:10 AM
> From: "Christopher Johnson" <ch...@gmail.com>
> To: users@jena.apache.org
> Subject: Re: Loosely converting JSON/XML to RDF
> Another approach is to use JSON-LD. A JSON document can be "converted" to
> RDF by adding a context and using the toRDF method[1] in one of the JSON-LD
> libraries. Defining the context is similar to what is done with RML,
> basically mapping data objects to structured vocabulary terms. If your XML
> is sufficiently denormalized, you can also convert that to JSON and repeat
> the same process as above.
>
> Christopher Johnson
> Scientific Associate
> Universitätsbibliothek Leipzig
>
> [1] https://json-ld.org/spec/latest/json-ld-api/#object-to-rdf-conversion
>
> On Mon, 5 Nov 2018 at 08:55, Alex To <to...@gmail.com> wrote:
>
> > We have web services returning XML and JSON in our environment. We use
> > https://github.com/RMLio/rmlmapper-java[https://github.com/RMLio/rmlmapper-java] to map XML/JSON to RDF with
> > satisfied results.
> >
> > Or course you need a valid URI for your XML or Json elements for e.g. in
> > our XML, if we have <Student id="...">...</Student> then we use RML to map
> > it to
> >
> > http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/]{id} rdfs:type
> > http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student]
> >
> > You can define your own URI generation scheme whatever works for you
> >
> > You can read more about RDF Mapping Language (RML) from W3C website.
> >
> > Regards
> >
> > On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:
> >
> > > I have a mixed set of datasets in XML, JSON, and RDF formats. I would
> > like
> > > to convert all the XML/JSON ones to RDF such that I can only use one
> > query
> > > language/library to access all the data, instead of having three
> > different
> > > ones. I'm also not interested in using any particular ontology or
> > > vocabulary for the conversion, so anything will work as long as I can
> > make
> > > the conversion.
> > > What would be an appropriate strategy for this? Since RDF requires
> > > absolute IRIs, would it be a good idea for example to convert all
> > > properties to http://example.org/property-name-1[http://example.org/property-name-1],
> > > http://example.org/property-name-2[http://example.org/property-name-2], ...? And maybe use UUIDs for nodes?
> > > Or is there a better way of doing this?
> > >
> >

Re: Loosely converting JSON/XML to RDF

Posted by Laura Morales <la...@mail.com>.
This made me thinking... if I can convert CSV, XML, and other formats to JSON, and then use JSON-LD context and framing to change the data to my linking, why do tools such as RML, YARRRML, and SPARQL-Generate exist at all? Do they do anything at all that can't be done with JSON-LD?

 
 

Sent: Monday, November 05, 2018 at 9:10 AM
From: "Christopher Johnson" <ch...@gmail.com>
To: users@jena.apache.org
Subject: Re: Loosely converting JSON/XML to RDF
Another approach is to use JSON-LD. A JSON document can be "converted" to
RDF by adding a context and using the toRDF method[1] in one of the JSON-LD
libraries. Defining the context is similar to what is done with RML,
basically mapping data objects to structured vocabulary terms. If your XML
is sufficiently denormalized, you can also convert that to JSON and repeat
the same process as above.

Christopher Johnson
Scientific Associate
Universitätsbibliothek Leipzig

[1] https://json-ld.org/spec/latest/json-ld-api/#object-to-rdf-conversion

On Mon, 5 Nov 2018 at 08:55, Alex To <to...@gmail.com> wrote:

> We have web services returning XML and JSON in our environment. We use
> https://github.com/RMLio/rmlmapper-java[https://github.com/RMLio/rmlmapper-java] to map XML/JSON to RDF with
> satisfied results.
>
> Or course you need a valid URI for your XML or Json elements for e.g. in
> our XML, if we have <Student id="...">...</Student> then we use RML to map
> it to
>
> http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/]{id} rdfs:type
> http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student]
>
> You can define your own URI generation scheme whatever works for you
>
> You can read more about RDF Mapping Language (RML) from W3C website.
>
> Regards
>
> On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:
>
> > I have a mixed set of datasets in XML, JSON, and RDF formats. I would
> like
> > to convert all the XML/JSON ones to RDF such that I can only use one
> query
> > language/library to access all the data, instead of having three
> different
> > ones. I'm also not interested in using any particular ontology or
> > vocabulary for the conversion, so anything will work as long as I can
> make
> > the conversion.
> > What would be an appropriate strategy for this? Since RDF requires
> > absolute IRIs, would it be a good idea for example to convert all
> > properties to http://example.org/property-name-1[http://example.org/property-name-1],
> > http://example.org/property-name-2[http://example.org/property-name-2], ...? And maybe use UUIDs for nodes?
> > Or is there a better way of doing this?
> >
>

Re: Loosely converting JSON/XML to RDF

Posted by Laura Morales <la...@mail.com>.
Thank you! This is a great idea indeed! Simply by adding a "context" to my JSON files I should be able to make them valid JSON-LD documents.



Sent: Monday, November 05, 2018 at 9:10 AM
From: "Christopher Johnson" <ch...@gmail.com>
To: users@jena.apache.org
Subject: Re: Loosely converting JSON/XML to RDF
Another approach is to use JSON-LD. A JSON document can be "converted" to
RDF by adding a context and using the toRDF method[1] in one of the JSON-LD
libraries. Defining the context is similar to what is done with RML,
basically mapping data objects to structured vocabulary terms. If your XML
is sufficiently denormalized, you can also convert that to JSON and repeat
the same process as above.

Christopher Johnson
Scientific Associate
Universitätsbibliothek Leipzig

[1] https://json-ld.org/spec/latest/json-ld-api/#object-to-rdf-conversion

On Mon, 5 Nov 2018 at 08:55, Alex To <to...@gmail.com> wrote:

> We have web services returning XML and JSON in our environment. We use
> https://github.com/RMLio/rmlmapper-java[https://github.com/RMLio/rmlmapper-java] to map XML/JSON to RDF with
> satisfied results.
>
> Or course you need a valid URI for your XML or Json elements for e.g. in
> our XML, if we have <Student id="...">...</Student> then we use RML to map
> it to
>
> http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/]{id} rdfs:type
> http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student]
>
> You can define your own URI generation scheme whatever works for you
>
> You can read more about RDF Mapping Language (RML) from W3C website.
>
> Regards
>
> On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:
>
> > I have a mixed set of datasets in XML, JSON, and RDF formats. I would
> like
> > to convert all the XML/JSON ones to RDF such that I can only use one
> query
> > language/library to access all the data, instead of having three
> different
> > ones. I'm also not interested in using any particular ontology or
> > vocabulary for the conversion, so anything will work as long as I can
> make
> > the conversion.
> > What would be an appropriate strategy for this? Since RDF requires
> > absolute IRIs, would it be a good idea for example to convert all
> > properties to http://example.org/property-name-1[http://example.org/property-name-1],
> > http://example.org/property-name-2[http://example.org/property-name-2], ...? And maybe use UUIDs for nodes?
> > Or is there a better way of doing this?
> >
>

Re: Loosely converting JSON/XML to RDF

Posted by Christopher Johnson <ch...@gmail.com>.
Another approach is to use JSON-LD.  A JSON document can be "converted" to
RDF by adding a context and using the toRDF method[1] in one of the JSON-LD
libraries.  Defining the context is similar to what is done with RML,
basically mapping data objects to structured vocabulary terms.  If your XML
is sufficiently denormalized, you can also convert that to JSON and repeat
the same process as above.

Christopher Johnson
Scientific Associate
Universitätsbibliothek Leipzig

[1] https://json-ld.org/spec/latest/json-ld-api/#object-to-rdf-conversion

On Mon, 5 Nov 2018 at 08:55, Alex To <to...@gmail.com> wrote:

> We have web services returning XML and JSON in our environment. We use
> https://github.com/RMLio/rmlmapper-java to map XML/JSON to RDF with
> satisfied results.
>
> Or course you need a valid URI for your XML or Json elements for e.g. in
> our XML, if we have <Student id="...">...</Student> then we use RML to map
> it to
>
> http://ourdomain.com/resources/students/{id}         rdfs:type
> http://ourdomain.com/ont/Student
>
> You can define your own URI generation scheme whatever works for you
>
> You can read more about RDF Mapping Language (RML) from W3C website.
>
> Regards
>
> On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:
>
> > I have a mixed set of datasets in XML, JSON, and RDF formats. I would
> like
> > to convert all the XML/JSON ones to RDF such that I can only use one
> query
> > language/library to access all the data, instead of having three
> different
> > ones. I'm also not interested in using any particular ontology or
> > vocabulary for the conversion, so anything will work as long as I can
> make
> > the conversion.
> > What would be an appropriate strategy for this? Since RDF requires
> > absolute IRIs, would it be a good idea for example to convert all
> > properties to http://example.org/property-name-1,
> > http://example.org/property-name-2, ...? And maybe use UUIDs for nodes?
> > Or is there a better way of doing this?
> >
>

Re: Loosely converting JSON/XML to RDF

Posted by Laura Morales <la...@mail.com>.
Thank you! I was completely unaware of this tool. I will definitely try it out! Do you have any links for their RML-Editor? They show screenshots and screencasts on the website but no source code to download.
 
 

Sent: Monday, November 05, 2018 at 8:54 AM
From: "Alex To" <to...@gmail.com>
To: users@jena.apache.org
Subject: Re: Loosely converting JSON/XML to RDF
We have web services returning XML and JSON in our environment. We use
https://github.com/RMLio/rmlmapper-java to map XML/JSON to RDF with
satisfied results.

Or course you need a valid URI for your XML or Json elements for e.g. in
our XML, if we have <Student id="...">...</Student> then we use RML to map
it to

http://ourdomain.com/resources/students/[http://ourdomain.com/resources/students/]{id} rdfs:type
http://ourdomain.com/ont/Student[http://ourdomain.com/ont/Student]

You can define your own URI generation scheme whatever works for you

You can read more about RDF Mapping Language (RML) from W3C website.

Regards

On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:

> I have a mixed set of datasets in XML, JSON, and RDF formats. I would like
> to convert all the XML/JSON ones to RDF such that I can only use one query
> language/library to access all the data, instead of having three different
> ones. I'm also not interested in using any particular ontology or
> vocabulary for the conversion, so anything will work as long as I can make
> the conversion.
> What would be an appropriate strategy for this? Since RDF requires
> absolute IRIs, would it be a good idea for example to convert all
> properties to http://example.org/property-name-1[http://example.org/property-name-1],
> http://example.org/property-name-2[http://example.org/property-name-2], ...? And maybe use UUIDs for nodes?
> Or is there a better way of doing this?
>

Re: Loosely converting JSON/XML to RDF

Posted by Alex To <to...@gmail.com>.
We have web services returning XML and JSON in our environment. We use
https://github.com/RMLio/rmlmapper-java to map XML/JSON to RDF with
satisfied results.

Or course you need a valid URI for your XML or Json elements for e.g. in
our XML, if we have <Student id="...">...</Student> then we use RML to map
it to

http://ourdomain.com/resources/students/{id}         rdfs:type
http://ourdomain.com/ont/Student

You can define your own URI generation scheme whatever works for you

You can read more about RDF Mapping Language (RML) from W3C website.

Regards

On Mon, 5 Nov 2018 at 6:34 pm, Laura Morales <la...@mail.com> wrote:

> I have a mixed set of datasets in XML, JSON, and RDF formats. I would like
> to convert all the XML/JSON ones to RDF such that I can only use one query
> language/library to access all the data, instead of having three different
> ones. I'm also not interested in using any particular ontology or
> vocabulary for the conversion, so anything will work as long as I can make
> the conversion.
> What would be an appropriate strategy for this? Since RDF requires
> absolute IRIs, would it be a good idea for example to convert all
> properties to http://example.org/property-name-1,
> http://example.org/property-name-2, ...? And maybe use UUIDs for nodes?
> Or is there a better way of doing this?
>

Re: Loosely converting JSON/XML to RDF

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Transform XML to RDF/XML or TriX using XSLT: https://www.w3.org/TR/xslt20/

XSLT 3.0 can also transform JSON: https://www.w3.org/TR/xslt-30/#json
On Mon, Nov 5, 2018 at 8:34 AM Laura Morales <la...@mail.com> wrote:
>
> I have a mixed set of datasets in XML, JSON, and RDF formats. I would like to convert all the XML/JSON ones to RDF such that I can only use one query language/library to access all the data, instead of having three different ones. I'm also not interested in using any particular ontology or vocabulary for the conversion, so anything will work as long as I can make the conversion.
> What would be an appropriate strategy for this? Since RDF requires absolute IRIs, would it be a good idea for example to convert all properties to http://example.org/property-name-1, http://example.org/property-name-2, ...? And maybe use UUIDs for nodes? Or is there a better way of doing this?