[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sxml boolean
From: |
john |
Subject: |
Re: sxml boolean |
Date: |
Sat, 31 Mar 2012 19:18:21 +0100 |
Hi Mark,
On 31 March 2012 16:46, Mark H Weaver <address@hidden> wrote:
> Hi John,
>
> john <address@hidden> writes:
>> When using (sxml simple) a conversion from boolean has no value. For
>> example, (sxml->xml '(foo #t)) produces <foo></foo>. Is this intended
>> or a bug? I was expecting perhaps something like <foo>true</foo>,
>> <foo>1</foo> or <foo>#t</foo>.
>
> (foo #t) is not valid SXML, and 'sxml->xml' assumes valid SXML,
> so the result is undefined. The SXML grammar is defined at:
>
> http://okmij.org/ftp/Scheme/SXML.html
>
> Arbitrary Scheme values are _not_ allowed, and there is no attempt to
> guess how the user would like those to be formatted. A child of an
> element must either be another element, a processing instruction, a
> comment, an entity, or character data. Character data must be
> represented as a Scheme string, and all the others are represented by
> Scheme lists. See the spec for details.
>
>> The first two make more sense to me in terms of validating against XML
>> Schema but I think any value is better than no value.
>
> We didn't design SXML. Oleg Kiselyov did. However, I think he made the
> right decision here. IMO, it would have been a mistake to define a
> behavior for other Scheme values. Whatever behavior he chose, it would
> not be what many users wanted, and it would make the definition and
> implementation of SXML considerably more complex.
>
> The only advantage would be a minor convenience in case the user
> happened to want the same formatting choices that Oleg had made. It is
> easy and far more flexible for the user to write their own converter
> that formats Scheme values as they need for their specific application.
>
> Does that make sense?
>
> Regards,
> Mark
Yes it does. Thanks for the explanation.
Cheers,
John