+ (push (list (type-reference (find "type" children :key #'node-name :test #'string=))
+ (reference (find "topicRef" children :key #'node-name :test #'string=))) roles)
+ (push child role-nodes)))))
+ (let ((association (read-item-identities node
+ (topic-maps.tmdm:make-association map type (reverse roles) :scope scope))))
+ ;; Match source metadata to the native Role by its complete signature
+ ;; within THIS canonical Parent. Role order/II are not equality keys.
+ (loop for pair in (reverse roles) for source in (reverse role-nodes) do
+ (let ((role (find-if (lambda (role)
+ (and (eq (topic-maps.tmdm:association-role-type role)
+ (topic-maps.tmdm:canonical-topic (first pair)))
+ (eq (topic-maps.tmdm:association-role-player role)
+ (topic-maps.tmdm:canonical-topic (second pair)))))
+ (topic-maps.tmdm:association-roles association))))
+ (read-item-identities source role)))
+ ;; Role metadata is now on the native canonical Parent. Reifier merging
+ ;; may normalize it again; return the resulting Association handle.
+ (topic-maps.tmdm:canonical-association
+ (read-item-reifier node association map))))))