Skip to content

Handle blank nodes without blank node prefix properly #515

Open
@MarcusElevait

Description

@MarcusElevait

When having quads with blank nodes like this:

[
  {
    "termType": "Quad",
    "subject": {
      "termType": "BlankNode",
      "value": "n3-5"
    },
    "predicate": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#first"
    },
    "object": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
    },
    "graph": {
      "termType": "DefaultGraph",
      "value": ""
    }
  },
  {
    "termType": "Quad",
    "subject": {
      "termType": "BlankNode",
      "value": "n3-5"
    },
    "predicate": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"
    },
    "object": {
      "termType": "BlankNode",
      "value": "n3-6"
    },
    "graph": {
      "termType": "DefaultGraph",
      "value": ""
    }
  },
  {
    "termType": "Quad",
    "subject": {
      "termType": "BlankNode",
      "value": "n3-6"
    },
    "predicate": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#first"
    },
    "object": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type1"
    },
    "graph": {
      "termType": "DefaultGraph",
      "value": ""
    }
  },
  {
    "termType": "Quad",
    "subject": {
      "termType": "BlankNode",
      "value": "n3-6"
    },
    "predicate": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"
    },
    "object": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
    },
    "graph": {
      "termType": "DefaultGraph",
      "value": ""
    }
  },
  {
    "termType": "Quad",
    "subject": {
      "termType": "NamedNode",
      "value": "http://example.com/ns#PersonShape"
    },
    "predicate": {
      "termType": "NamedNode",
      "value": "http://www.w3.org/ns/shacl#ignoredProperties"
    },
    "object": {
      "termType": "BlankNode",
      "value": "n3-5"
    },
    "graph": {
      "termType": "DefaultGraph",
      "value": ""
    }
  }
]

where the value of the blank node is not prefixed with a blank node prefix, i would expect the library to parse to a proper json array like this:

{
    "http://www.w3.org/ns/shacl#ignoredProperties": [
        "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", 
        "http://www.w3.org/1999/02/22-rdf-syntax-ns#type1"
    ]
}

when using the fromRDF function.
But what we actually get is this:

[
  {
    "@id": "http://example.com/ns#PersonShape",
    "http://www.w3.org/ns/shacl#ignoredProperties": [
      {
        "@id": "n3-21"
      }
    ]
  },
  {
    "@id": "n3-21",
    "http://www.w3.org/1999/02/22-rdf-syntax-ns#first": [
      {
        "@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
      }
    ],
    "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest": [
      {
        "@list": [
          {
            "@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type1"
          }
        ]
      }
    ]
  }
]

As soon as i add the prefix '_:' to all blank node values, i get the proper json array output.
The rdfjs specification points out, that there should be no prefix on the blank node value. And when using a parser to e.g. parse a turtle serialized RDF to quads, they correctly remove the prefix from the value. But then it's not compatible with this library here.

So my question is, is the goal of this library here to stay in line with the rdfjs specification?
Because that's important to know for us, when deciding if we can use this library here in the future or not.

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