]> dreyeck.freedombox.rocks Git - topic-maps.git/blobdiff - src/tmdm/occurrences.lisp
Implement CTM integer occurrences and canonical integer CXTM
[topic-maps.git] / src / tmdm / occurrences.lisp
index 7338d0180a40bdb8f0ade73072bbdd2a0906a6e8..5fd761b716ea632fdb97c00e1a2e7d51f840c6cf 100644 (file)
   map)
 (defun add-occurrence (topic type value &key (datatype (string-datatype)) item-identifiers)
   "Create an unscoped Occurrence; TYPE must be a same-map Topic. VALUE and DATATYPE
-are strings; anyURI VALUE must already be absolute (TMDM 4.3), never resolved here.
+are strings; DATATYPE is any absolute locator (TMDM 4.4). Its value space is not
+interpreted. anyURI VALUE must already be absolute, never resolved here.
 Validate before mutation, return current representative after duplicate replacement."
   (check-type value string) (check-type datatype string)
-  (unless (member datatype (list (string-datatype) (iri-datatype)) :test #'string=)
-    (occurrence-problem :unsupported-datatype "Only xsd:string and xsd:anyURI are supported."))
+  ;; TMDM 4.4/5.6: datatype is a locator, never a Topic or a whitelist.
+  (unless (absolute-locator-p datatype)
+    (occurrence-problem :invalid-datatype "Datatype must be a resolved absolute locator."))
+  (when (and (string= datatype (integer-datatype)) (not (integer-lexical-p value)))
+    (occurrence-problem :invalid-integer-value "Value is not an xsd:integer lexical form."))
   (when (and (string= datatype (iri-datatype)) (not (absolute-locator-p value)))
     (occurrence-problem :relative-uri-value "TMDM IRI-valued Occurrences require an absolute locator."))
   (let* ((topic (live-topic topic)) (type (live-topic type)) (map (%topic-parent topic)))