Subject: Re: [cxml-devel] Parsing from a stream
From: Chaitanya Gupta <[email-masked]>
To: David Lichteblau <[email-masked]>
Date: Wed, 20 Feb 2008 00:16:36 +0530

David Lichteblau wrote:
> parsing from character streams is a reasonable feature suggestion, but
> currently not implemented.  When parsing from streams, the stream must
> have element-type (unsigned-byte 8).
>
>   
I tried the following with flexi-streams:

CL-USER> (setf *x (coerce "<foo>bar</foo>" '(array (unsigned-byte 8))))
#(121 205 223 223 125 197 195 229 121 95 205 223 223 125)

CL-USER> (flexi-streams:with-input-from-sequence (s *x)
           (cxml:parse s (cxml-dom:make-dom-builder)))

This is the error/backtrace I get:

---

There is no filename associated with stream
#<FLEXI-STREAMS::VECTOR-INPUT-STREAM @ #x12cc7212>
   [Condition of type TYPE-ERROR]

Backtrace:
  0: (SWANK::DEBUG-IN-EMACS #<TYPE-ERROR @ #x12cd29c2>)
  1: (SWANK:SWANK-DEBUGGER-HOOK #<TYPE-ERROR @ #x12cd29c2> #<Function 
SWANK-DEBUGGER-HOOK>)
  2: (ERROR TYPE-ERROR :DATUM #1=#<FLEXI-STREAMS::VECTOR-INPUT-STREAM @ 
#x12cc7212> :EXPECTED-TYPE FILE-STREAM :FORMAT-CONTROL "There is no 
filename associated with stream ~s" :FORMAT-ARGUMENTS (#1#))
  3: (PATHNAME #<FLEXI-STREAMS::VECTOR-INPUT-STREAM @ #x12cc7212>)
  4: (CXML:PARSE #<FLEXI-STREAMS::VECTOR-INPUT-STREAM @ #x12cc7212> 
#<RUNE-DOM::DOM-BUILDER @ #x12ccc12a>)

---

Only file streams are supported?

> However, you can parse from a string directly.  Is that good enough for
> now?
>
>   
No. The reason I am asking is because I get a (huge) XML over a socket; 
I think parsing directly from the socket stream should be much more 
efficient than first reading the XML into a string, and then parsing the 
string (is this assumption correct?).

Chaitanya