sxml->xml(改行を上手く入れられない)
いまごろなんだけど
http://www.thinkit.co.jp/article/74/2/2.html
最近頭が上手く働かない。
(use util.match) (use text.tree) (define *url* '(html (head (title "Gauche Web")) (body (h1 "Gauche Web Page") (a (@ (url "foo.ne.jp")) "link") (table (tr (td "1") (td "lisp")) (tr (td "2") (td "scheme")))))) (define (tag-transform seq) (match seq [(tag ('@ . attributes) . args) (let ((s (symbol->string tag)) (attributes* (map (lambda (attrs) (apply format #f "~a=\"~a\"" attrs)) attributes))) `("<" ,s " " ,(string-join attributes* " ") ">" ,(map tag-transform args) "</" ,s ">"))] [(tag . args) (let1 s (symbol->string tag) `("<" ,s ">" ,(map tag-transform args) "</" ,s ">"))] [ _ seq])) (write-tree (tag-transform *url*))