[cxml-devel] flush-ystream on character-stream-yestream

Nathan Bird nathan at acceleration.net
Wed Jan 18 00:31:13 UTC 2006


I was having a problem with serializing to a character stream (rather than
string or octets) on SBCL 0.9.7.


CL-USER> (let* ((dom (cxml-dom:create-document))
		    (string (with-output-to-string (stream)
				 (dom:map-document
(cxml:make-character-stream-sink
stream :indentation 4 :canonical nil) dom ))))
		  (values string (length string)))

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
^@^@^@^@ .... (I've actually typed these in since I can't paste them) .....
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
^@^@^@^@^@^@^@^@^@^@............."
1024

It was looking an awfully lot like it was trying to write out buffer that
wasn't filled.


Tracked it down to

(defmethod flush-ystream ((ystream character-stream-ystream))
  (write-string (ystream-in-buffer ystream)
                (ystream-target-stream ystream)
                ;;this end argument had been missing.
                :end (ystream-in-ptr ystream)) 
  (setf (ystream-in-ptr ystream) 0))


Patch attached.


Nathan Bird

BTW, I've been playing around with using CXML to generate XUL, since it
mixes with HTML and namespaces matter and all that jazz. As an interesting
comparison I tried generating and serializing out through UnCommon Web a big
html table with a lot of dynamic generated strings in it.  It looks like
doing it with CXML is about 2.5 times faster than doing the equivalent with
UCW's own tool-- yaclml. Sweet!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flush-character-stream-ystream.diff
Type: application/octet-stream
Size: 713 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cxml-devel/attachments/20060117/bc9b271c/attachment.obj>


More information about the cxml-devel mailing list