Arc Forumnew | comments | leaders | submitlogin
1 point by Jesin 5951 days ago | link | parent

Messing with XML in general should be pretty easy in Lisp.

1 point by drcode 5951 days ago | link

FYI- In case anyone is doing this, here is my version of the canonical sexp->xml function:

  (def xexp (x (o indent 0))
    (if acons.x
        (withs ((tg . lst) x
	        atts nil
	        pad (apply string (n-of indent " "))
  	      pretty (all acons lst))
  	(and lst (acons caar.lst) (= atts pop.lst))
  	(string pad 
  		(tostring:map [pr " " car._ "=\"" cdr._ "\""] atts) 
  		(when pretty
  		(apply string (map [xexp _ (+ indent 3)] lst)) 
  		(when pretty
It assumes the standard PLT-scheme "xexpr" is naive about character encoding right now BTW.


  (xexp '(ying (foo ((bar . baz)) "zing") (yang)))

     <foo bar="baz">zing</foo>
(fyi, 'tag makes html assumptions and breaks on most xml, nor is it really appropriate in style for building xml)