2 (asdf:initialize-source-registry '(:source-registry :ignore-inherited-configuration))
3 (asdf:load-asd #p"/Users/rgb/workspace/topic-maps/topic-maps.asd")
4 (asdf:load-system "topic-maps/project-work-example")
5 (use-package '(:topic-maps.tmdm :topic-maps.project-work.example))
7 (defparameter *example-source* #p"/Users/rgb/workspace/topic-maps/examples/project-work.ctm")
8 (defparameter *example-map* (load-map *example-source*))
9 (defparameter *held-question*
10 (find-topic *example-map* "urn:topic-maps:question:Q-XTM-LOOP"))
11 (describe *held-question*)
12 (show-topic *held-question*)
13 ;; Native Associations and their actual Role Items are navigable:
14 (dolist (association (relations *held-question*))
15 (describe association)
16 (dolist (role (association-roles association)) (describe role)))
18 (defparameter *before-edit*
19 (topic-maps.cxtm:canonicalize-octets *example-map* :base-locator *document-iri*))
20 (defparameter *exercise-occurrence* (add-exercise-note *example-map*))
21 (assert (eq *held-question*
22 (find-topic *example-map* "urn:topic-maps:question:Q-XTM-LOOP")))
23 (show-topic *held-question*)
24 (defparameter *after-edit*
25 (topic-maps.cxtm:canonicalize-octets *example-map* :base-locator *document-iri*))
26 (list (length *before-edit*) (length *after-edit*) (mismatch *before-edit* *after-edit*))
27 ;; => (7914 8191 5141); mismatch uses a zero-based byte position.
29 (defparameter *same-note-again* (add-exercise-note *example-map*))
30 (assert (eq (canonical-occurrence *exercise-occurrence*) *same-note-again*))
31 (assert (equalp *after-edit*
32 (topic-maps.cxtm:canonicalize-octets *example-map* :base-locator *document-iri*)))
33 ;; The original CTM is untouched; a fresh read contains no exercise annotation:
34 (defparameter *fresh-original* (load-map *example-source* :source-key "re-read original"))
35 (assert (equalp *before-edit*
36 (topic-maps.cxtm:canonicalize-octets *fresh-original* :base-locator *document-iri*)))