From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?QWxlaXggQ29uY2hpbGxvIEZsYXF1w6k=?= Newsgroups: gmane.lisp.guile.user Subject: [SOLVED] Re: sxml: avoiding intermixed text? Date: Thu, 13 Jan 2011 11:47:26 +0100 Message-ID: <4D2ED83E.4000008@gmail.com> References: <4D2AEBCA.8060506@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1294915672 24698 80.91.229.12 (13 Jan 2011 10:47:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 13 Jan 2011 10:47:52 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Jan 13 11:47:46 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PdKiX-0006gy-9w for guile-user@m.gmane.org; Thu, 13 Jan 2011 11:47:45 +0100 Original-Received: from localhost ([127.0.0.1]:36085 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdKiW-0003N3-5B for guile-user@m.gmane.org; Thu, 13 Jan 2011 05:47:44 -0500 Original-Received: from [140.186.70.92] (port=59376 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdKiM-0003Lr-95 for guile-user@gnu.org; Thu, 13 Jan 2011 05:47:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PdKiK-0002YH-QJ for guile-user@gnu.org; Thu, 13 Jan 2011 05:47:34 -0500 Original-Received: from mail-wy0-f169.google.com ([74.125.82.169]:37372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PdKiK-0002Y3-JO for guile-user@gnu.org; Thu, 13 Jan 2011 05:47:32 -0500 Original-Received: by wyj26 with SMTP id 26so1566842wyj.0 for ; Thu, 13 Jan 2011 02:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=AsQfQiYY7Se8elZr5sXfEGgKqnlFcvbt36vOMHzf8k0=; b=Gqb+WVgC8pvYC4dgmHtnN73LAlpl2dPItG9L5IzjlDIuxQjCnE1uIcI16/65vHSwWn fQALTuKIaqI5029x1tdKGNjmgLRg6Y+VLYXPFT96h43+hM4noBK8Vd5w1C1MxLbIgB95 JaH82O2JBAmTQHKt5fi+nHpKurqk881WEcN+w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=g5ebjG01Htw1OnV668KIMSt0ZaGlPtfYwfZzOpSSNs7uCE4KZYBwmFTAzBq+SovUpL KktLvD8uSIbspd+N/BRIRyrhV06KK4zDH4hseXlD8Lm2Nf1Z3TdueDQpsXu9BPLWflYf BQxkEqRNeKN+HVJArJQOeMDNlYzYEMAT2qsss= Original-Received: by 10.227.167.8 with SMTP id o8mr2158598wby.166.1294915651090; Thu, 13 Jan 2011 02:47:31 -0800 (PST) Original-Received: from [192.168.1.131] ([95.21.118.140]) by mx.google.com with ESMTPS id 11sm1253820wbj.13.2011.01.13.02.47.30 (version=SSLv3 cipher=RC4-MD5); Thu, 13 Jan 2011 02:47:30 -0800 (PST) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20101227 Iceowl/1.0b1 Icedove/3.0.11 In-Reply-To: <4D2AEBCA.8060506@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8357 Archived-At: 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: http://www.modis.ispras.ru/Lizorkin/sxml-tutorial.html#hevea:modif 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)) #nil (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! Cheers, Aleix