You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Quentin Reul <Qu...@gmail.com> on 2015/07/16 17:12:12 UTC
Parsing / reparsing JSON-LD content
Hi all,
As part of one of our projects, we are using Jena 1.3 to process RDF
content in different serialization. When creating a RDF/XML output from a
JSON-LD output (created by another process using Jena 1.3), we have
identified an issue with the encoding. More specifically, the encoding of
resources in JSON-LD leads to the information being represented as a
literal in RDF/XML.
Let us assume that we have the following JSON-LD object:
{
"@id" : "http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10",
"@type" : "http://onto.wolterskluwer.com/pci/cpe/ProfileItem",
"source" : "rvctc3.02.02#DE3233",
"identifier" : "CGLS10",
"isPartOf" :
"http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004",
"notation" : "GZM",
"prefLabel" : {
"@language" : "en",
"@value" : "Tax losses, excluding film losses, transferred after
consolidation from a trust."
}
}
when we process the RDF statement and output it as RDF/XML, we have
the following:
<rdf:Description
rdf:about="http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10">
<dcterms:identifier>CGLS10</dcterms:identifier>
<skos:notation>GZM</skos:notation>
<dc:source>rvctc3.02.02#DE3233</dc:source>
<dcterms:isPartOf>http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004</dcterms:isPartOf>
<rdf:type rdf:resource="http://onto.wolterskluwer.com/pci/cpe/ProfileItem"/>
<skos:prefLabel xml:lang="en">Tax losses, excluding film losses,
transferred after consolidation from a trust.</skos:prefLabel>
</rdf:Description>
As y
Re: Parsing / reparsing JSON-LD content
Posted by Stian Soiland-Reyes <st...@apache.org>.
This is JSON-LD issue in your context, Jena is interpreting it correctly.
You need to have "@type": "@id" for "isPartOf" in JSON-LD for simple
strings to be interpreted as a IRI, e.g.:
"isPartOf" : { "@id": "http://purl.org/dc/terms/isPartOf",
"@type": "@id" },
Try also in the JSON-LD playground to N-Quads, which with your
original context also concludes:
<http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10>
<http://purl.org/dc/terms/isPartOf>
"http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004" .
http://json-ld.org/playground/
Modified context, see http://json-ld.org/playground/#/gist/ad624b7bfca63d9ad625
gives the expected:
<http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10>
<http://purl.org/dc/terms/isPartOf>
<http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004> .
(BTW: Also you can't have unescaped newlines within JSON values)
On 16 July 2015 at 17:57, Quentin Reul <de...@googlemail.com> wrote:
> Hi Damian,
>
> Thanks for your quick reply.
>
> With regards to the Jena version, it should have read 1.13 (instead of 1.3).
>
> With regards to the JSON-LD output, the current context information is as
> follows:
> "@context" : {
> "identifier" : "http://purl.org/dc/terms/identifier",
> "notation" : "http://www.w3.org/2004/02/skos/core#notation",
> "source" : "http://purl.org/dc/elements/1.1/source",
> "isPartOf" : "http://purl.org/dc/terms/isPartOf",
> "prefLabel" : "http://www.w3.org/2004/02/skos/core#prefLabel",
> "scopeNote" : "http://www.w3.org/2004/02/skos/core#scopeNote",
> "type" : "http://purl.org/dc/elements/1.1/type",
> "dc" : "http://purl.org/dc/elements/1.1/",
> "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
> "skos" : "http://www.w3.org/2004/02/skos/core#",
> "dcterms" : "http://purl.org/dc/terms/"
> }
> As you can see, the context does not include @id as part of the definition
> of "isPartOf". The JSON-LD information is created by another Jena-based
> application.
>
> Cheers,
>
> Quentin
>
>
>
> On 16 July 2015 at 10:55, Damian Steer <d....@bris.ac.uk> wrote:
>
>>
>> > On 16 Jul 2015, at 16:17, Quentin Reul <Qu...@gmail.com> wrote:
>> >
>> > Hi all,
>> >
>> > [Sorry for duplicate]
>> >
>> > As part of one of our projects, we are using Jena 1.3
>>
>> Are you sure about that version?
>>
>> > Let us assume that we have the following JSON-LD object:
>> >
>> > {
>> > "@id" : "
>> http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10",
>> > "@type" : "http://onto.wolterskluwer.com/pci/cpe/ProfileItem",
>> > "source" : "rvctc3.02.02#DE3233",
>> > "identifier" : "CGLS10",
>> > "isPartOf" : "
>> http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004",
>> > "notation" : "GZM",
>> > "prefLabel" : {
>> > "@language" : "en",
>> > "@value" : "Tax losses, excluding film losses, transferred after
>> > consolidation from a trust."
>> > }
>> > }
>>
>> From what you’ve written it sounds like you produced this json-ld from
>> java code where the value of isPartOf was a resource (“in the Java code, we
>> are encoding
>> http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004 as a
>> resource”). However this isn’t the output I’d expect at all.[1]
>>
>> Could you explain where this json came from?
>>
>> Damian
>>
>> [1] This would work (note the added @context):
>>
>> {
>> "@context" : { "@vocab" : "http://purl.org/dc/terms/", "isPartOf" : {
>> "@type": "@id" } },
>> "@id" : "
>> http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10",
>> "@type" : "http://onto.wolterskluwer.com/pci/cpe/ProfileItem",
>> "source" : "rvctc3.02.02#DE3233",
>> "identifier" : "CGLS10",
>> "isPartOf" : "http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004
>> ",
>> "notation" : "GZM",
>> "prefLabel" : {
>> "@language" : "en",
>> "@value" : "Tax losses, excluding film losses, transferred after
>> consolidation from a trust."
>> }
>> }
>>
>> --
>> Damian Steer
>> Senior Technical Researcher
>> Research IT
>> +44 (0) 117 928 7057
>>
>>
--
Stian Soiland-Reyes
Apache Taverna (incubating), Apache Commons RDF (incubating)
http://orcid.org/0000-0001-9842-9718
Re: Parsing / reparsing JSON-LD content
Posted by Quentin Reul <de...@googlemail.com>.
Hi Damian,
Thanks for your quick reply.
With regards to the Jena version, it should have read 1.13 (instead of 1.3).
With regards to the JSON-LD output, the current context information is as
follows:
"@context" : {
"identifier" : "http://purl.org/dc/terms/identifier",
"notation" : "http://www.w3.org/2004/02/skos/core#notation",
"source" : "http://purl.org/dc/elements/1.1/source",
"isPartOf" : "http://purl.org/dc/terms/isPartOf",
"prefLabel" : "http://www.w3.org/2004/02/skos/core#prefLabel",
"scopeNote" : "http://www.w3.org/2004/02/skos/core#scopeNote",
"type" : "http://purl.org/dc/elements/1.1/type",
"dc" : "http://purl.org/dc/elements/1.1/",
"rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"skos" : "http://www.w3.org/2004/02/skos/core#",
"dcterms" : "http://purl.org/dc/terms/"
}
As you can see, the context does not include @id as part of the definition
of "isPartOf". The JSON-LD information is created by another Jena-based
application.
Cheers,
Quentin
On 16 July 2015 at 10:55, Damian Steer <d....@bris.ac.uk> wrote:
>
> > On 16 Jul 2015, at 16:17, Quentin Reul <Qu...@gmail.com> wrote:
> >
> > Hi all,
> >
> > [Sorry for duplicate]
> >
> > As part of one of our projects, we are using Jena 1.3
>
> Are you sure about that version?
>
> > Let us assume that we have the following JSON-LD object:
> >
> > {
> > "@id" : "
> http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10",
> > "@type" : "http://onto.wolterskluwer.com/pci/cpe/ProfileItem",
> > "source" : "rvctc3.02.02#DE3233",
> > "identifier" : "CGLS10",
> > "isPartOf" : "
> http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004",
> > "notation" : "GZM",
> > "prefLabel" : {
> > "@language" : "en",
> > "@value" : "Tax losses, excluding film losses, transferred after
> > consolidation from a trust."
> > }
> > }
>
> From what you’ve written it sounds like you produced this json-ld from
> java code where the value of isPartOf was a resource (“in the Java code, we
> are encoding
> http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004 as a
> resource”). However this isn’t the output I’d expect at all.[1]
>
> Could you explain where this json came from?
>
> Damian
>
> [1] This would work (note the added @context):
>
> {
> "@context" : { "@vocab" : "http://purl.org/dc/terms/", "isPartOf" : {
> "@type": "@id" } },
> "@id" : "
> http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10",
> "@type" : "http://onto.wolterskluwer.com/pci/cpe/ProfileItem",
> "source" : "rvctc3.02.02#DE3233",
> "identifier" : "CGLS10",
> "isPartOf" : "http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004
> ",
> "notation" : "GZM",
> "prefLabel" : {
> "@language" : "en",
> "@value" : "Tax losses, excluding film losses, transferred after
> consolidation from a trust."
> }
> }
>
> --
> Damian Steer
> Senior Technical Researcher
> Research IT
> +44 (0) 117 928 7057
>
>
Re: Parsing / reparsing JSON-LD content
Posted by Damian Steer <d....@bris.ac.uk>.
> On 16 Jul 2015, at 16:17, Quentin Reul <Qu...@gmail.com> wrote:
>
> Hi all,
>
> [Sorry for duplicate]
>
> As part of one of our projects, we are using Jena 1.3
Are you sure about that version?
> Let us assume that we have the following JSON-LD object:
>
> {
> "@id" : "http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10",
> "@type" : "http://onto.wolterskluwer.com/pci/cpe/ProfileItem",
> "source" : "rvctc3.02.02#DE3233",
> "identifier" : "CGLS10",
> "isPartOf" : "http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004",
> "notation" : "GZM",
> "prefLabel" : {
> "@language" : "en",
> "@value" : "Tax losses, excluding film losses, transferred after
> consolidation from a trust."
> }
> }
From what you’ve written it sounds like you produced this json-ld from java code where the value of isPartOf was a resource (“in the Java code, we are encoding
http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004 as a resource”). However this isn’t the output I’d expect at all.[1]
Could you explain where this json came from?
Damian
[1] This would work (note the added @context):
{
"@context" : { "@vocab" : "http://purl.org/dc/terms/", "isPartOf" : { "@type": "@id" } },
"@id" : "http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10",
"@type" : "http://onto.wolterskluwer.com/pci/cpe/ProfileItem",
"source" : "rvctc3.02.02#DE3233",
"identifier" : "CGLS10",
"isPartOf" : "http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004",
"notation" : "GZM",
"prefLabel" : {
"@language" : "en",
"@value" : "Tax losses, excluding film losses, transferred after consolidation from a trust."
}
}
--
Damian Steer
Senior Technical Researcher
Research IT
+44 (0) 117 928 7057
Re: Parsing / reparsing JSON-LD content
Posted by Quentin Reul <Qu...@gmail.com>.
Hi all,
[Sorry for duplicate]
As part of one of our projects, we are using Jena 1.3 to process RDF
content in different serialization. When creating a RDF/XML output from a
JSON-LD output (created by another process using Jena 1.3), we have
identified an issue with the encoding. More specifically, the encoding of
resources in JSON-LD leads to the information being represented as a
literal in RDF/XML.
Let us assume that we have the following JSON-LD object:
{
"@id" : "http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10",
"@type" : "http://onto.wolterskluwer.com/pci/cpe/ProfileItem",
"source" : "rvctc3.02.02#DE3233",
"identifier" : "CGLS10",
"isPartOf" : "http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004",
"notation" : "GZM",
"prefLabel" : {
"@language" : "en",
"@value" : "Tax losses, excluding film losses, transferred after
consolidation from a trust."
}
}
when we process the RDF statement and output it as RDF/XML, we have
the following:
<rdf:Description
rdf:about="http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004#CGLS10">
<dcterms:identifier>CGLS10</dcterms:identifier>
<skos:notation>GZM</skos:notation>
<dc:source>rvctc3.02.02#DE3233</dc:source>
<dcterms:isPartOf>http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004</dcterms:isPartOf>
<rdf:type rdf:resource="http://onto.wolterskluwer.com/pci/cpe/ProfileItem"/>
<skos:prefLabel xml:lang="en">Tax losses, excluding film losses,
transferred after consolidation from a trust.</skos:prefLabel>
</rdf:Description>
In the Java code, we are encoding
http://data.wolterskluwer.com/au/cch/taxform/2014/CGLS0004 as a
resource and would have expected rdf:resource to be used to express
the link between the two resources. Looking online, we replaced
model.write($os, "JSON-LD"); by RDFDataMgr.write($os, $model,
RDFFormat.JSONLD) ; thinking that it could resolve the issue (but to
no avail). I saw an issue on JIRA [1] that seem to relate to the same
issue, but I'm not a 100%.
Please advise.
Quentin
[1] https://issues.apache.org/jira/browse/MARMOTTA-306