Skip to content

Support for nulls in RDF Lists to preserve positioning in the list when needed #196

@ebremer

Description

@ebremer

Why?

I have data to be modeled that generally fits within an ordered list structure, but some elements may be missing, but the position in the list must be held. In other words, position 2 in a list has a specific meaning. For example, in DICOM the Pixel Spacing attribute, the first position is row spacing and the second position is column spacing. One of the two values could be missing. see (https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_10.7.html#sect_10.7.1.3)

Proposed solution

I can define a list in Turtle as:

_:myList rdf:first 1; rdf:rest _:element2 .
_:element2 rdf:first 2 rdf:rest _:element3 .
_:element3 rdf:first 3; rdf:rest rdf:nil .

In SPARQL, I can express more concisely this list as (1 2 3 )

I can omit the triple _:element2 rdf:first 2 thus creating a "null" for the value of the second item, but I cannot say in SPARQL (1 null 3 ).
The only thing I can do is use an expanded SPARQL query and wrap a optional (or a minus) around the second element value:
optional { _:element2 rdf:first ?value2 }

It would be helpful to add a way to indicate that a list position is unbound such as (1 optional{ ?position2 } 3). In some cases, it would be desirable to have (1 minus { ?position2) 3) to match any list that is missing position 2.
Included in any mutation function (such as those mentioned in #151 , the ability to set a positional element to null. For example,
setValue(?myList,null,2) to remove an element in a list but preserve the positioning.

Considerations for backward compatibility

JSON-LD currently filters out RDF List elements that do not have a rdf:first value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions