pod-os / PodOS

Personal Online Data Operating System
MIT License
13 stars 1 forks source link

Should pos-resource support blank nodes? #35

Open josephguillaume opened 6 months ago

josephguillaume commented 6 months ago

There might be an architectural decision to make here. I'll describe my use case and current blockers.

I use pos-resource to make a resource available to descendants. This includes creating pos-resource elements and setting their uri programmatically (usually with lazy=true)

When the resource is a blank node, pos-resource errors with e.g. NamedNode IRI "_g_L9C317" must be absolute

I would need to confirm, but it appears the error is thrown by os.store.get when checking editable, which in turn assumes that the Uri is a named node: https://github.com/linkeddata/rdflib.js/blob/cd9a5960ef01bf9350c55a349db4410bc029a796/src/update-manager.ts#L154

There are other places that the PodOs code currently assumes a Uri is a named node/sym, e.g. https://github.com/pod-os/PodOS/blob/e4904287890fa3c03a37fb485d0b78ddd893cc34/core/src/thing/Thing.ts#L99

Current workaround is to rewrite data to avoid using blank nodes.

Issues to address:

angelo-v commented 5 months ago

You are right, PodOS mostly assumes named nodes currently and I did not spent much thoughts on blank nodes(yet). I am trying to avoid them as described in your workaround.

Some things come to my mind, but the whole blank node situation must be carefully thought through:

josephguillaume commented 5 months ago

My current use case actually relates to collections - my list component creates pos-resource elements and sets their uri. Calling lazy=true suppresses fetching but allows descendants to receive the resource.

If it's a blank node, the uri starts with an underscore, e.g. _g_L9C317

Options for renaming would be resource or about. consistent with https://www.w3.org/TR/rdfa-lite/#resource or https://www.w3.org/TR/rdfa-primer/#alternative-for-setting-the-context-about PodOS has the potential for its DOM to become valid RDFa.

Just checking now, it turns out RDFa supports explicitly defining blank nodes, which would work well for our case here. https://www.w3.org/TR/rdfa-core/#s_blankNodes