+ (reference (topic-name-type name)))
+ (require-set (topic-occurrences topic))
+ (dolist (item (topic-occurrences topic))
+ (require-exact-item item 'occurrence)
+ (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 (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."))
+ (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) "http://www.w3.org/2001/XMLSchema#dateTime")
+ (fail :unsupported-occurrence-datatype "DateTime 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."))
+ (let ((ids (occurrence-item-identifiers item)))
+ (unless (and (every #'topic-maps.tmdm::absolute-locator-p ids)
+ (= (length ids) (length (remove-duplicates ids :test #'string=))))
+ (fail :invalid-locators "Occurrence identifiers must be an absolute locator set.")))))