]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - tests/xtm-occurrence-reification.lisp
Document XTM normative coverage and remaining qualification gaps
[topic-maps.git] / tests / xtm-occurrence-reification.lisp
1 (in-package #:topic-maps.xtm.tests)
2
3 (defun orr-current-p (map)
4 (and (ik-current-p map)
5 (every (lambda (o) (let ((r (item-reifier o)))
6 (or (null r) (and (eq r (canonical-topic r)) (eq map (topic-parent r)) (eq o (topic-reified r)))))) (all-occurrences map))))
7 (defun orr-model (map)
8 (let ((topics (topic-map-topics map)))
9 (mm-fields "existingModel" (ik-model map) "canonicalOccurrenceReifierInverseEQ" (if (orr-current-p map) :true :false)
10 "occurrenceReifiers" (coerce (loop for o in (all-occurrences map) collect
11 (mm-fields "itemIdentifiers" (coerce (item-identifiers o) 'vector)
12 "reifierTopic" (when (item-reifier o) (1+ (position (item-reifier o) topics :test #'eq)))
13 "reifierItemIdentifiers" (coerce (when (item-reifier o) (item-identifiers (item-reifier o))) 'vector)
14 "inverseReifiedEQ" (if (or (null (item-reifier o)) (eq o (topic-reified (item-reifier o)))) :true :false))) 'vector))))
15 (defun orr-observe (raw key)
16 (let ((parser (symbol-function 'topic-maps.xml:parse-octets))
17 (reader (symbol-function 'topic-maps.xtm::read-occurrence))
18 (calls 0) (same nil) (held nil) (counts nil) (map nil))
19 (unwind-protect
20 (progn
21 (setf (symbol-function 'topic-maps.xml:parse-octets)
22 (lambda (input &rest args) (incf calls) (setf same (eq raw input)) (apply parser input args)))
23 (setf (symbol-function 'topic-maps.xtm::read-occurrence)
24 (lambda (node owner model)
25 (let ((o (funcall reader node owner model)))
26 (pushnew o held :test #'eq) (when (item-reifier o) (pushnew (item-reifier o) held :test #'eq))
27 (push (length (all-occurrences model)) counts) o)))
28 (setf map (deserialize-octets raw :document-iri *document* :source-key key)))
29 (setf (symbol-function 'topic-maps.xml:parse-octets) parser
30 (symbol-function 'topic-maps.xtm::read-occurrence) reader))
31 (values map held (nreverse counts) calls same)))
32 (defun orr-held-p (map held)
33 (every (lambda (i) (member (topic-maps.tmdm::canonical-item i) (topic-maps.tmdm::map-information-items map) :test #'eq)) held))
34 (defun orr-pure (label map held)
35 (let ((before (ik-state map)) (cx (mm-cxtm map)))
36 (check (format nil "occurrence-reifier:~A:pure-repeated-CXTM-identifiers-reifiers-handles" label)
37 (and (equalp cx (mm-cxtm map)) (equal before (ik-state map)) (orr-current-p map) (orr-held-p map held))) cx))
38 (defun orr-condition-from (raw key &optional resolver)
39 ;; Observe a real failed native assignment on its actual Map. Ignore inner
40 ;; disposable preflight calls; propagate the original native condition object.
41 (let ((saved (symbol-function 'set-item-reifier)) (depth 0) (frames nil) (c nil))
42 (unwind-protect
43 (progn
44 (setf (symbol-function 'set-item-reifier)
45 (lambda (item topic)
46 (incf depth)
47 (unwind-protect
48 (let* ((map (topic-maps.tmdm::item-topic-map item)) (before (ik-state map))
49 (prior (and topic (topic-reified topic))))
50 (handler-case (funcall saved item topic)
51 (error (condition)
52 (when (= depth 1)
53 (push (mm-fields "assignedItemKind" (string (type-of item))
54 "priorReifiedItemKind" (when prior (string (type-of prior)))
55 "requestedReifierII" (coerce (when topic (item-identifiers topic)) 'vector)
56 "nativeAssignmentUnchanged" (if (equal before (ik-state map)) :true :false)) frames))
57 (error condition))))
58 (decf depth))))
59 (setf c (condition-from (lambda () (deserialize-octets raw :document-iri *document* :source-key key :resource-resolver resolver)))))
60 (setf (symbol-function 'set-item-reifier) saved))
61 (values c (nreverse frames))))
62 (defun occurrence-reifier-original-contracts ()
63 (setf *occurrence-reifier-outputs* nil)
64 (let ((previous (copy-list *cases*)))
65 (dolist (name '("occurrence-reifier" "occurrence-duplicate-reifier"))
66 (let* ((id (format nil "xtm2/in/~A.xtm" name))
67 (*document* (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" id))
68 (raw (file-bytes (corpus-path id))) (copy (copy-seq raw))
69 (baseline (corpus-path (format nil "xtm2/baseline/~A.xtm.cxtm" name))) (expected (file-bytes baseline))
70 (case (topic-maps.test-foundation:make-test-case :id id :category :valid :source-pathname (corpus-path id)
71 :document-iri *document* :expected-outcome :cxtm-equal :expected-baseline baseline
72 :clauses '("XTM 4.3.2,4.3.4,4.5,4.15" "TMDM 5.1,5.3.4-5.3.5,5.6,6.2,6.5")))
73 (map nil) (held nil) (counts nil) (calls 0) (same nil) (actual nil) (c nil))
74 (check (format nil "occurrence-reifier-original:~A:unique-new-case" name)
75 (null (find id *cases* :key #'topic-maps.test-foundation:test-case-id :test #'equal)))
76 (setf *cases* (append *cases* (list case)))
77 (handler-case
78 (progn
79 (multiple-value-setq (map held counts calls same) (orr-observe raw id))
80 (let* ((o (first (all-occurrences map))) (r (by-id map "reifier")))
81 (check (format nil "occurrence-reifier-original:~A:exact-native-value-parent-type-scope-reifier-and-inverse" name)
82 (and (= 3 (length (topic-map-topics map))) (= 1 (length (all-occurrences map)))
83 (null (topic-map-associations map)) (null (name-reifier-names map))
84 (eq (by-id map "topic") (occurrence-parent o)) (eq (by-id map "occtype") (occurrence-type o))
85 (equal "Testing resource data." (occurrence-value o)) (equal (string-datatype) (occurrence-datatype o))
86 (null (occurrence-scope o)) (null (item-identifiers o)) (eq r (item-reifier o)) (eq o (topic-reified r))
87 (equal (list (concatenate 'string *document* "#reifier")) (item-identifiers r))
88 (every (lambda (topic) (and (= 1 (length (item-identifiers topic)))
89 (null (topic-subject-identifiers topic)) (null (topic-subject-locators topic)))) (topic-map-topics map))
90 (orr-current-p map) (orr-held-p map held))))
91 (check (format nil "occurrence-reifier-original:~A:original-octets-one-qualified-parser-and-actual-reads" name)
92 (and (= 1 calls) same (equalp raw copy) (equal counts (if (equal name "occurrence-reifier") '(1) '(1 1)))))
93 (when (equal name "occurrence-duplicate-reifier")
94 (check "occurrence-reifier-original:duplicate:old-Occurrence-handle-replaced-and-resolvable"
95 (some (lambda (i) (and (typep i 'occurrence) (not (eq i (canonical-occurrence i))))) held)))
96 (setf actual (orr-pure name map held))
97 (let ((other (deserialize-octets raw :document-iri *document* :source-key "different:Occurrence-Reifier-provenance")))
98 (check (format nil "occurrence-reifier-original:~A:source-key-independent" name)
99 (and (equalp (orr-model map) (orr-model other)) (equalp actual (mm-cxtm other))))))
100 (error (condition) (setf c condition)))
101 (record-original-result case actual expected c)
102 (push (mm-fields "id" id "documentIRI" *document* "sourceKey" id "sourceBytes" (length raw)
103 "sourceHex" (format nil "~{~2,'0X~}" (coerce raw 'list)) "sourceText" (babel:octets-to-string raw :encoding :utf-8)
104 "qualifiedParserCalls" calls "originalOctetsEQ" (if same :true :false) "model" (when map (orr-model map))
105 "occurrenceCountsAfterEachRead" (coerce counts 'vector) "observedNativeHandles" (length held)
106 "oldHandlesCanonicalAndLive" (if (and map (orr-held-p map held)) :true :false)
107 "actualBytes" (when actual (length actual)) "expectedBytes" (length expected)
108 "actualCXTM" (when actual (babel:octets-to-string actual :encoding :utf-8)) "expectedCXTM" (babel:octets-to-string expected :encoding :utf-8)
109 "firstDifferentByte" (when actual (mismatch actual expected)) "condition" (mm-condition c)
110 "status" (string-downcase (string (topic-maps.test-foundation:test-case-status case)))) *occurrence-reifier-outputs*)
111 (when c (error c))
112 (check (format nil "occurrence-reifier-original:~A:complete-original-CXTM-byte-exact" name) (equalp actual expected))))
113 (orr-negative-original)
114 (check "occurrence-reifier-original:three-requested-cases-once-all-prior-PASS-preserved"
115 (and (every (lambda (case) (and (member case *cases* :test #'eq) (eq :pass (topic-maps.test-foundation:test-case-status case)))) previous)
116 (same-identifiers-p (mapcar #'topic-maps.test-foundation:test-case-id (set-difference *cases* previous :test #'eq))
117 '("xtm2/in/occurrence-reifier.xtm" "xtm2/in/occurrence-duplicate-reifier.xtm" "xtm2/invalid/reifier-collision.xtm"))
118 (every (lambda (case) (= 1 (count (topic-maps.test-foundation:test-case-id case) *cases* :key #'topic-maps.test-foundation:test-case-id :test #'equal))) *cases*))))
119 (setf *occurrence-reifier-outputs* (nreverse *occurrence-reifier-outputs*)))
120 (defun orr-negative-original ()
121 (let* ((id "xtm2/invalid/reifier-collision.xtm")
122 (*document* (concatenate 'string "https://xtm-tests.example.invalid/cd165b150176c1d6842b37be9cc9051b40d4996b/" id))
123 (raw (file-bytes (corpus-path id))) (copy (copy-seq raw))
124 (spec '("reifier-collision" reification-error :reifier-conflict "Topic already reifies a different information item." nil nil "XTM 4.3.2,4.15; TMDM 5.3.4-5.3.5,6.2: Map and Occurrence are different items"))
125 (case (topic-maps.test-foundation:make-test-case :id id :category :invalid :source-pathname (corpus-path id)
126 :document-iri *document* :expected-outcome :ctm-rejection :clauses (list (seventh spec))))
127 (c nil) (frames nil))
128 (multiple-value-setq (c frames) (orr-condition-from raw id))
129 (record-negative-original-result case spec c *document* id)
130 (setf *cases* (append *cases* (list case)))
131 (push (mm-fields "id" id "documentIRI" *document* "sourceKey" id "sourceBytes" (length raw)
132 "sourceHex" (format nil "~{~2,'0X~}" (coerce raw 'list)) "sourceText" (babel:octets-to-string raw :encoding :utf-8)
133 "condition" (mm-condition c) "actualNativeAssignments" (coerce frames 'vector)
134 "intendedCauseReached" (if (intended-negative-p spec c *document* id) :true :false)
135 "status" (string-downcase (string (topic-maps.test-foundation:test-case-status case)))) *occurrence-reifier-outputs*)
136 (check "occurrence-reifier-negative-original:actual-Map-Occurrence-collision-and-exact-native-condition"
137 (and (intended-negative-p spec c *document* id) (equalp copy raw) (= 1 (length frames))
138 (let ((members (topic-maps.test-foundation::json-object-members (first frames))))
139 (and (equal "OCCURRENCE" (cdr (assoc "assignedItemKind" members :test #'equal)))
140 (equal "TOPIC-MAP" (cdr (assoc "priorReifiedItemKind" members :test #'equal)))
141 (eq :true (cdr (assoc "nativeAssignmentUnchanged" members :test #'equal)))))))
142 (check "occurrence-reifier-negative-original:no-preliminary-Unsupported-registered-PASS"
143 (and (not (typep c 'xtm-unsupported)) (eq :pass (topic-maps.test-foundation:test-case-status case))))))
144
145 (defun orr-xml (reifier &key (ids nil) (type "#t") scope (value "V") (datatype nil) resource)
146 (format nil "<occurrence~A>~A<type><topicRef href='~A'/></type>~A~A</occurrence>"
147 (if reifier (format nil " reifier='~A'" reifier) "") (ik-ids ids) type
148 (if scope (format nil "<scope>~{<topicRef href='~A'/>~}</scope>" scope) "")
149 (or resource (format nil "<resourceData~A>~A</resourceData>" (if datatype (format nil " datatype='~A'" datatype) "") value))))
150 (defun orr-probe (label body verify &optional replacement)
151 (let* ((raw (bytes (document body))) (copy (copy-seq raw)))
152 (multiple-value-bind (map held counts calls same) (orr-observe raw label)
153 (check (format nil "occurrence-reifier:~A:productive-reader-original-bytes-native-EQ-and-inverses" label)
154 (and (= 1 calls) same (equalp copy raw) (orr-current-p map) (orr-held-p map held)))
155 (funcall verify map)
156 (when replacement
157 (check (format nil "occurrence-reifier:~A:old-handles-resolve-after-normalization" label)
158 (some (lambda (i) (not (eq i (topic-maps.tmdm::canonical-item i)))) held)))
159 (let ((cx (orr-pure label map held)))
160 (push (mm-fields "label" label "documentIRI" *document* "sourceKey" label "sourceText" (document body)
161 "model" (orr-model map) "CXTM" (babel:octets-to-string cx :encoding :utf-8)
162 "readOccurrenceCounts" (coerce counts 'vector) "oldHandlesCanonicalAndLive" :true) *occurrence-reifier-controls*)) map)))
163 (defun orr-error (label body class code &key resolver map-reifier)
164 (multiple-value-bind (c frames) (orr-condition-from (bytes (if map-reifier (map-reifier-xml map-reifier body) (document body))) label resolver)
165 (let ((actual (cond ((typep c 'topic-maps.xtm:xtm-error) (error-code c))
166 ((typep c 'reification-error) (reification-error-code c))
167 ((typep c 'item-identifier-error) (item-identifier-error-code c)))))
168 (check (format nil "occurrence-reifier-error:~A:exact-class-code-intended-cause" label)
169 (and (eq (type-of c) class) (eq code actual)))
170 (when (typep c 'topic-maps.xtm:xtm-error)
171 (check (format nil "occurrence-reifier-error:~A:original-document-source-position-and-cause" label)
172 (and (equal *document* (error-document-iri c)) (equal label (error-source-key c))
173 (if (typep c 'xtm-xml-error) (topic-maps.xtm:error-cause c)
174 (and (integerp (error-line c)) (integerp (error-column c)))))))
175 (push (mm-fields "label" label "documentIRI" *document* "sourceKey" label "sourceText" (if map-reifier (map-reifier-xml map-reifier body) (document body))
176 "condition" (mm-condition c) "nativeConditionHasNoSourcePositionSlots" (if (typep c 'topic-maps.xtm:xtm-error) :false :true)
177 "actualNativeAssignments" (coerce frames 'vector)) *occurrence-reifier-controls*)) c))
178 (defun occurrence-reifier-tests ()
179 (setf *occurrence-reifier-controls* nil)
180 (dolist (position '("unknown" "before" "after"))
181 (let ((body (format nil "<topic id='p'>~A</topic>" (orr-xml "#r"))))
182 (orr-probe (concatenate 'string "definition-" position)
183 (concatenate 'string (if (equal position "before") "<topic id='r'/>" "") body
184 (if (equal position "after") "<topic id='r'/>" ""))
185 (lambda (map)
186 (check (format nil "occurrence-reifier:definition-~A:one-II-reifier-topic-no-SI-SL" position)
187 (let ((o (first (all-occurrences map))) (r (by-id map "r")))
188 (and (= 3 (length (topic-map-topics map))) (eq r (item-reifier o)) (eq o (topic-reified r))
189 (equal (list (concatenate 'string *document* "#r")) (item-identifiers r))
190 (null (topic-subject-identifiers r)) (null (topic-subject-locators r)) (null (item-identifiers o)))))))))
191 (dolist (category '("itemIdentity" "subjectIdentifier"))
192 (let ((iri "https://reifier.example.invalid/object#r"))
193 (orr-probe (concatenate 'string "lookup-" category)
194 (format nil "<topic id='known'><~A href='~A'/></topic><topic id='p'>~A</topic>" category iri (orr-xml iri))
195 (lambda (map)
196 (let ((r (by-id map "known")))
197 (check (format nil "occurrence-reifier:lookup-~A:II-only-lookup-TMDM-cross-merge-and-identifier-preservation" category)
198 (and (= 3 (length (topic-map-topics map))) (eq r (item-reifier (first (all-occurrences map))))
199 (same-identifiers-p (list (concatenate 'string *document* "#known") iri) (item-identifiers r))
200 (equal (when (equal category "subjectIdentifier") (list iri)) (topic-subject-identifiers r))
201 (null (topic-subject-locators r)))))))))
202 (dolist (ref '("urn:reifier" "../%E9%A6%AC#r"))
203 (orr-probe (concatenate 'string "resolved-IRI:" ref) (format nil "<topic id='p'>~A</topic>" (orr-xml ref :ids '("urn:occurrence-II")))
204 (lambda (map)
205 (let* ((o (first (all-occurrences map))) (r (item-reifier o)))
206 (check (format nil "occurrence-reifier:resolved-IRI:~A:separate-II-and-Reifier" ref)
207 (and (equal '("urn:occurrence-II") (item-identifiers o))
208 (equal (list (mm-child-iri ref)) (item-identifiers r))
209 (not (equal (item-identifiers o) (item-identifiers r))) (null (topic-subject-identifiers r)) (null (topic-subject-locators r))))))))
210 (orr-probe "same-Occurrence-two-Reifiers-and-item-identifiers"
211 (format nil "<topic id='p'>~A~A</topic>" (orr-xml "#r" :ids '("urn:o1")) (orr-xml "#u" :ids '("urn:o2")))
212 (lambda (map)
213 (let ((o (first (all-occurrences map))))
214 (check "occurrence-reifier:two-Reifiers:one-native-Occurrence-one-Reifier-Topic-all-identifiers"
215 (and (= 1 (length (all-occurrences map))) (= 3 (length (topic-map-topics map)))
216 (same-identifiers-p '("urn:o1" "urn:o2") (item-identifiers o))
217 (eq (by-id map "r") (by-id map "u")) (eq o (topic-reified (by-id map "u")))
218 (same-identifiers-p (list (concatenate 'string *document* "#r") (concatenate 'string *document* "#u")) (item-identifiers (item-reifier o))))))) t)
219 (dolist (order '("unreified-first" "reified-first"))
220 (orr-probe order
221 (format nil "<topic id='p'>~A~A</topic>" (orr-xml (when (equal order "reified-first") "#r")) (orr-xml (when (equal order "unreified-first") "#r")))
222 (lambda (map) (check (concatenate 'string "occurrence-reifier:" order ":normalization-retains-Reifier")
223 (and (= 1 (length (all-occurrences map))) (eq (by-id map "r") (item-reifier (first (all-occurrences map))))))) t))
224 (orr-probe "resourceRef-IRI-value-with-Reification"
225 (format nil "<topic id='p'>~A</topic>" (orr-xml "#r" :resource "<resourceRef href='../resource'/>"))
226 (lambda (map) (let ((o (first (all-occurrences map))))
227 (check "occurrence-reifier:resourceRef:resolved-value-datatype-and-reified-inverse"
228 (and (equal (mm-child-iri "../resource") (occurrence-value o)) (equal (iri-datatype) (occurrence-datatype o))
229 (eq o (topic-reified (by-id map "r"))))))))
230 (orr-late-merges)
231 (orr-negative-tests)
232 (orr-import-test)
233 (setf *occurrence-reifier-controls* (nreverse *occurrence-reifier-controls*)))
234 (defun orr-late-merges ()
235 (dolist (category '("subjectIdentifier" "subjectLocator" "itemIdentity"))
236 (let* ((label (concatenate 'string "late-" category))
237 (body (concatenate 'string
238 (format nil "<topic id='p'>~A</topic><topic id='q'>~A</topic>"
239 (orr-xml "#r" :ids '("urn:o1") :type "#t" :scope '("#s"))
240 (orr-xml "#u" :ids '("urn:o2") :type "#tt" :scope '("#ss")))
241 (format nil "<topic id='p2'><itemIdentity href='#p'/><~A href='urn:owner'/></topic><topic id='q2'><itemIdentity href='#q'/><~A href='urn:owner'/></topic><topic id='t'><~A href='urn:type'/></topic><topic id='tt'><~A href='urn:type'/></topic><topic id='s'><~A href='urn:scope'/></topic><topic id='ss'><~A href='urn:scope'/></topic><topic id='r'><~A href='urn:reifier'/></topic><topic id='u'><~A href='urn:reifier'/></topic>" category category category category category category category category))))
242 (orr-probe label body
243 (lambda (map) (let ((o (first (all-occurrences map))))
244 (check (format nil "occurrence-reifier:~A:late-owner-type-scope-Reifier-identity-merges" label)
245 (and (= 1 (length (all-occurrences map))) (eq (by-id map "p") (by-id map "q"))
246 (eq (by-id map "t") (by-id map "tt")) (eq (by-id map "s") (by-id map "ss"))
247 (eq (by-id map "r") (by-id map "u")) (eq o (topic-reified (by-id map "u")))
248 (same-identifiers-p '("urn:o1" "urn:o2") (item-identifiers o))
249 (eq (by-id map "p") (occurrence-parent o)) (eq (by-id map "t") (occurrence-type o))
250 (equal (list (by-id map "s")) (occurrence-scope o)))))) t))))
251 (defun orr-negative-tests ()
252 (dolist (row '(("bad-percent" "%ZZ" :invalid-percent-escape) ("bad-percent-UTF8" "%C3%28" :invalid-percent-utf8) ("bad-IRI" "x#y#z" :invalid-iri)))
253 (orr-error (first row) (format nil "<topic id='p'>~A</topic>" (orr-xml (second row))) 'xtm-rejection (third row)))
254 (dolist (row '(("extra-attribute" "<topic id='p'><occurrence reifier='#r' bogus='1'><type><topicRef href='#t'/></type><resourceData>V</resourceData></occurrence></topic>" xtm-rejection :unexpected-attribute)
255 ("reifier-on-type" "<topic id='p'><occurrence><type reifier='#r'><topicRef href='#t'/></type><resourceData>V</resourceData></occurrence></topic>" xtm-rejection :unexpected-attribute)
256 ("reifier-on-Topic" "<topic id='p' reifier='#r'/>" xtm-rejection :unexpected-attribute)
257 ("reifier-on-scope" "<topic id='p'><occurrence><type><topicRef href='#t'/></type><scope reifier='#r'><topicRef href='#s'/></scope><resourceData>V</resourceData></occurrence></topic>" xtm-rejection :unexpected-attribute)
258 ("malformed-XML" "<topic id='p'><occurrence reifier='#r'></topic>" xtm-xml-error :xml-not-well-formed)))
259 (apply #'orr-error row))
260 (orr-error "two-different-Occurrences-same-Reifier"
261 (format nil "<topic id='p'>~A~A</topic>" (orr-xml "#r" :value "A") (orr-xml "#r" :value "B")) 'reification-error :reifier-conflict)
262 (orr-error "Name-and-Occurrence-same-Reifier"
263 (format nil "<topic id='p'><name reifier='#r'><value>N</value></name>~A</topic>" (orr-xml "#r")) 'reification-error :reifier-conflict)
264 (orr-error "Map-and-Occurrence-same-Reifier"
265 (concatenate 'string "<topic id='p'>" (orr-xml "#r") "</topic><topic id='r'/>")
266 'reification-error :reifier-conflict
267 :map-reifier "#r")
268 (dolist (category '("subjectIdentifier" "subjectLocator" "itemIdentity"))
269 (orr-error (concatenate 'string "late-conflicting-Reifier-merge-" category)
270 (format nil "<topic id='p'>~A~A</topic><topic id='r'><~A href='urn:shared'/></topic><topic id='u'><~A href='urn:shared'/></topic>"
271 (orr-xml "#r" :value "A") (orr-xml "#u" :value "B") category category) 'reification-error :reifier-conflict))
272 (orr-error "Occurrence-own-II-cannot-be-Reifier-Topic-II"
273 (format nil "<topic id='p'>~A</topic>" (orr-xml "urn:same" :ids '("urn:same"))) 'topic-maps.tmdm::occurrence-identifier-error :duplicate-item-identifier)
274 (orr-error "anyType-remains-Unsupported" (format nil "<topic id='p'>~A</topic>" (orr-xml "#r" :datatype "http://www.w3.org/2001/XMLSchema#anyType")) 'xtm-unsupported :resource-data-datatype)
275 (orr-error "Association-Reification-remains-Unsupported" "<association reifier='#r'><type><topicRef href='#t'/></type><role reifier='#excluded-role%GG'><type><topicRef href='#rt'/></type><topicRef href='#p'/></role></association>" 'xtm-rejection :invalid-percent-escape)
276 (orr-error "Role-Reification-remains-Unsupported" "<association><type><topicRef href='#t'/></type><role reifier='#r%GG'><type><topicRef href='#rt'/></type><topicRef href='#p'/></role></association>" 'xtm-rejection :invalid-percent-escape))
277 (defun orr-import-test ()
278 (let* ((child (mm-child-iri "child.xtm"))
279 (raw (bytes (document (format nil "<topic id='p'><subjectIdentifier href='urn:owner'/>~A</topic>" (orr-xml "#r" :ids '("urn:imported-Occurrence") :scope '("#s")))))))
280 (mm-call "Occurrence-Reification-import" (document (concatenate 'string (mm-directive "child.xtm") "<topic id='local'><subjectIdentifier href='urn:owner'/></topic>"))
281 (list (list child raw "child:Reification"))
282 (lambda (map imports calls) (declare (ignore calls))
283 (let ((o (first (all-occurrences map))) (r (mm-local map child "r")))
284 (check "occurrence-reifier:import:native-parent-II-Reifier-inverse-source-preservation"
285 (and (orr-current-p map) (eq (by-id map "local") (occurrence-parent o)) (eq r (item-reifier o)) (eq o (topic-reified r))
286 (equal '("urn:imported-Occurrence") (item-identifiers o)) (null (item-identifiers map))
287 (every (lambda (record) (let ((source (first record)) (resolve (second record)))
288 (and (orr-current-p source) (eq o (funcall resolve (first (all-occurrences source))))
289 (eq r (funcall resolve (item-reifier (first (all-occurrences source)))))))) imports))))
290 (push (mm-fields "label" "native-Reification-import" "sourceText" (babel:octets-to-string raw :encoding :utf-8)
291 "model" (orr-model map) "sourceMapPreserved" :true) *occurrence-reifier-controls*)))))