X-Git-Url: https://dreyeck.freedombox.rocks/gitweb/topic-maps.git/blobdiff_plain/17dd58775e25ab495e3c83deb4b5a36f5e5a124b..6a2f8446afca0915882f0d4a06cb891ccfcdc96d:/src/cxtm/canonicalizer.lisp?ds=inline diff --git a/src/cxtm/canonicalizer.lisp b/src/cxtm/canonicalizer.lisp index ab3800f..6d544ef 100644 --- a/src/cxtm/canonicalizer.lisp +++ b/src/cxtm/canonicalizer.lisp @@ -123,13 +123,21 @@ (when (and (string= (occurrence-datatype item) (integer-datatype)) (not (integer-lexical-p (occurrence-value item)))) (fail :invalid-integer-value "Occurrence value is not an xsd:integer lexical form.")) - ;; CXTM 3.16: these three remaining datatypes need additional canonical - ;; lexical rules. Unknown datatypes use Other, without interpretation. - (when (member (occurrence-datatype item) - '("http://www.w3.org/2001/XMLSchema#decimal" - "http://www.w3.org/2001/XMLSchema#date" - "http://www.w3.org/2001/XMLSchema#dateTime") :test #'string=) - (fail :unsupported-occurrence-datatype "CXTM 3.16 numeric/date canonicalization is not implemented." t)) + (when (and (string= (occurrence-datatype item) (decimal-datatype)) + (not (decimal-lexical-p (occurrence-value item)))) + (fail :invalid-decimal-value "Occurrence value is not an xsd:decimal lexical form.")) + (when (string= (occurrence-datatype item) (date-datatype)) + (unless (date-lexical-p (occurrence-value item)) + (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) (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-bce-timezone-rollover) + :datetime-bce-timezone-rollover :datetime-leap-second-context) + "DateTime BCE rollover/leap-second 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.")) @@ -216,6 +224,12 @@ Variants or non-Topic identifiers other than Occurrence identifiers. Does not mu (normalized-locator (occurrence-value item))) ((string= (occurrence-datatype item) (integer-datatype)) (canonical-integer-lexical-form (occurrence-value item))) + ((string= (occurrence-datatype item) (decimal-datatype)) + (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 "~%") ;; CXTM 3.14: datatype locator is NOT base-normalized.