X-Git-Url: https://dreyeck.freedombox.rocks/gitweb/topic-maps.git/blobdiff_plain/437ad53ea7539d36db3fa871d0931650b7a6a03e..17dd58775e25ab495e3c83deb4b5a36f5e5a124b:/src/cxtm/canonicalizer.lisp?ds=sidebyside diff --git a/src/cxtm/canonicalizer.lisp b/src/cxtm/canonicalizer.lisp index a788853..ab3800f 100644 --- a/src/cxtm/canonicalizer.lisp +++ b/src/cxtm/canonicalizer.lisp @@ -118,8 +118,18 @@ (unless (and (eq item (canonical-occurrence item)) (eq (occurrence-parent item) topic)) (fail :invalid-parent "Occurrence must be current and owned by its containing Topic.")) (reference (occurrence-type item)) - (unless (member (occurrence-datatype item) (list (string-datatype) (iri-datatype)) :test #'string=) - (fail :unsupported-occurrence-datatype "Only string and anyURI values are supported." t)) + (unless (topic-maps.tmdm::absolute-locator-p (occurrence-datatype item)) + (fail :invalid-occurrence-datatype "Datatype must be an absolute locator.")) + (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) (iri-datatype)) (not (topic-maps.tmdm::absolute-locator-p (occurrence-value item)))) (fail :invalid-occurrence-value "IRI-valued Occurrences must store an absolute locator.")) @@ -202,8 +212,11 @@ Variants or non-Topic identifiers other than Occurrence identifiers. Does not mu (type-ref (topic-name-type name)) (format out "~%")) (loop for item in (sorted (topic-occurrences topic) #'occurrence-order) for index from 1 do (format out "~%" index) - (xml-text (if (string= (occurrence-datatype item) (iri-datatype)) - (normalized-locator (occurrence-value item)) (occurrence-value item)) out) + (xml-text (cond ((string= (occurrence-datatype item) (iri-datatype)) + (normalized-locator (occurrence-value item))) + ((string= (occurrence-datatype item) (integer-datatype)) + (canonical-integer-lexical-form (occurrence-value item))) + (t (occurrence-value item))) out) (format out "~%") ;; CXTM 3.14: datatype locator is NOT base-normalized. (xml-text (occurrence-datatype item) out) (format out "~%")