[Catalyst] Can Catalyst-Plugin-AtomServer support nontext/xhtml content?

John Napiorkowski jjn1056 at yahoo.com
Mon Sep 25 18:53:06 CEST 2006

--- Jonathan Rockway <jon at jrock.us> wrote:

> XML::Atom is for Atom ("RSS") feeds.  If you have
> non-Atom tags in your
> XML, I think the feed server assumes it's some
> variant of XHTML instead.
>  What is the xmlns on the <div> tags?
> Here's how you're "supposed" to use
> C::P::AtomServer:
> Also, Atom's mime type is application/atom+xml (not
> the others you
> tried), so that might mean something.
> But if your XML isn't Atom, I'm not sure why you're
> using
> C::P::AtomServer.  More information about what
> you're trying to achieve
> would be appreciated.  I see no problem with:
> sub serve_xml : ... {
>    my ($self, $c, @args) = @_;
>    $c->response->content_type('application/xml')
>    $c->response->body( XMLOut( [hash to xml encode]
> );
> }
> if all you want to do is spew some XML to the
> client.
> Regards,
> Jonathan Rockway
> John Napiorkowski wrote:
> > Hi,
> > 
> > I'm using the Catalyst-Plugin-AtomServer as a way
> to
> > expose some xml encoded data but having trouble
> > getting the plugin to accept a content type of
> 'xml'. 
> > I can do:
> > 
> > use XML::Simple;
> > my $content = XML::Atom::Content;
> > 
> > $content->type('application/xml')
> > $content->body( XMLOut( [hash to xml encode] );
> > 
> > and then add the content object to the entry
> object
> > but I still get output that wraps the XML in an
> xhtml
> > div tag.  The content type attribute does get set
> > correctly though and I do get the xml content
> inside
> > the content tags, just it has the extra div tag
> which
> > messes up my clients on the other side.  I've
> tried
> > 'application/xml', 'xml', 'text/xml', etc. but
> none of
> > these seem to work.
> > 
> > Has anyone gotten this to work with this plugin or
> > found a different way to accomplsih this task? 
> Advice
> > appreciate

My project goal is to build a set of REST inspired web
services that use ATOM as a wrapper, similar to what
Google is doing with it's Data API
Perhaps I don't fully understand how this works, but
my current understanding is that ATOM allows you to
specify xml inside the content tags as long as you set
a type attribute of something with 'xml' in it, like
"application/xml" for example.

There are a lot of different ways to build this kind
of service.  We could have choosen something like the
XOXO format for our list oriented data, for example,
or to just use XML::Dumper on the stash/request body. 
I felt there were security concerns with this, but
with the correct checking I suppose that wouldn't
really be a problem.

I'd be happy to give additional details about my
project, but what I am trying to figure out is if the
XML::Atom plugin is going to support what I need to do
without having to modify it in some way.  Based on my
review of the code it seems like unless you set the
content body to something that looks like text
XML::Atom will automatically assume it xhtml and wrap
your content body in a <div> tag.  Here's what it
looks like when I create it in XML::Atom(this is a
test example):

## Create an XML::Atom Entry object, etc.
my $content = XML::Atom::Content;


  <member xmlns="http://mysite.com/ns#member">
    <name>blah blah</name>

and what I see in the browser after passing this
through the XML::Atom::View module:

  <div xmlns="http://www.w3.org/1999/xhtml">
    <member xmlns="http://mysite.com/ns#member" >
      <name>blah blah</name>

Now the atom spec says I can do XML content and have
it look like (same example as above):

<content type="application/xml">
  <member xmlns="http://mysite.com/ns#member" >
    <name>blah blah</name>

However nothing I do seems to get the XML::Atom plugin
to work this way.  Now, I realize this is not a
tradional use for this kind of feed, but the
specification seems to indicate it's a valid one.

Another approach I could take is how Google is doing
this by adding a new namespace and placing the data
elements inside the entry tag and not the content tag.
 Maybe this is a better way?  This would look (very
roughly like)

<entry member:xmlsn="http://mysite.com/ns#member">
    <member:name>blah blah</name>

It just seems neater to me to place all my stuff
inside the content tag, that way I can easily parse it
by sending the return to entry->content->body to
XML::Simple or some other xml parser.

Anyway, if anyone has gotten this plugin to perform in
this way I'd appreciate hearing about it.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the Catalyst mailing list