chickadee » sxml-modifications » sxml-delete-undeep

sxml-insert-following node-specifierprocedure
sxml-insert-preceding node-specifierprocedure
sxml-insert-into node-specifierprocedure
sxml-rename new-nameprocedure
sxml-deleteprocedure
sxml-delete-undeepprocedure

These procedures all correspond to the action symbols accepted by sxml-modify. There are no procedures corresponding to move-into, move-preceding, move-following or replace.

The sxml-delete and sxml-delete-undeep procedures can only be put directly into the action-parameters list as-is, which means this adds zero expressiveness over the corresponding symbols.

The insert-following, insert-preceding and insert-into procedures all accept a node-specifier procedure of two arguments which must return a node or node-set which shall be inserted. The first argument of the procedure is the context, the second is the base node.

The sxml-rename procedure accepts a symbol which indicates the new element name to use for the matched nodes.

Here's the example from sxml-modify using these procedures instead of action symbols:

(define doc
  '(*TOP*
    (*PI* xml "version='1.0'")
    (purchaseOrder (@ (orderDate "07.23.2001"))
      (recipient
        (name "Dennis Scannell")
        (street "175 Perry Lea Side Road"))
      (order
        (cd (@ (title "Little Lion") (artist "Brooks Williams")))))))

(define delete-recipient (sxml-modify `("purchaseOrder/recipient" ,sxml-delete)))
(delete-recipient doc)
=>
(*TOP*
 (*PI* xml "version='1.0'")
 (purchaseOrder (@ (orderDate "07.23.2001"))
   ;; (recipient ...) is gone
   (order
     (cd (@ (title "Little Lion") (artist "Brooks Williams"))))))

;; insert-into accepts any number of action-parameters, being the node(s) to insert at the end
((sxml-modify `("purchaseOrder/recipient"
                ,(sxml-insert-into
                  (lambda (context base-node)
                    (list '(postalCode "05676") '(city "Footown"))))))
 doc)
=>
(*TOP*
 (*PI* xml "version='1.0'")
 (purchaseOrder (@ (orderDate "07.23.2001"))
   (recipient
     (name "Dennis Scannell")
     (street "175 Perry Lea Side Road")
     (postalCode "05676") ; New
     (city "Footown"))    ; New
   (order
     (cd (@ (title "Little Lion") (artist "Brooks Williams"))))))