[cl-soap-devel] Manipulating CL-SOAP sexpr

Sven Van Caekenberghe scaekenberghe at common-lisp.net
Mon Oct 3 12:35:54 UTC 2005


CL-SOAP uses what I call 'sexpr' in input/output binding.
Basically these are nested plists with string keys.

I added some example functions to lxml.lisp to manipulate sexpr:

sexpr-get, (setf sexpr-getf), sexpr-select and sexpr-remove

This is a short listener interaction that shows their use:

;; sexpr-getf is much like CL's getf

CL-SOAP > (sexpr-getf '("x" 100 "y" 200) "x")
100

CL-SOAP > (sexpr-getf '("x" 100 "y" 200) "z")
NIL

CL-SOAP > (sexpr-getf '("x" 100 "y" 200) "y")
200

CL-SOAP > (setf foo '("x" 100 "y" 200))
("x" 100 "y" 200)

;; (setf sexpr-getf) is destructive, like (setf gethash) and friends

CL-SOAP > (setf (sexpr-getf foo "x") 1)
("x" 1 "y" 200)

CL-SOAP > (incf (sexpr-getf foo "x") 2)
("x" 3 "y" 200)

CL-SOAP > (decf (sexpr-getf foo "y") 2)
("x" 3 "y" 198)

;; (setf sexpr-getf) can be used to add elements (to the tail)

CL-SOAP > (setf (sexpr-getf foo "z") -1)
("x" 3 "y" 198 "z" -1)

;; sexpr-select is not destructive (much like SQL's select)

CL-SOAP > (sexpr-select foo '("x" "y"))
("x" 3 "y" 198)

CL-SOAP > (sexpr-select foo '("x" "z"))
("x" 3 "z" -1)

;; sexpr-remove is the inverse of select

CL-SOAP > (sexpr-remove foo '("x" "z"))
("y" 198)

HTH,

Sven




More information about the cl-soap-devel mailing list