Re: [Chicken-users] Another lowdown->sxml-serializer problem
That seems to work. Thank you very much! On Fri, Oct 11, 2013 at 4:07 PM, Moritz Heidkamp wrote: > Hi Matt, > > Matt Gushee 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 ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Another lowdown->sxml-serializer problem
Hi Matt, Matt Gushee 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 ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Another lowdown->sxml-serializer problem
Hi, John etc.-- On Fri, Oct 11, 2013 at 7:58 AM, John Cowan wrote: >> 2. Convert w/ markdown->sxml: >> >> ((p "This" (#\space) "fragment" >> (a (@ (href ("http://call-cc.org/";))) "Chicken" (#\space) "Scheme") ".")) > > Well, evidently this is a bug in markdown->sxml, since the above is not > well-formed SXML. Not only is the URL incorrectly being wrapped in a > list, but the lists of characters aren't really SXML either. Hmm, pretty much what I thought, but I'm not confident enough in my understanding of SXML to have said that. Well, any recommendations, then? This is holding up the release of a new egg, so if Moritz doesn't have a quick fix for lowdown, I'd like to try another approach. Despite what I said about sxml-transforms, I'm willing to try it, but might need some help figuring it out. The problem I've had when I've tried it is that namespace declarations and processing instructions are not rendered properly--they are escaped so as to become visible on an HTML page. Actually, there aren't really any processing instructions--I am referring to the XML declaration, which is syntactically equivalent to a PI but is not really a PI; and since the XML declaration is not strictly required, and I don't think PIs are widely used in general, it wouldn't be a big deal to say "this system can't handle PIs or XML declarations." Namespaces, on the other hand, are an essential part of the process. The template processor, civet, uses them to distinguish between literal content and control structures, so the input XML template has to have at least two namespace declarations, and it doesn't seem like a good idea to omit them from the output (e.g. if the output is XHTML, as I expect will usually be the case ... well, I need to research this, but I highly suspect there are browsers that won't handle XHTML correctly without the namespace declaration). So, it probably isn't a very hard problem, but I just have not yet grasped how to create custom rules for sxml-transforms. Any light you can shed would be appreciated. -- Matt Gushee ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Another lowdown->sxml-serializer problem
Andy Bennett scripsit: > Unfortunately some of the SXML tooling is OK with something that isn't > an element name appearing in the car of a list and some of it isn't. "Be conservative in what you do, liberal in what you accept from others." Any routine that purports to generate SXML should do just that. -- A poetical purist named Cowan [that's me: co...@ccil.org] Once put the rest of us dowan. [on xml-dev] "Your verse would be sweeterhttp://www.ccil.org/~cowan If it only had metre And rhymes that didn't force me to frowan." [overpacked line!] --Michael Kay ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Another lowdown->sxml-serializer problem
Hi, >> 2. Convert w/ markdown->sxml: >> >> ((p "This" (#\space) "fragment" >> (a (@ (href ("http://call-cc.org/";))) "Chicken" (#\space) "Scheme") ".")) > > Well, evidently this is a bug in markdown->sxml, since the above is not > well-formed SXML. Not only is the URL incorrectly being wrapped in a > list, but the lists of characters aren't really SXML either. Agreed. Unfortunately some of the SXML tooling is OK with something that isn't an element name appearing in the car of a list and some of it isn't. Both ("http://call-cc.org/";) and (#\space) are badly-formed sxml that the sxml->html tooling will generally be ok with and most things that use foldts generally will not be. :-( Regards, @ndy -- andy...@ashurst.eu.org http://www.ashurst.eu.org/ 0x7EBA75FF ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Another lowdown->sxml-serializer problem
Matt Gushee scripsit: > 2. Convert w/ markdown->sxml: > > ((p "This" (#\space) "fragment" > (a (@ (href ("http://call-cc.org/";))) "Chicken" (#\space) "Scheme") ".")) Well, evidently this is a bug in markdown->sxml, since the above is not well-formed SXML. Not only is the URL incorrectly being wrapped in a list, but the lists of characters aren't really SXML either. -- John Cowan http://ccil.org/~cowanco...@ccil.org Monday we watch-a Firefly's house, but he no come out. He wasn't home. Tuesday we go to the ball game, but he fool us. He no show up. Wednesday he go to the ball game, and we fool him. We no show up. Thursday was a double-header. Nobody show up. Friday it rained all day. There was no ball game, so we stayed home and we listened to it on-a the radio. --Chicolini ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users