SAX overhaul for HAX integration.
* dom/dom-builder.lisp (DOM-BUILDER): Inherit from sax:content-handler. * klacks/klacks-impl.lisp (KLACKS-DTD-HANDLER): Inherit from sax:default-handler. * klacks/klacks.lisp (KLACKS:SERIALIZE-EVENT): Bugfix -- call start-cdata and end-cdata on the handler, not the source. * xml/package.lisp: New export WITH-OUTPUT-SINK. * xml/sax-handler.lisp (SAX): New exports abstract-handler, content-handler, default-handler. (STANDARD-ATTRIBUTE): Renamed from attribute. (ATTRIBUTE-NAMESPACE-URI, ATTRIBUTE-LOCAL-NAME, ATTRIBUTE-QNAME, ATTRIBUTE-VALUE, ATTRIBUTE-SPECIFIED-P): Wrapper methods for standard-attribute. Wrapper methods for hax:standard-attribute. (all events): pulled into a common define-event form. New dummy method on null. Added a warning to the default method. New error method on abstract-handler. New dummy method on the respective default handler classes. * xml/sax-proxy.lisp (BROADCAST-HANDLER): Inherit from abstract-handler, not sax-parser-mixin. * xml/unparse.lisp (sink): Inherit from sax:content-handler. (WITH-OUTPUT-SINK): New macro. (INVOKE-WITH-OUTPUT-SINK): New function.
This commit is contained in:
@ -69,7 +69,7 @@
|
||||
|
||||
;;;; SINK: an xml output sink
|
||||
|
||||
(defclass sink ()
|
||||
(defclass sink (sax:content-handler)
|
||||
((ystream :initarg :ystream :accessor sink-ystream)
|
||||
(width :initform 79 :initarg :width :accessor width)
|
||||
(canonical :initform nil :initarg :canonical :accessor canonical)
|
||||
@ -561,6 +561,9 @@
|
||||
(defmacro with-xml-output (sink &body body)
|
||||
`(invoke-with-xml-output (lambda () ,@body) ,sink))
|
||||
|
||||
(defmacro with-output-sink ((var) &body body)
|
||||
`(invoke-with-output-sink (lambda (,var) ,@body)))
|
||||
|
||||
(defun invoke-with-xml-output (fn sink)
|
||||
(let ((*sink* sink)
|
||||
(*current-element* nil)
|
||||
@ -570,6 +573,10 @@
|
||||
(funcall fn)
|
||||
(sax:end-document *sink*)))
|
||||
|
||||
(defun invoke-with-output-sink (fn)
|
||||
(maybe-emit-start-tag)
|
||||
(funcall fn *sink*))
|
||||
|
||||
(defmacro with-element (qname &body body)
|
||||
`(invoke-with-element (lambda () ,@body) ,qname))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user