Kid playing nice with MochiKit

0 views
Skip to first unread message

Brian Beck

unread,
Dec 7, 2005, 1:39:41 AM12/7/05
to TurboGears
Hi,

I assume that since I couldn't find a bunch of other people asking the
same question, I must be missing something or doing something wrong.

I'm trying to do something like the Sortable Tables demo in a Kid
template, but Kid complains with an "unbound prefix" exception wherever
I use mochi:format attributes, causing an internal server error.

What's the trick here?

Jared Kuolt

unread,
Dec 7, 2005, 1:49:51 AM12/7/05
to turbo...@googlegroups.com
I think that since Kid views everything as XML, it thinks "mochi:" is
a namespace. I'm assuming it's failing because it is not declared as
such.

You may be able to get away with putting something like this in your
template, though be aware it is a hack. That, and I don't even know if
it'd work.

<html xmlns:mochikit="http://thisisafakenamespace.org/">

Good luck.


--
jared...@gmail.com

Brian Beck

unread,
Dec 7, 2005, 1:50:16 AM12/7/05
to TurboGears
Brian Beck wrote:
> What's the trick here?

Found it. Forgot to add mochi:format to the DTD attribute list.

Brian Beck

unread,
Dec 7, 2005, 1:52:34 AM12/7/05
to TurboGears
Brian Beck wrote:
> Found it. Forgot to add mochi:format to the DTD attribute list.

For anyone else who runs into this, here's a comment from the top of
the Sortable Tables HTML:

Technically we should be using this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [<!ATTLIST th
mochi:format CDATA #IMPLIED>]>

However, that will only work if the document is served with a
Content-Type of "application/xhtml+xml". Browsers don't parse the tag
right otherwise.

Jared Kuolt

unread,
Dec 7, 2005, 1:54:06 AM12/7/05
to turbo...@googlegroups.com
Doesn't IE choke on that Content-Type?

On 12/6/05, Brian Beck <exo...@gmail.com> wrote:
>


--
jared...@gmail.com

Brian Beck

unread,
Dec 7, 2005, 2:02:57 AM12/7/05
to TurboGears
Jared Kuolt wrote:
> Doesn't IE choke on that Content-Type?

Not sure, but it didn't solve my problem anyway, since Kid ignores the
DTD you give it and puts in its own. Also tried the xlmns:mochi thing
you suggested, still can't get the template to render. Where can I
modify "sitetemplate" that master.kid extends from? If that has the
DTD and base html tag, then I think I can make it work.

Michele Cella

unread,
Dec 7, 2005, 3:33:42 AM12/7/05
to TurboGears

Sylvain Hellegouarch

unread,
Dec 7, 2005, 4:01:13 AM12/7/05
to turbo...@googlegroups.com

Selon Brian Beck <exo...@gmail.com>:

Indeed. They don't because if you send XHTML with text/html, browsers think you
send them HTML and not XML.

http://www.hixie.ch/advocacy/xhtml


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Brian Beck

unread,
Dec 7, 2005, 3:11:04 PM12/7/05
to TurboGears
Michele Cella wrote:
> http://trac.turbogears.org/turbogears/browser/trunk/turbogears/view.py#L49

This is getting a bit more complicated than I think it should be...
even if I tell master.kid not to extend sitetemplate, Kid overrides its
DTD and html tag (where xlmns attributes are listed).

Hasn't anyone already used both MochiKit attributes and Kid at the same
time? How'd you do it?

David Stanek

unread,
Dec 8, 2005, 6:57:46 AM12/8/05
to turbo...@googlegroups.com
Declaring the namespace should get the HTML to render OK. The following raises an exception during parsing:
    <html xmlns:py="http://purl.org/kid/ns#" >
        <element mochi:format="" />
    </html>

To get it to render OK all I had to do was:
    <html xmlns:py="http://purl.org/kid/ns#"
         xmlns:mochi="some_unique_uri">
        <element mochi:format="" />
    </html>

....which will give as it's final output:
    <?xml version="1.0" encoding="utf-8"?>
    <html xmlns:mochi="some_unique_uri">
        <element mochi:format="" />
    </html>

I hope this helps.

-- David
Reply all
Reply to author
Forward
0 new messages