[ 
https://issues.apache.org/jira/browse/JENA-1744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andy Seaborne updated JENA-1744:
--------------------------------
    Description: 
Example Turtle file, no prefixes:

{noformat}
<http://somewhere/s1> <http://example/ns/(prop1)> "prop 1" .
<http://somewhere/s2> <http://example/ns/(prop2)> "prop 2" .
{noformat}

produces ({{riot --pretty JSONLD D.ttl}}) the JSON LD
{noformat}
{
  "@graph" : [ {
    "@id" : "http://somewhere/s1";,
    "http://example/ns/(prop1)" : "prop 1"
  }, {
    "@id" : "http://somewhere/s2";,
    "" : "prop 2"
  } ],
  "@context" : {
    "" : {
      "@id" : "http://example/ns/(prop2)"
    }
  }
}
{noformat}

which parses back to to the original RDF triples correctly.

However, the treatment of the two properties is asymmetric - one is context "" 
and one is full URI as "http://example/ns/(prop1)".

This can create problems downstream if the JSON-LD is treated as JSON (the 
motivating case is ingesting extracted RDF data into a BI-tool via it's JSON 
adapter).

The [JSONLD writer (line 
321)|https://github.com/apache/jena/blob/0dde76f777e55109a75db87c855bfc17e40c9d4a/jena-arq/src/main/java/org/apache/jena/riot/writer/JsonLDWriter.java#L321]
 uses "{{p.getLocalName()}}" to choose JSON-LD field name. In both cases, it is 
"" because "()" are legal in a URI but not legal for an RDF qname localname. 
The XML-split is the pair (full-URI, "").

JSON-LD does not need the restrictions need for RDF/XML. The split can be made 
at the "/". JSON-LD uses [curies|https://www.w3.org/TR/curie/].


  was:
Example Turtle file, no prefixes:

{noformat}
<http://somewhere/s1> <http://example/ns/(prop1)> "prop 1" .
<http://somewhere/s2> <http://example/ns/(prop2)> "prop 2" .
{noformat}

produces ({{riot --pretty JSONLD D.ttl}}) the JSON LD
{noformat}
{
  "@graph" : [ {
    "@id" : "http://somewhere/s1";,
    "http://example/ns/(prop1)" : "prop 1"
  }, {
    "@id" : "http://somewhere/s2";,
    "" : "prop 2"
  } ],
  "@context" : {
    "" : {
      "@id" : "http://example/ns/(prop2)"
    }
  }
}
{noformat}

which parses back to to the original RDF triples correctly.

However, the treatment of the two properties is asymmetric - one is context "" 
and one is full URI as "http://example/ns/(prop1)".

This can creat problems downstream if the JSON-LD is treated as JSON (the 
motivating case is ingesting into a BI-tool via it's JSON adapter).

This is because the [JSONLD writer (line 
321)|https://github.com/apache/jena/blob/0dde76f777e55109a75db87c855bfc17e40c9d4a/jena-arq/src/main/java/org/apache/jena/riot/writer/JsonLDWriter.java#L321]
 uses "{{p.getLocalName()}}" to choose JSON-LD field name. In both cases it is 
"" because "()" are legal in a URI but not legal for an RDF qname localname. 
The XML-split is (full-URI, "").



> JSON-LD writing handles non-qname property URI badly.
> -----------------------------------------------------
>
>                 Key: JENA-1744
>                 URL: https://issues.apache.org/jira/browse/JENA-1744
>             Project: Apache Jena
>          Issue Type: Improvement
>          Components: RIOT
>    Affects Versions: Jena 3.12.0
>            Reporter: Andy Seaborne
>            Assignee: Andy Seaborne
>            Priority: Major
>
> Example Turtle file, no prefixes:
> {noformat}
> <http://somewhere/s1> <http://example/ns/(prop1)> "prop 1" .
> <http://somewhere/s2> <http://example/ns/(prop2)> "prop 2" .
> {noformat}
> produces ({{riot --pretty JSONLD D.ttl}}) the JSON LD
> {noformat}
> {
>   "@graph" : [ {
>     "@id" : "http://somewhere/s1";,
>     "http://example/ns/(prop1)" : "prop 1"
>   }, {
>     "@id" : "http://somewhere/s2";,
>     "" : "prop 2"
>   } ],
>   "@context" : {
>     "" : {
>       "@id" : "http://example/ns/(prop2)"
>     }
>   }
> }
> {noformat}
> which parses back to to the original RDF triples correctly.
> However, the treatment of the two properties is asymmetric - one is context 
> "" and one is full URI as "http://example/ns/(prop1)".
> This can create problems downstream if the JSON-LD is treated as JSON (the 
> motivating case is ingesting extracted RDF data into a BI-tool via it's JSON 
> adapter).
> The [JSONLD writer (line 
> 321)|https://github.com/apache/jena/blob/0dde76f777e55109a75db87c855bfc17e40c9d4a/jena-arq/src/main/java/org/apache/jena/riot/writer/JsonLDWriter.java#L321]
>  uses "{{p.getLocalName()}}" to choose JSON-LD field name. In both cases, it 
> is "" because "()" are legal in a URI but not legal for an RDF qname 
> localname. The XML-split is the pair (full-URI, "").
> JSON-LD does not need the restrictions need for RDF/XML. The split can be 
> made at the "/". JSON-LD uses [curies|https://www.w3.org/TR/curie/].



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to