+ ((string= name "variant")
+ (attributes node '("reifier") nil)
+ (check-reifier node)
+ (let ((phase 0) (scope-seen nil) (resource-seen nil))
+ (dolist (child (elements node))
+ (check-namespace child)
+ (let* ((kind (node-name child))
+ (next (cond ((string= kind "itemIdentity") 0)
+ ((string= kind "scope") 1)
+ ((member kind '("resourceData" "resourceRef") :test #'string=) 2))))
+ (unless next (reject :unexpected-element (format nil "Unexpected ~A element." kind) child))
+ (when (< next phase) (reject :element-order "variant child order is invalid." child))
+ (setf phase next)
+ (cond
+ ((string= kind "itemIdentity") (leaf-href child) (unsupported child))
+ ((string= kind "scope")
+ (when scope-seen (reject :duplicate-variant-scope "Only one variant scope is allowed." child))
+ (setf scope-seen t))
+ (t
+ (unless scope-seen (reject :missing-variant-scope "variant requires scope before its resource." child))
+ (when resource-seen (reject :variant-resource-cardinality "variant requires exactly one resource." child))
+ (setf resource-seen t)))
+ (validate child '("scope" "resourceData" "resourceRef"))))
+ (unless scope-seen (reject :missing-variant-scope "variant requires a scope element." node))
+ (unless resource-seen (reject :missing-variant-resource "variant requires a resource element." node))))
+ ((string= name "resourceRef") (leaf-href node) (unsupported node))
+ ((string= name "resourceData")
+ (attributes node '("datatype") nil)
+ (when (and (attr node "datatype")
+ (not (equal (attr node "datatype") (topic-maps.tmdm:string-datatype))))
+ (reject :resource-data-datatype "Only textual xsd:string resourceData is implemented." node 'xtm-unsupported))
+ (dolist (child (node-children node))
+ (unless (stringp child)
+ (if (equal (node-uri child) +namespace+)
+ (reject :unexpected-child "resourceData cannot contain XTM markup." child)
+ (reject :resource-data-markup "Embedded XML resourceData is outside this subset." child 'xtm-unsupported)))))