]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - src/ctm/xtm.lisp
Qualify closed XML/C14N 1.0 infrastructure for XTM resourceData
[topic-maps.git] / src / ctm / xtm.lisp
1 (in-package #:topic-maps.ctm)
2
3 ;; Optional ASDF adapter: neither the standalone XTM model reader nor plain CTM
4 ;; silently loads dependencies or retrieves resources. This method is installed
5 ;; only by explicitly loading topic-maps/ctm/xtm in a qualified XML environment.
6 (define-condition mergemap-source-error (ctm-resource-error) ())
7 (define-condition mergemap-source-unsupported (ctm-unsupported) ())
8
9 (defmethod mergemap-reader ((notation (eql :xtm)))
10 (lambda (bytes resource source-key parser)
11 (declare (ignore parser))
12 (let ((position (getf (first *resource-context*) :position)))
13 (handler-case
14 (topic-maps.xtm:deserialize-octets
15 ;; Preserve the very same specialized vector. The established
16 ;; resolver also accepts generic vectors of byte values; specialize
17 ;; only their storage representation, never decode/re-encode XML.
18 (if (typep bytes '(vector (unsigned-byte 8))) bytes
19 (map '(vector (unsigned-byte 8)) #'identity bytes))
20 :document-iri resource :source-key source-key)
21 (topic-maps.xtm:xtm-unsupported (c)
22 (problem 'mergemap-source-unsupported (topic-maps.xtm:error-code c)
23 position (princ-to-string c) :character c))
24 (topic-maps.xtm:xtm-error (c)
25 (problem 'mergemap-source-error (topic-maps.xtm:error-code c)
26 position (princ-to-string c) :character c))
27 (topic-maps.tmdm:item-identifier-error (c)
28 (problem 'mergemap-source-error (topic-maps.tmdm:item-identifier-error-code c)
29 position (princ-to-string c) :character c))
30 (topic-maps.tmdm:core-subject-error (c)
31 (problem 'mergemap-source-error (topic-maps.tmdm:core-subject-error-code c)
32 position (princ-to-string c) :character c))))))