Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the XML-Atom CPAN distribution.

Report information
The Basics
Id:
21733
Status:
open
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
jjn1056 [...] yahoo.com
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
0.23
Fixed in:
(no value)



Subject: Can't seem to set content with type of */xml
Hi, I've been trying to create a XML::Atom::Content with a mimetype of xml but no matter what I do the module wraps my content in a <div> tag with a xhtml namespace. It also adds some other namespaces. Here is an example: use XML::Simple; my $content = XML::Atom::Content; $content->type('application/xml') $content->body( XMLOut( [hash to xml encode] ); Then I add the $content to an XML::Atom::Entry and render it to a string. What I get is something like: <content xmlns="http://www.w3.org/2005/Atom" xmlns:default="http://www.w3.org/1999/xhtml" type="application/xml"> <div xmlns="http://www.w3.org/1999/xhtml"> <member xmlns="http://mysite.com/ns#member" > <name>blah blah</name> <title>nobody</title> </member> </div> </content> But I should be able to get: <content type="application/xml"> <member xmlns="http://mysite.com/ns#member" > <name>blah blah</name> <title>nobody</title> </member> </content> From looking at the code it seems like this module only support text and xhtml for the value of content tags, however the Atom specification should allow otherwise. I'd like to help try to solve this problem and have some developer time I can assign for your assistance. Please let me know if you are interested. Right now I don't think I understand this well enough to offer a useful patch. Thanks! --john (jjn1056@yahoo.com)
CC: jjn1056@yahoo.com
Subject: Re: [rt.cpan.org #21733] Can't seem to set content with type of */xml
Date: Wed, 27 Sep 2006 17:46:07 +0900
To: bug-XML-Atom@rt.cpan.org
From: "Tatsuhiko Miyagawa" <miyagawa@gmail.com>
Yeah, I understand this problem and it's on our todo list. Sorry for the inconvenience. On 9/27/06, jjn1056@yahoo.com via RT <bug-XML-Atom@rt.cpan.org> wrote:
Show quoted text
> > Tue Sep 26 16:51:02 2006: Request 21733 was acted upon. > Transaction: Ticket created by jjn1056@yahoo.com > Queue: XML-Atom > Subject: Can't seem to set content with type of */xml > Broken in: 0.23 > Severity: Important > Owner: Nobody > Requestors: jjn1056@yahoo.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=21733 > > > > Hi, > > I've been trying to create a XML::Atom::Content with a mimetype of xml > but no matter what I do the module wraps my content in a <div> tag with > a xhtml namespace. It also adds some other namespaces. > > Here is an example: > > use XML::Simple; > my $content = XML::Atom::Content; > > $content->type('application/xml') > $content->body( XMLOut( [hash to xml encode] ); > > Then I add the $content to an XML::Atom::Entry and render it to a > string. What I get is something like: > > <content > xmlns="http://www.w3.org/2005/Atom" > xmlns:default="http://www.w3.org/1999/xhtml" > type="application/xml"> > <div xmlns="http://www.w3.org/1999/xhtml"> > <member xmlns="http://mysite.com/ns#member" > > <name>blah blah</name> > <title>nobody</title> > </member> > </div> > </content> > > But I should be able to get: > > <content type="application/xml"> > <member xmlns="http://mysite.com/ns#member" > > <name>blah blah</name> > <title>nobody</title> > </member> > </content> > > From looking at the code it seems like this module only support text and > xhtml for the value of content tags, however the Atom specification > should allow otherwise. > > I'd like to help try to solve this problem and have some developer time > I can assign for your assistance. Please let me know if you are > interested. Right now I don't think I understand this well enough to > offer a useful patch. Thanks! > > --john (jjn1056@yahoo.com) >
-- Tatsuhiko Miyagawa
From: icestar@inbox.ru
On Wed Sep 27 04:46:20 2006, miyagawa@gmail.com wrote:
Show quoted text
> Yeah, I understand this problem and it's on our todo list. Sorry for > the inconvenience. >
5 years have gone but this bug still hasn't been fixed. At the same time it's critical and almost impossible to pass complex data structures in the content without correct handling of XML type. It shouldn't be very difficult to fix it, do you need any help?
Subject: Re: [rt.cpan.org #21733] Can't seem to set content with type of */xml
Date: Tue, 7 Jun 2011 09:11:27 -0700
To: bug-XML-Atom@rt.cpan.org
From: Tatsuhiko Miyagawa <miyagawa@gmail.com>
Show quoted text
> > 5 years have gone but this bug still hasn't been fixed. At the same time > it's critical and almost impossible to pass complex data structures in > the content without correct handling of XML type. It shouldn't be very > difficult to fix it, do you need any help?
If you think it's not difficult to fix it, why not submit a patch with a test suite? -- Tatsuhiko Miyagawa
From: icestar@inbox.ru
On Tue Jun 07 12:11:55 2011, miyagawa@gmail.com wrote:
Show quoted text
> > If you think it's not difficult to fix it, why not submit a patch with > a test suite? >
Hello Tatsuhiko! Please, consider this simple patch, which allows me to pass in the XML::Atom::Content constructor */xml and plain text data. Here are some examples of content object creation: $content = XML::Atom::Content->new(Body => $xml->toString, Type => "text/ xml"); $entry->content(XML::Atom::Content->new(Body => $msg, Type => "text"));
Subject: Content.pm.patch
--- initContent.pm 2011-06-14 12:36:31.000000000 +0400 +++ patchedContent.pm 2011-07-20 10:06:50.000000000 +0400 @@ -17,12 +17,12 @@ my $content = shift; my %param = @_ == 1 ? (Body => $_[0]) : @_; $content->SUPER::init(%param); - if ($param{Body}) { - $content->body($param{Body}); - } if ($param{Type}) { $content->type($param{Type}); } + if ($param{Body}) { + $content->body($param{Body}); + } return $content; } @@ -48,7 +48,7 @@ $content->mode('base64'); } } else { - my $copy = '<div xmlns="http://www.w3.org/1999/xhtml">' . + my $copy = ($content->type =~ /(text|[/+]xml)$/) ? $data : '<div xmlns="http://www.w3.org/1999/xhtml">' . $data . '</div>'; my $node; @@ -68,7 +68,7 @@ if ($content->version == 0.3) { $content->mode('xml'); } else { - $content->type('xhtml'); + $content->type('xhtml') unless defined $content->type; } } else { if (LIBXML) {


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.