Last active
September 21, 2021 15:05
-
-
Save sbarnum/8b0ea8d173af8a4932c7301e49cdc3cf to your computer and use it in GitHub Desktop.
SPDX3.0 example showing ids, id prefixes, external map, context metadata serialization in json-ld
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This example demonstrates: | |
- Element identifiers with appropriate structure of namespace+localid (does not presume any particular reserved separating character) | |
- A mix of new elements defined within a document-centric namespace, elements within other producer-controlled namespace, elements defined external to the document by other producer, etc | |
- Expression of prefixMap property of Document | |
- How a given serialization (json-ld in this case) can leverage the prefixMap to define id namespace prefixes | |
- How those prefixes are applied to Element ids throughout the example | |
- An external map characterizing all Elements within the Document that were not defined locally within the document | |
- Context metadata (createdBy, created, specVersion, etc) defined on the document with the serialization-dependent specific implication that this context metadata also applies to the Elements within the Document unless directly overridden with properties on the individual Elements | |
{ | |
"@context": [ | |
"https://www.spdx.org/ontology/spdx3.jsonld", | |
{ | |
"acmeFile": "https://www.acme.org/some/namespace/for/content/defined/in/this/file", | |
"acmeGeneral": "https://www.acme.org/some/namespace/for/general/content", | |
"fugazi": "https://www.fugazi.org/", | |
"fugaziExt": "https://www.fugazi.org/some/externally/defined/namespace", | |
"fugaziExtDoc": "https://www.fugazi.org/some/externally/defined/namespace/for/ExternalDocumentFoo" | |
} | |
], | |
"@graph": [ | |
{ | |
"@id": "acmeFile:Document1", | |
"@type": "core:Document", | |
"core:specVersion": "SPDX-3", | |
"core:createdBy": "acmeGeneral:AcmeIdentity", | |
"core:created": "2018-01-21T17:59:43.25Z", | |
"core:namespaceMap": [ | |
{ | |
"prefix": "acmeFile", | |
"namespace": "https://www.acme.org/some/namespace/for/content/defined/in/this/file" | |
}, | |
{ | |
"prefix": "acmeGeneral", | |
"namespace": "https://www.acme.org/some/namespace/for/general/content" | |
}, | |
{ | |
"prefix": "fugazi", | |
"namespace": "https://www.fugazi.org/" | |
}, | |
{ | |
"prefix": "fugaziExt", | |
"namespace": "https://www.fugazi.org/some/externally/defined/namespace" | |
}, | |
{ | |
"prefix": "fugaziExtDoc", | |
"namespace": "https://www.fugazi.org/some/externally/defined/namespace/for/ExternalDocumentFoo" | |
} | |
], | |
"core:externalMap": [ | |
{ | |
"core:externalID": "fugaziExt:ExternalDocumentFoo", | |
"core:verifiedUsing": [ | |
{ | |
"@type": "core:Hash", | |
"core:hashAlgorithm": "SHA256", | |
"core:hashValue": "961B6DD3EDE3CB8ECBAACBD68DE040CD78EB2ED5889130CCEB4C49268EA4D506" | |
} | |
], | |
"core:elementURL": "https://www.fugazi.org/some/externally/defined/namespace/docs/ExternalDocumentFoo-1.2-75306d2f-8dd5-402d-bfbc-d0a97e5a9b20", | |
"core:createdBy": "fugaziExt:identity-75306d2f-8dd5-402d-bfbc-d0a97e5a9b20" | |
}, | |
{ | |
"core:externalID": "fugaziExtDoc:cluster-autoscaler-9.9.0", | |
"core:definingDocument": "fugaziExt:ExternalDocumentFoo" | |
}, | |
{ | |
"core:externalID": "fugaziExtDoc:go", | |
"core:definingDocument": "fugaziExt:ExternalDocumentFoo" | |
}, | |
{ | |
"core:externalID": "fugaziExtDoc:azure-sdk-for-go", | |
"core:definingDocument": "fugaziExt:ExternalDocumentFoo" | |
}, | |
{ | |
"core:externalID": "fugazi:FugaziIdentity", | |
"core:verifiedUsing": [ | |
{ | |
"@type": "core:Hash", | |
"core:hashAlgorithm": "SHA256", | |
"core:hashValue": "A433244E170EA43AE36B90B7839F56A9069EDE0066C390C61317EF114BCECAD1" | |
} | |
], | |
"core:elementURL": "https://www.fugazi.org/some/externally/defined/namespace/identities/FugaziIdentity" | |
}, | |
{ | |
"core:externalID": "acmeGeneral:AcmeIdentity", | |
"core:verifiedUsing": [ | |
{ | |
"@type": "core:Hash", | |
"core:hashAlgorithm": "SHA256", | |
"core:hashValue": "ABB06D70213CEE6DCC3024F08C5F4D4A7F53E05431CCF74F1796F63882DFA04A" | |
} | |
] | |
} | |
], | |
"core:element": [ | |
{ | |
"@id": "acmeGeneral:AcmeIdentity", | |
"@type": "core:Organization", | |
"core:created": "2007-11-19T15:34:22.26Z", | |
"core:name": "ACME, Inc" | |
}, | |
{ | |
"@id": "acmeFile:foobar", | |
"@type": "software:File", | |
"software:fileType": "BINARY", | |
"core:name": "foobarzed" | |
}, | |
{ | |
"@id": "fugaziExtDoc:cluster-autoscaler-9.9.0", | |
"@type": "software:File", | |
"core:createdBy": "fugazi:FugaziIdentity", | |
"core:created": "2016-07-08T09:11:23.52Z", | |
"software:fileType": "BINARY", | |
"core:name": "cluster-autoscaler" | |
}, | |
{ | |
"@id": "fugaziExtDoc:go", | |
"@type": "core:Package", | |
"core:createdBy": "fugazi:FugaziIdentity", | |
"core:created": "2016-07-08T09:11:23.52Z", | |
"core:name": "cloud.google.com/go" | |
}, | |
{ | |
"@id": "fugaziExtDoc:azure-sdk-for-go", | |
"@type": "core:Package", | |
"core:createdBy": "fugazi:FugaziIdentity", | |
"core:created": "2016-07-08T09:11:23.52Z", | |
"core:name": "Azure/azure-sdk-for-go" | |
}, | |
{ | |
"@id": "acmeFile:Relationship1", | |
"@type": "core:Relationship", | |
"core:createdBy": "fugazi:FugaziIdentity", | |
"core:created": "2016-07-08T09:11:23.52Z", | |
"core:from": "fugaziExtDoc:go", | |
"core:to": "fugaziExtDoc:cluster-autoscaler-9.9.0", | |
"core:relationshipType": "STATIC_LINK" | |
}, | |
{ | |
"@id": "acmeFile:Relationship2", | |
"@type": "core:Relationship", | |
"core:createdBy": "fugazi:FugaziIdentity", | |
"core:created": "2016-07-08T09:11:23.52Z", | |
"from": "fugaziExtDoc:azure-sdk-for-go", | |
"to": "fugaziExtDoc:cluster-autoscaler-9.9.0", | |
"relationshipType": "STATIC_LINK" | |
} | |
] | |
} | |
] | |
} |
@goneall In my opinion generally the namespace should end with "#" so that they can be referenced.
example :
{
@context:
{
abc : www.xyz.org#
}
homepage : abc:index
}
So when the homepage is dereferenced it will be expanded in this form:
www.xyz.org#index
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Minor detail question should your namespace properties end with a "/" or "#"?