]> dreyeck.freedombox.rocks Git - topic-maps.git/blobdiff - src/cxtm/canonicalizer.lisp
Support DateTime occurrences and expose normative baseline conflicts
[topic-maps.git] / src / cxtm / canonicalizer.lisp
index 8d726d89d03eb5831addf8a05799d2252844a723..65496a6377c8ece1cb9a35a34bdb64c58d0e0c3a 100644 (file)
               (fail :invalid-date-value "Occurrence value is not a valid XSD 1.0 date."))
             (unless (canonical-date-lexical-form (occurrence-value item))
               (fail :date-timezone-canonicalization "XSD date recoverable-timezone canonicalization is outside this slice." t)))
-          (when (string= (occurrence-datatype item) "http://www.w3.org/2001/XMLSchema#dateTime")
-            (fail :unsupported-occurrence-datatype "DateTime canonicalization is not implemented." t))
+          (when (string= (occurrence-datatype item) (datetime-datatype))
+            (unless (datetime-lexical-p (occurrence-value item))
+              (fail :invalid-datetime-value "Occurrence value is not a valid XSD 1.0 dateTime."))
+            (multiple-value-bind (value reason) (canonical-datetime-lexical-form (occurrence-value item))
+              (unless value (fail (if (eq reason :unsupported-timezone) :datetime-timezone-canonicalization :datetime-leap-second-context)
+                                  "DateTime timezone/leap context is outside this canonical subset." t))))
           (when (and (string= (occurrence-datatype item) (iri-datatype))
                      (not (topic-maps.tmdm::absolute-locator-p (occurrence-value item))))
             (fail :invalid-occurrence-value "IRI-valued Occurrences must store an absolute locator."))
@@ -223,6 +227,8 @@ Variants or non-Topic identifiers other than Occurrence identifiers. Does not mu
                              (canonical-decimal-lexical-form (occurrence-value item)))
                             ((string= (occurrence-datatype item) (date-datatype))
                              (canonical-date-lexical-form (occurrence-value item)))
+                            ((string= (occurrence-datatype item) (datetime-datatype))
+                             (canonical-datetime-lexical-form (occurrence-value item)))
                             (t (occurrence-value item))) out)
             (format out "</value>~%<datatype>")
             ;; CXTM 3.14: datatype locator is NOT base-normalized.