Atom Feed Issues
Posted April 12th, 2005 @ 03:32pm by Erik J. Barzeski
I wanted to modify the Atom feed with some HTML, but that breaks validation. Here's a sample:
<content type="text/html" mode="escaped" xml:lang="en" xml:base="<MTBlogURL encode_xml="1">"> <p><MTEntryExcerpt encode_xml="1"></p> <p><a href="http://nslog.com/" title="Visit NSLog();">Click</a></p>
I thought it should work. It defines the type, after all, as text/html. Instead, feedvalidator tells me "Undefined content element: p". Hmmmm.
The MovableType default template is:
<content type="text/html" mode="escaped" xml:lang="en" xml:base="<$MTBlogURL encode_xml="1"$>"> <$MTEntryBody encode_xml="1"$> <$MTEntryMore encode_xml="1"$>
Any ideas? It's probably something silly, and when someone gives the right answer I'll smack my forehead. Video available to the person who gets causes such a reaction. 🙂
Posted 12 Apr 2005 at 4:00pm #
Aside from the fact that your [a] tag isn't closed, which I assume is a case of trying to get a simple example up quickly, I think the problem with what you're doing is that the p and a elements aren't defined in the atom spec, which is what you're saying if you have xmlns="http://purl.org/atom/ns#draft-ietf-atompub-format-07" or something like that in your feed element. That defines a default namespace, indicating that all elements without a specific namespace are in that one. What you need to do is to specify that the p and a tags are in the XHTML namespace, either by specifying an alternate namespace in your feed element and prefixing it to your p and a (making them xhtml:p and xhtml:a, as a possible example) or by overriding the default namespace inherited from the feed element, as is done in the example in the draft IETF spec for Atom (see the example at the top of page 3 ).
Hope this helps.
Posted 12 Apr 2005 at 5:03pm #
Thanks. Using "xhtml:" in the tags didn't work, but I'll try finding another namespace.
Posted 12 Apr 2005 at 5:29pm #
I've got it. It's fixed now. Thanks Patrick.