htmlgen - odd html-print behavior

"Dmitri Ivanov" <[email protected]> Mon, 12 Aug 2002 15:02:14 +0400
Newsgroups gmane.lisp.open-source.franz
Organization YStock Soft
Message-ID <003901c241ef$f28225c0$0c1fa8c0@div>
Hello,

I actually use PortableAserve based on Aserve 1.2.23, but the point
should stay the same.

(defun gen-country-select (selected-code &rest attr-plist)
 ;; For coutries, generate lhtml analog of <SELECT> element (drop-down
list box)
 (let ((*countries* '(("AL" "Albania")
                      ("DZ" "Algeria")
                      ("AS" "American Samoa")
                      ("AD" "Andorra"))))
  `((:select :size 1 ,@attr-plist)
    ,.(loop for (code name) in *countries*
            collect `((:option :value ,code
                               ,@(when (equal selected-code code)
'(:selected "selected")))
                      ,name)
            collect :newline))))    ; :newline for readability

When I try to evaluate the following

(html-stream *standard-output*
  (:html
   "Country: "
   (html-print (gen-country-select "AU" :name "CountryCode" :accesskey
"C")
               *html-stream*)
   :br
   "Address: "))

everything is Ok and the output is like this:

<html>Country: <SELECT SIZE="1" NAME="CountryCode" ACCESSKEY="C"><OPTION
VALUE="AL">Albania</OPTION>
<OPTION VALUE="DZ">Algeria</OPTION>
<OPTION VALUE="AS">American Samoa</OPTION>
<OPTION VALUE="AD">Andorra</OPTION>
</SELECT><br>Address: </html>
"</html>"

Then, I try to generate a response by this

(publish :path "/select-test" :content-type "text/html"
         :function
  (lambda (req ent)
    (with-http-response (req ent)
      (with-http-body (req ent)
        (html
         (:html
          "Country: "
          (html-print (gen-country-select "AU" :name "CountryCode"
:accesskey "C")
                      *html-stream*)
          :br
          "Address: "))))))

However, the result looks odd in the browser and opening the underlying
source shows the following:

<html>Country: <SELECT SIZE="1" NAME="CountryCode" ACCESSKEY="C"><OPTION
VALUE="AL">Albania
<OPTION VALUE="DZ">Algeria
<OPTION VALUE="AS">American Samoa
<OPTION VALUE="AD">Andorra
<br>Address: </html>

Neither </OPTION> nor </SELECT> closing tags are generated. What could
be the matter?
---
Sincerely,
Dmitri Ivanov
www.aha.ru/~divanov