[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Lowdown & sxml-serializer not working together
From: |
Jim Ursetto |
Subject: |
Re: [Chicken-users] Lowdown & sxml-serializer not working together |
Date: |
Sun, 25 Aug 2013 02:57:25 -0500 |
On Aug 24, 2013, at 5:25 PM, Jim Ursetto <address@hidden> wrote:
> Unfortunately it doesn't declare the default namespace for html. You can
> work around this by providing a default namespace prefix *and* using the
> actual prefix (below, xhtml:) on your elements. This is kind of ugly.
> However, the stock serializer didn't even support default namespaces (!) so I
> may have simply overlooked this case when adding support. I'll see if I can
> look into it further.
I've added support for the default (unqualified) namespace ID in the source
SXML now; the code is available at https://github.com/ursetto/sxml-serializer
while I run a couple more tests. Formerly, you could render to unqualified
names but not use them properly in the source.
[Note: below, unqualified names are rendering to the xhtml: namespace, because
there is a list of default namespace URI -> ID mappings, called
conventional-ns-prefixes. To override this and render them without
qualification, add *default* as the 3rd arg of the namespace association (as
the "original prefix"). The word "original" is used as if the XML document was
the original source and you had parsed it to SXML; the SXML prefix and XML
prefix are permitted to differ.]
(use sxml-serializer)
(print
(serialize-sxml
'(*TOP*
(@ (*NAMESPACES*
(*default* "http://www.w3.org/1999/xhtml")
(cvt "http://xmlns.therebetygers.net/civet/0.1")))
(*PI* xml "version=\"1.0\" encoding=\"utf-8\"")
(html
(@ (xml:lang "en") (lang "en"))
(cvt:template
(cvt:head
(cvt:locale (@ (lang "en") (country "US") (encoding "utf-8"))))
(cvt:block (@ (name "headerContent"))
#\< Single #\space (#\a #\r #\t #\i #\c #\l #\e)
#\space "page>"))))
))
<?xml version="1.0" encoding="utf-8"?>
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<cvt:template xmlns:cvt="http://xmlns.therebetygers.net/civet/0.1">
<cvt:head>
<cvt:locale lang="en" country="US" encoding="utf-8" />
</cvt:head>
<cvt:block name="headerContent"><Single article page></cvt:block>
</cvt:template>
</xhtml:html>