fatzh opened a new issue, #1254:
URL: https://github.com/apache/jena/issues/1254

   First off, thanks for the great software, we use it a lot and it's brilliant 
;) 
   
   I stumbled upon something today while trying to parse a json-ld response 
from Jena/Fuseki. I have a test store with a few books, their URIs look like 
this: `<http://onbetween.ch/3ms/cms#book_1>`.
   
   If there's a custom predicate `<http://onbetween.ch/3ms/cms#book>`, there's 
an overlap with the book URIs and the JSON-LD serialisation is no longer valid 
:-/ as I get book URIs like this: `book:_1`.
   
   Here's the very simple CONSTRUCT query that I send to Fuseki (version 4.4.0):
   
   ```
   In [67]: response = requests.post('http://localhost:3030/threems_example', 
data={'query': """
       ...: PREFIX cms: <http://onbetween.ch/3ms/cms#>
       ...:
       ...: CONSTRUCT {
       ...: ?a cms:book ?c
       ...: }
       ...: FROM <http://example/cmstest_data>
       ...: WHERE {
       ...: ?a a cms:Collection.
       ...: VALUES ?a { cms:collection_1 }.
       ...: ?c a cms:Book.
       ...: }
       ...: """})
   
   In [68]: print(response.content.decode())
   @prefix schema: <http://schema.org/> .
   @prefix threems: <http://onbetween.ch/3ms/core#> .
   @prefix owl:   <http://www.w3.org/2002/07/owl#> .
   @prefix cms:   <http://onbetween.ch/3ms/cms#> .
   @prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
   @prefix skos:  <http://www.w3.org/2004/02/skos/core#> .
   @prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
   @prefix cmsapi: <http://onbetween.ch/3ms/cmsapi#> .
   @prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
   @prefix xml:   <http://www.w3.org/XML/1998/namespace> .
   @prefix cmsui: <http://onbetween.ch/3ms/cmsui#> .
   @prefix dc:    <http://purl.org/dc/elements/1.1/> .
   
   cms:collection_1  cms:book  cms:book_B , cms:book_C , cms:book_2 , 
cms:book_1 , cms:book_A .
   ```
   
   Which is correct, got a simple collection with 5 books.
   
   Now if I request JSON-LD form Fuseki (just adding headers `Accept:  
application/ld+json` to the query)
   
   ```
   In [73]: response = requests.post('http://localhost:3030/threems_example', 
data={'query': """
       ...: PREFIX cms: <http://onbetween.ch/3ms/cms#>
       ...:
       ...: CONSTRUCT {
       ...: ?a cms:book ?c
       ...: }
       ...: FROM <http://example/cmstest_data>
       ...: WHERE {
       ...: ?a a cms:Collection.
       ...: VALUES ?a { cms:collection_1 }.
       ...: ?c a cms:Book.
       ...: }
       ...: """}, headers={'Accept':  'application/ld+json'})
   
   In [74]: print(response.content.decode())
   {
     "@id" : "cms:collection_1",
     "book" : [ "book:_B", "book:_C", "book:_2", "book:_1", "book:_A" ],
     "@context" : {
       "book" : {
         "@id" : "http://onbetween.ch/3ms/cms#book";,
         "@type" : "@id"
       },
       "schema" : "http://schema.org/";,
       "threems" : "http://onbetween.ch/3ms/core#";,
       "owl" : "http://www.w3.org/2002/07/owl#";,
       "cms" : "http://onbetween.ch/3ms/cms#";,
       "xsd" : "http://www.w3.org/2001/XMLSchema#";,
       "skos" : "http://www.w3.org/2004/02/skos/core#";,
       "rdfs" : "http://www.w3.org/2000/01/rdf-schema#";,
       "cmsapi" : "http://onbetween.ch/3ms/cmsapi#";,
       "xml" : "http://www.w3.org/XML/1998/namespace";,
       "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#";,
       "cmsui" : "http://onbetween.ch/3ms/cmsui#";,
       "dc" : "http://purl.org/dc/elements/1.1/";
     }
   }
   ```
   
   Fuseki serializes the books like this:
   
   `  "book" : [ "book:_B", "book:_C", "book:_2", "book:_1", "book:_A" ],`
   
   I wasn't sure if that's actually correct json-ld serialisation, but trying 
on the json-ld playground [here](https://tinyurl.com/y8jlny9t) I get this 
interpretation:
   
   ```
   <http://onbetween.ch/3ms/cms#collection_1> 
<http://onbetween.ch/3ms/cms#book> <book:_1> .
   <http://onbetween.ch/3ms/cms#collection_1> 
<http://onbetween.ch/3ms/cms#book> <book:_2> .
   <http://onbetween.ch/3ms/cms#collection_1> 
<http://onbetween.ch/3ms/cms#book> <book:_A> .
   <http://onbetween.ch/3ms/cms#collection_1> 
<http://onbetween.ch/3ms/cms#book> <book:_B> .
   <http://onbetween.ch/3ms/cms#collection_1> 
<http://onbetween.ch/3ms/cms#book> <book:_C> .
   ```
   
   Which is incorrect. Should be:
   
   ```
   <http://onbetween.ch/3ms/cms#collection_1> 
<http://onbetween.ch/3ms/cms#book> <http://onbetween.ch/3ms/cms#book_1> .
   <http://onbetween.ch/3ms/cms#collection_1> 
<http://onbetween.ch/3ms/cms#book> <http://onbetween.ch/3ms/cms#book_2> .
   <http://onbetween.ch/3ms/cms#collection_1> 
<http://onbetween.ch/3ms/cms#book> <http://onbetween.ch/3ms/cms#book_A> .
   <http://onbetween.ch/3ms/cms#collection_1> 
<http://onbetween.ch/3ms/cms#book> <http://onbetween.ch/3ms/cms#book_B> .
   <http://onbetween.ch/3ms/cms#collection_1> 
<http://onbetween.ch/3ms/cms#book> <http://onbetween.ch/3ms/cms#book_C> .
   ```
   
   It's a bit of an edge case, but actually for us this may happen when working 
with organisation specific ontologies. 
   
   I'm more of a python dev nowadays but if I can help let me know. If you can 
confirm it's a bug, I can also look into it, but I'm actually not 100% sure if 
that's not a JSON-LD spec issue. 
   
   Also if the predicate serialisation would be using the prefixes, i.e. 
`cms:book`, this wouldn't happen, we would have `cms:book_1`, something like:
   
   ```
   {
     "@id": "cms:collection_1",
     "cms:book": [
       "cms:book_B",
       "cms:book_C",
       "cms:book_2",
       "cms:book_1",
       "cms:book_A"
     ],
     "@context": {
       "cms:book": {
         "@id": "http://onbetween.ch/3ms/cms#book";,
         "@type": "@id"
       },
       "schema": "http://schema.org/";,
       "threems": "http://onbetween.ch/3ms/core#";,
       "owl": "http://www.w3.org/2002/07/owl#";,
       "cms": "http://onbetween.ch/3ms/cms#";,
       "xsd": "http://www.w3.org/2001/XMLSchema#";,
       "skos": "http://www.w3.org/2004/02/skos/core#";,
       "rdfs": "http://www.w3.org/2000/01/rdf-schema#";,
       "cmsapi": "http://onbetween.ch/3ms/cmsapi#";,
       "xml": "http://www.w3.org/XML/1998/namespace";,
       "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#";,
       "cmsui": "http://onbetween.ch/3ms/cmsui#";,
       "dc": "http://purl.org/dc/elements/1.1/";
     }
   }
   ```
   
   What do you think ?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to