diff --git a/cxml.asd b/cxml.asd index bfcd2b8..64746e2 100644 --- a/cxml.asd +++ b/cxml.asd @@ -127,7 +127,7 @@ "test/" (make-pathname :name nil :type nil :defaults *load-truename*)) :components ((:file "domtest") (:file "xmlconf")) - :depends-on (:cxml-xml :cxml-dom)) + :depends-on (:cxml-xml :cxml-klacks :cxml-dom)) (asdf:defsystem :cxml :components () diff --git a/doc/klacks.xml b/doc/klacks.xml index 0cab5d8..93b8de6 100644 --- a/doc/klacks.xml +++ b/doc/klacks.xml @@ -215,4 +215,11 @@ NIL Call klacks:close-source to close the source after exiting body, whether normally or abnormally.

+ +

Bridging Klacks and SAX

+

+

Function KLACKS:SERIALIZE-SOURCE (source handler)
+ Read all klacks events from source and send them as SAX + events to the SAX handler. +

diff --git a/dom/dom-builder.lisp b/dom/dom-builder.lisp index eed2048..ab3e9e3 100644 --- a/dom/dom-builder.lisp +++ b/dom/dom-builder.lisp @@ -37,10 +37,11 @@ (setf (document handler) document) (push document (element-stack handler)))) +;; fixme +(defmethod sax::dtd ((handler dom-builder) dtd) + (setf (slot-value (document handler) 'dtd) dtd)) + (defmethod sax:end-document ((handler dom-builder)) - (setf (slot-value (document handler) 'dtd) - ;; FIXME! - (and cxml::*ctx* (cxml::dtd cxml::*ctx*))) (let ((doctype (dom:doctype (document handler)))) (when doctype (setf (slot-value (dom:entities doctype) 'read-only-p) t) diff --git a/klacks/klacks-impl.lisp b/klacks/klacks-impl.lisp index 960bda4..b551acf 100644 --- a/klacks/klacks-impl.lisp +++ b/klacks/klacks-impl.lisp @@ -31,7 +31,7 @@ (current-values) (current-attributes) (cdata-section-p :reader klacks:current-cdata-section-p) - ;; extra with-source magic + ;; extra WITH-SOURCE magic (data-behaviour :initform :DTD) (namespace-stack :initform (list *initial-namespace-bindings*)) (temporary-streams :initform nil) @@ -126,13 +126,18 @@ (apply #'make-source xstream args))) (pathname (let* ((xstream - (make-xstream (open input :element-type '(unsigned-byte 8)))) - (source (apply #'make-source - xstream - :pathname input - args))) - (push xstream (slot-value source 'temporary-streams)) - source)) + (make-xstream (open input :element-type '(unsigned-byte 8))))) + (setf (xstream-name xstream) + (make-stream-name + :entity-name "main document" + :entity-kind :main + :uri (pathname-to-uri (merge-pathnames input)))) + (let ((source (apply #'make-source + xstream + :pathname input + args))) + (push xstream (slot-value source 'temporary-streams)) + source))) (rod (let ((xstream (string->xstream input))) (setf (xstream-name xstream) @@ -152,8 +157,7 @@ (check-type entity-resolver (or null function symbol)) (check-type disallow-internal-subset boolean) (let* ((context - (make-context :handler nil - :main-zstream input + (make-context :main-zstream input :entity-resolver entity-resolver :disallow-internal-subset disallow-internal-subset)) (source @@ -167,6 +171,7 @@ :scratch-pad-2 *scratch-pad-2* :scratch-pad-3 *scratch-pad-3* :scratch-pad-4 *scratch-pad-4*))) + (setf (handler context) (make-instance 'klacks-dtd-handler :source source)) (setf (slot-value source 'continuation) (lambda () (klacks/xmldecl source input))) source)) @@ -208,25 +213,26 @@ (defun klacks/doctype (source input) (with-source (source current-key current-values validate dtd) (let ((cont (lambda () (klacks/finish-doctype source input))) - ignoreme name extid) + l) (prog1 (cond ((eq (peek-token input) :