Given a node-list, expand-children replaces all of the members of the node-list whose GIs are members of gilist with (children).
This function can be used to selectively flatten the hierarchy of a document.
Suppose that the node list is (BOOKINFO PREFACE PART APPENDIX). (expand-children nl ("PART")) might return (BOOKINFO PREFACE CHAPTER CHAPTER APPENDIX).
(define (expand-children nodelist gilist) ;; Expand selected nodes in a node list (let loop ((nl nodelist) (result (empty-node-list))) (if (node-list-empty? nl) result (if (member (gi (node-list-first nl)) gilist) (loop (node-list-rest nl) (node-list result (children (node-list-first nl)))) (loop (node-list-rest nl) (node-list result (node-list-first nl)))))))