[cxml-cvs] CVS cxml/xml
dlichteblau
dlichteblau at common-lisp.net
Sun Apr 22 13:24:03 UTC 2007
Update of /project/cxml/cvsroot/cxml/xml
In directory clnet:/tmp/cvs-serv17056/xml
Modified Files:
package.lisp sax-proxy.lisp
Log Message:
+ <li>New class <tt>broadcast-handler</tt> as a generalization
+ of the older <tt>sax-proxy</tt>.</li>
+ <li>New class <tt>tapping-source</tt>, a klacks source that
+ relays events from an upstream klacks source unchanged, while also
+ emitting them as SAX events to a user-specified handler at the
+ same time.</li>
+ Fixed serialize-event to generate
+ start-prefix-mapping and end-prefix-mapping events. New function
+ map-current-namespace-declarations.</li>
--- /project/cxml/cvsroot/cxml/xml/package.lisp 2007/02/11 18:21:21 1.14
+++ /project/cxml/cvsroot/cxml/xml/package.lisp 2007/04/22 13:23:55 1.15
@@ -78,11 +78,15 @@
#:resolve-extid
#:make-recoder
- #:sax-proxy
- #:proxy-chained-handler
#:make-namespace-normalizer
#:make-whitespace-normalizer
#:rod-to-utf8-string
#:utf8-string-to-rod
+ #:broadcast-handler
+ #:broadcast-handler-handlers
+ #:make-broadcast-handler
+ #:sax-proxy
+ #:proxy-chained-handler
+
#:make-source))
--- /project/cxml/cvsroot/cxml/xml/sax-proxy.lisp 2005/12/29 00:31:36 1.4
+++ /project/cxml/cvsroot/cxml/xml/sax-proxy.lisp 2007/04/22 13:23:55 1.5
@@ -8,14 +8,33 @@
(in-package :cxml)
-(defclass sax-proxy ()
- ((chained-handler :initform nil
- :initarg :chained-handler
- :accessor proxy-chained-handler)))
+(defclass broadcast-handler ()
+ ((handlers :initform nil
+ :initarg :handlers
+ :accessor broadcast-handler-handlers)))
+
+(defun make-broadcast-handler (&rest handlers)
+ (make-instance 'broadcast-handler :handlers handlers))
+
+(defclass sax-proxy (broadcast-handler)
+ ())
+
+(defmethod initialize-instance
+ :after ((instance sax-proxy) &key chained-handler)
+ (setf (proxy-chained-handler instance) chained-handler))
+
+(defmethod proxy-chained-handler ((instance sax-proxy))
+ (car (broadcast-handler-handlers instance)))
+
+(defmethod (setf proxy-chained-handler) (newval (instance sax-proxy))
+ (setf (broadcast-handler-handlers instance) (list newval)))
(macrolet ((define-proxy-method (name (&rest args))
- `(defmethod ,name ((handler sax-proxy) , at args)
- (,name (proxy-chained-handler handler) , at args))))
+ `(defmethod ,name ((handler broadcast-handler) , at args)
+ (let (result)
+ (dolist (next (broadcast-handler-handlers handler))
+ (setf result (,name next , at args)))
+ result))))
(define-proxy-method sax:start-document ())
(define-proxy-method sax:start-element (uri lname qname attributes))
(define-proxy-method sax:start-prefix-mapping (prefix uri))
@@ -39,3 +58,7 @@
(define-proxy-method sax:attribute-declaration (elt attr type default))
(define-proxy-method sax:entity-resolver (resolver))
(define-proxy-method sax::dtd (dtd)))
+
+(defmethod sax:register-sax-parser :after ((handler sax-proxy) parser)
+ (dolist (next (broadcast-handler-handlers handler))
+ (sax:register-sax-parser next parser)))
More information about the Cxml-cvs
mailing list