Skip to content

Expanding ordered lists #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gkellogg opened this issue Jul 8, 2018 · 2 comments
Closed

Expanding ordered lists #9

gkellogg opened this issue Jul 8, 2018 · 2 comments
Labels
wontfix This will not be worked on

Comments

@gkellogg
Copy link
Member

gkellogg commented Jul 8, 2018

Consider the following inputs:

(1)

{
    "@graph": [{
        "@id": "http://example.com/Flintstone",
        "@type": [
            "http://www.w3.org/ns/shacl#PropertyShape"
        ],
        "http://www.w3.org/ns/shacl#or": [{
            "@list": [
                {
                    "http://www.w3.org/ns/shacl#class": [{
                        "@id": "http://example.com/Fred"
                    }]
                },
                {
                    "http://www.w3.org/ns/shacl#class": [{
                        "@id": "http://example.com/Wilma"
                    }]
                }
            ]
        }]
    }]
}

and

(2)

{
    "@graph": [
        {
            "@id": "http://example.com/Flintstone",
            "@type": [
                "http://www.w3.org/ns/shacl#PropertyShape"
            ],
            "http://www.w3.org/ns/shacl#or": [{
                "@id": "_:4"
            }]
        },
        {
            "@id": "_:4",
            "http://www.w3.org/1999/02/22-rdf-syntax-ns#first": [{
                "@id": "_:1"
            }],
            "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest": [{
                "@id": "_:2"
            }]
        },
        {
            "@id": "_:1",
            "http://www.w3.org/ns/shacl#class": [{
                "@id": "http://example.com/Fred"
            }]
        },
        {
            "@id": "_:2",
            "http://www.w3.org/1999/02/22-rdf-syntax-ns#first": [{
                "@id": "_:3"
            }],
            "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest": [{
                "@list": []
            }]
        },
        {
            "@id": "_:3",
            "http://www.w3.org/ns/shacl#class": [{
                "@id": "http://example.com/Wilma"
            }]
        }
    ]
}

When resolved as N-Quads on the playground, they both result in:

(3)

<http://example.com/Flintstone> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/shacl#PropertyShape> .
<http://example.com/Flintstone> <http://www.w3.org/ns/shacl#or> _:b0 .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:b1 .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:b2 .
_:b1 <http://www.w3.org/ns/shacl#class> <http://example.com/Fred> .
_:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:b3 .
_:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:b3 <http://www.w3.org/ns/shacl#class> <http://example.com/Wilma> .

In other words, they are semantically identical, ordered lists.

However, if i submit them to JSON-LD expansion, the former preserves @list, while the latter preserves the rdf:List construct. This causes knock-on inconsistencies when i compact and/or frame.

In order to resolve this, i propose that the expansion algorithm explicitly take into account rdf:Lists in expanded form. In other words, whether the input is (1) or (2), the result of expansion should always be:

[{
"@id": "http://example.com/Flintstone", 
"@type": ["http://www.w3.org/ns/shacl#PropertyShape"], 
"http://www.w3.org/ns/shacl#or": [
  {"@list": [
    {"http://www.w3.org/ns/shacl#class": [{"@id": "http://example.com/Fred"}]}, 
    {"http://www.w3.org/ns/shacl#class": [{"@id": "http://example.com/Wilma"}]}
  ]}]
}]

Alternatively, you can specify that any conversion to JSON-LD always convert rdfLists to @list form. This would then effectively make rdf:first/rdf:rest verboten in JSON-LD-land. I realize the algorithm seems to cover the conversion (though i admit not fully understanding how), but the spec itself does not preclude JSON-LD with explicit rdf:firsts.

Original issue: Expanding ordered lists #654.

@gkellogg
Copy link
Member Author

gkellogg commented Jul 8, 2018

I added this for WG review, but I don't think we'll end up bringing further RDF interpretation into algorithms other than to/from RDF. This would also mean interpreting rdf:type as @type, something we explicitly avoided in 1.0.

To work around this would be to turn your JSON-LD source using rdf:List into quads, and then perform the fromRDF algorithm to get it back into normal JSON-LD form.

@azaroth42 azaroth42 added the wontfix This will not be worked on label Aug 4, 2018
@azaroth42
Copy link
Contributor

Closing, wontfix, as the API should not make decisions based on rdf predicates.
WG Resolution: https://www.w3.org/2018/json-ld-wg/Meetings/Minutes/2018/2018-08-03-json-ld#section2-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants