Re: accessing SXML->HTML in the latest version of sxml-tools for plt-scheme
David Van Horn <[email protected]> Sun, 23 May 2004 11:45:12 -0400
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <[email protected]> |
Terrence Brannon wrote:
> Kirill Lisovsky wrote:
>> I recommend to use
>> http://pair.com/lisovsky/download/sxml/plt/preview/ssax20040221.plt
>> it looks like it's stable enough.
> I cannot figure out how to access the SXML->HTML function:
The PLT collection you cite above is the SSAX collection, not the SXML
collection. I believe you want the following .plt file:
http://www196.pair.com/lisovsky/download/sxml/plt/preview/sxml20040221.plt
Once installed, the following should work.
(require (lib "sxml-tools.ss" "sxml"))
(define simple
'(a (@ (href http://www.aaa.com))
"The AAA Site"))
(sxml:sxml->html simple)
> ;;; This function returns something that is not quite HTML.
> ;;; I want to generate HTML that can be viewed by a browser.
sxml->html will return a tree of html fragments. You need to do an in order
traversal displaying the fragments to emit HTML.
The function srv:send-reply does exactly this, however I wasn't able to find
it in the SXML distribution. Here is a possible definition of it:
(define (SRV:send-reply . fragments)
(let loop ((fragments fragments) (result #f))
(cond
((null? fragments) result)
((not (car fragments)) (loop (cdr fragments) result))
((null? (car fragments)) (loop (cdr fragments) result))
((pair? (car fragments))
(loop (cdr fragments) (loop (car fragments) result)))
((procedure? (car fragments))
((car fragments))
(loop (cdr fragments) #t))
(else
(display (car fragments))
(loop (cdr fragments) #t)))))
hth,
David
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click