Changeset View
Changeset View
Standalone View
Standalone View
docs/specs/protocol-reference.rst
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | |||||
While the SWORDv2 specification recommends the use of DublinCore_, | While the SWORDv2 specification recommends the use of DublinCore_, | ||||
we prefer the CodeMeta_ vocabulary, as we already use it in other components | we prefer the CodeMeta_ vocabulary, as we already use it in other components | ||||
of Software Heritage. | of Software Heritage. | ||||
While CodeMeta is designed for use in JSON-LD, it is easy to reuse its vocabulary | While CodeMeta is designed for use in JSON-LD, it is easy to reuse its vocabulary | ||||
and embed it in an XML document, in three steps: | and embed it in an XML document, in three steps: | ||||
1. use the JSON-LD compact representation of the CodeMeta document | 1. use the `JSON-LD compact representation`_ of the CodeMeta document with | ||||
2. replace ``@context`` declarations with XML namespaces | ``@context: "https://doi.org/10.5063/SCHEMA/CODEMETA-2.0"`` and no other context; | ||||
3. unfold JSON lists to sibling XML subtrees | which implies that: | ||||
1. Codemeta properties (whether in the ``https://codemeta.github.io/terms/`` | |||||
or ``http://schema.org/`` namespaces) are unprefixed terms | |||||
2. other properties in the ``http://schema.org/`` namespace use `compact IRIs`_ | |||||
with the ``schema`` prefix | |||||
3. other properties are absolute | |||||
2. replace ``@context`` declarations with a XMLNS declaration with | |||||
``https://doi.org/10.5063/SCHEMA/CODEMETA-2.0`` as namespace | |||||
(eg. ``xmlns="https://doi.org/10.5063/SCHEMA/CODEMETA-2.0"`` | |||||
or ``xmlns:codemeta="https://doi.org/10.5063/SCHEMA/CODEMETA-2.0"``) | |||||
3. if using a non-default namespace, apply its prefix to any unprefixed term | |||||
(ie. any term defined in https://doi.org/10.5063/SCHEMA/CODEMETA-2.0 ) | |||||
ardumont: ;) | |||||
4. add XMLNS declarations for any other prefix (eg. ``xmlns:schema="http://schema.org/"`` | |||||
if any property in that namespace is used) | |||||
5. unfold JSON lists to sibling XML subtrees | |||||
For example, this CodeMeta document: | .. _JSON-LD compact representation: https://www.w3.org/TR/json-ld11/#compacted-document-form | ||||
.. _compact IRIs: https://www.w3.org/TR/json-ld11/#compact-iris | |||||
Example Codemeta document | |||||
""""""""""""""""""""""""" | |||||
.. code:: json | .. code:: json | ||||
{ | { | ||||
"@context": "https://doi.org/10.5063/SCHEMA/CODEMETA-2.0", | "@context": "https://doi.org/10.5063/SCHEMA/CODEMETA-2.0", | ||||
"name": "My Software", | "name": "My Software", | ||||
"author": [ | "author": [ | ||||
{ | { | ||||
Show All 36 Lines | <codemeta:author> | ||||
<codemeta:email>foo@example.org</codemeta:email> | <codemeta:email>foo@example.org</codemeta:email> | ||||
</codemeta:author> | </codemeta:author> | ||||
<codemeta:author> | <codemeta:author> | ||||
<codemeta:name>Author 2</codemeta:name> | <codemeta:name>Author 2</codemeta:name> | ||||
</codemeta:author> | </codemeta:author> | ||||
</entry> | </entry> | ||||
Note that in both these examples, ``codemeta:name`` is used even though | |||||
the property is actually ``http://schema.org/name``. | |||||
Example generic JSON-LD document | |||||
"""""""""""""""""""""""""""""""" | |||||
Another example using properties not part of Codemeta: | |||||
.. code:: json | |||||
{ | |||||
"@context": "https://doi.org/10.5063/SCHEMA/CODEMETA-2.0", | |||||
"name": "My Software", | |||||
"schema:sameAs": "http://example.org/my-software" | |||||
} | |||||
which is equivalent to: | |||||
.. code:: json | |||||
{ | |||||
"@context": "https://doi.org/10.5063/SCHEMA/CODEMETA-2.0", | |||||
"name": "My Software", | |||||
"http://schema.org/sameAs": "http://example.org/my-software" | |||||
} | |||||
becomes this XML document: | |||||
.. code:: xml | |||||
<?xml version="1.0"?> | |||||
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" | |||||
xmlns="https://doi.org/10.5063/SCHEMA/CODEMETA-2.0" | |||||
xmlns:schema="http://schema.org/"> | |||||
<name>My Software</name> | |||||
<schema:sameAs>http://example.org/my-software</schema:sameAs> | |||||
</atom:entry> | |||||
Or, equivalently: | |||||
.. code:: xml | |||||
<?xml version="1.0"?> | |||||
<entry xmlns="http://www.w3.org/2005/Atom" | |||||
xmlns:codemeta="https://doi.org/10.5063/SCHEMA/CODEMETA-2.0" | |||||
xmlns:schema="http://schema.org/"> | |||||
<codemeta:name>My Software</codemeta:name> | |||||
<schema:sameAs>http://example.org/my-software</schema:sameAs> | |||||
</entry> | |||||
.. _mandatory-attributes: | .. _mandatory-attributes: | ||||
Mandatory attributes | Mandatory attributes | ||||
^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^ | ||||
All deposits must include: | All deposits must include: | ||||
* an ``<atom:author>`` tag with an ``<atom:name>`` and ``<atom:email>``, and | * an ``<atom:author>`` tag with an ``<atom:name>`` and ``<atom:email>``, and | ||||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |
;)