trungdong / prov

A Python library for W3C Provenance Data Model (PROV)
http://prov.readthedocs.io/
MIT License
120 stars 44 forks source link

support for non-HTTP fully qualified URNs #132

Closed pohutukawa closed 5 years ago

pohutukawa commented 5 years ago

I am adding decentralised identifiers (DIDs) of the Decentralised Identity Foundation to PROV(-N) trails. However, this Python PROV library chokes with an exception when using those URIs directly (or in fact any full URL) to identify agents:

prov.model.ProvException: Invalid value for attribute prov:agent: did:ssid:8uQhQMGzWxR8vw5P3UWH1ja

or with a full (made up) URL:

prov.model.ProvException: Invalid value for attribute prov:agent: https://w3id.org/ssid/8uQhQMGzWxR8vw5P3UWH1ja

DIDs are fully qualified URNs, that have a provisional name added already to the IANA URI schemes:

https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml

In my opinion added short namespaces were only required as a convenience, but not necessity for long/full URIs.

Anyway, I think it would be good if these could be used (both above) in full at any time.

For now, I'm just adding a dummy did namespace shorthand, which resolves to did:

document
    ...
    prefix did <did:>
    ...
    wasAssociatedWith(kauriid:identityAttestation/01234,
                      did:ssid:2omXXXbobXXX...WEG, -,
                      [prov:hadRole="kauriid:attester"])
  endDocument

Please, also see the thread here on public-prov-comments mailing list:

https://lists.w3.org/Archives/Public/public-prov-comments/2019Mar/thread.html

trungdong commented 5 years ago

Hi @pohutukawa,

I think the main issue here is that a string is passed where the package is expecting a qualified name. In such cases, it will try to look for a registered namespace using something before a colon in the string. In the examples you gave, they are did: and https:. Since the registered namespaces did not have either of those, it failed. When you registered the did: namespace, it worked.

Following the PROV specs, two built-in namespaces are reserved and defined: prov: and xsd:. Other namespaces will need to be explicitly registered.

Also, it is the requirement of using qualified names as identifiers in PROV that necessitates namespace registration (https://www.w3.org/TR/prov-dm/#term-identifier); URIs cannot be used directly as identifiers in PROV.

pohutukawa commented 5 years ago

Hi @trungdong, thanks for the info/clarification!

Would I be 'doing it right' if I registered did as a prefix in the way as described above, or is that somewhat ugly/undesired to just register it as a prefix for did: itself?

trungdong commented 5 years ago

Yes, what you're doing is correct.