[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED] Re: sxml: avoiding intermixed text?

From: Aleix Conchillo Flaqué
Subject: [SOLVED] Re: sxml: avoiding intermixed text?
Date: Thu, 13 Jan 2011 11:47:26 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20101227 Iceowl/1.0b1 Icedove/3.0.11

When I asked the question I thought I could use some sxml function to do this job. Particularly, I found out a way to do it with the SXML modifications explained here:

Unfortunately this is not available in Guile. So, This function removes whitespace text nodes from an sxml.

(define (remove-whitespace-nodes sxml)
  (define (node-fix node)
    (cond ((symbol? node) (list node))
          ((string? node) (if (string-null? (string-trim node))
                              (list node)))
          (else (list (remove-whitespace-nodes node)))))
  (let loop ((node sxml) (result '()))
    (cond ((null? node) result)
          (else (loop (cdr node)
                      (append result (node-fix (car node))))))))

I'm new to scheme, so a code review is really welcome!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]