JsonLD icon indicating copy to clipboard operation
JsonLD copied to clipboard

Parse documents into interlinked object structures

Open lanthaler opened this issue 11 years ago • 3 comments

It should be possible to work directly with the data contained in a document. Some functionality that should be supported:

// load a document
$doc = Document::load('document.jsonld');

// get the default graph
$graph = $doc->getGraph();

// get all nodes in the document
$nodes = $graph->getNodes();

// retrieve a node by ID
$node = $graph->getNode('http://example.com/node1');

// get a property
$node->getProperty('http://example.com/vocab/name');

// add a new blank node to the document
$newNode = $graph->createNode();

// link the new blank node to the existing node
$node->addPropertyValue('http://example.com/vocab/link', $newNode);

// even reverse properties are supported; this returns $newNode
$node->getReverseProperty('http://example.com/vocab/link');

At a later point, it should also be possible to query for nodes or properties.

lanthaler avatar Sep 07 '12 13:09 lanthaler

Merging graphs, currently doesn't work as blank nodes aren't relabeled properly. There's a bigger problem with the current implementation as nodes are generated at the graph level instead of the document level. This means that blank node graphs which are either shared between graphs or also used a graph names might get relabeled differently.

lanthaler avatar Mar 19 '14 23:03 lanthaler

Just a thought: why not change the blank node ID generator function so it builds long random hashes instead of _:b1?

k00ni avatar Aug 22 '22 12:08 k00ni

This stems from compatibility with the JSON-LD spec. Such blank node IDs need to be generated for other methods which are reused internally by this function.

lanthaler avatar Aug 22 '22 19:08 lanthaler