[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Another lowdown->sxml-serializer problem
From: |
Moritz Heidkamp |
Subject: |
Re: [Chicken-users] Another lowdown->sxml-serializer problem |
Date: |
Sat, 12 Oct 2013 00:07:00 +0200 |
Hi Matt,
Matt Gushee <address@hidden> writes:
> I have observed the following undesired behavior:
[...]
> Any solutions for this?
I'm sorry that I didn't get around to changing Lowdown so that it
produces SXML conformant with the spec, yet. In the meantime you can use
this code to clean it up I think (works at least for your example):
(use srfi-1 sxml-transforms)
(define sxml-normalization-rules
`((*text* . ,(lambda (_ x) (->string x)))
(*default* . ,(lambda (tag children)
(cons tag
(append-map
(lambda (x)
(cond ((not (list? x)) (list x))
((null? x) x)
((symbol? (car x)) (list x))
(else x)))
children))))))
(define (normalize-sxml doc)
(pre-post-order* doc sxml-normalization-rules))
Jim, maybe sxml-serializer can be patched so that it handles this
situation in accordance with Postel's law, too?
Hope that helps!
Moritz