Page MenuHomeSoftware Heritage

D7319.id26731.diff
No OneTemporary

D7319.id26731.diff

diff --git a/swh/deposit/tests/api/test_checks.py b/swh/deposit/tests/api/test_checks.py
--- a/swh/deposit/tests/api/test_checks.py
+++ b/swh/deposit/tests/api/test_checks.py
@@ -162,6 +162,38 @@
</entry>
""",
),
+ (
+ "codemeta-date-month",
+ # Allowed by ISO8601, therefore by schema:Date, but not by xsd:date
+ f"""\
+ <entry {XMLNS}>
+ <url>some url</url>
+ <external_identifier>some id</external_identifier>
+ <name>nar</name>
+ <author>no one</author>
+ <codemeta:datePublished>2020-12</codemeta:datePublished>
+ <codemeta:dateCreated>2020-12</codemeta:dateCreated>
+ <codemeta:dateModified>2020-12</codemeta:dateModified>
+ {PROVENANCE_XML}
+ </entry>
+ """,
+ ),
+ (
+ "codemeta-date-year",
+ # Allowed by ISO8601, therefore by schema:Date, but not by xsd:date
+ f"""\
+ <entry {XMLNS}>
+ <url>some url</url>
+ <external_identifier>some id</external_identifier>
+ <name>nar</name>
+ <author>no one</author>
+ <codemeta:datePublished>2020</codemeta:datePublished>
+ <codemeta:dateCreated>2020</codemeta:dateCreated>
+ <codemeta:dateModified>2020</codemeta:dateModified>
+ {PROVENANCE_XML}
+ </entry>
+ """,
+ ),
(
"codemeta-datetimes",
# technically, only Date is allowed for datePublished; but we allow DateTime
diff --git a/swh/deposit/xsd/codemeta.xsd b/swh/deposit/xsd/codemeta.xsd
--- a/swh/deposit/xsd/codemeta.xsd
+++ b/swh/deposit/xsd/codemeta.xsd
@@ -16,8 +16,18 @@
<xsd:element name="dateModified" type="codemeta:DateOrDateTime" />
<xsd:element name="embargoDate" type="xsd:date" />
+ <xsd:simpleType name="Date">
+ <!-- schema:Date allows truncated formats, but XML Schema primitive types
+ need to be joined to approximate it:
+ https://www.w3.org/TR/xmlschema-2/#truncatedformats
+ Note that this is stricter than ISO8601. For example, it does not
+ allow week dates or ordinal days.
+ -->
+ <xsd:union memberTypes="xsd:date xsd:gYearMonth xsd:gYear"/>
+ </xsd:simpleType>
+
<xsd:simpleType name="DateOrDateTime">
- <xsd:union memberTypes="xsd:date xsd:dateTime"/>
+ <xsd:union memberTypes="codemeta:Date xsd:dateTime"/>
</xsd:simpleType>
<xsd:element name="author" type="codemeta:PersonOrOrganization" />

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 3, 2:36 PM (4 d, 19 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3219238

Event Timeline