Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 32606
Status: rejected
Priority: 0/
Queue: XML-Atom-SimpleFeed

People
Owner: Nobody in particular
Requestors: james.every [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Sorting entries in XML-Atom-SimpleFeed
Date: Thu, 24 Jan 2008 08:22:06 +0000
To: bug-xml-atom-simplefeed [...] rt.cpan.org
From: "James Every" <james.every [...] gmail.com>
Thank you for a very useful library! I have one question - my code that generates my atom feed is merging events from various sources and it is easier for me to sort the entries in time order when generating the XML rather than adding the entries to the feed in the correct order. I have added a sort call to the as_string method (see below code from v0.7 though your v0.8 looks similar): sub as_string { my $self = shift; $self->{entries} = sort {$a->{issued} <=> $b->{issued} } @{ $self->{feed}[0]{entry} }; # This sorts the entries but wraps the root <feed...> in another <feed> tag! my $xml = XMLout( $self, SuppressEmpty => 1, RootName => 'feed', KeepRoot => 1, AttrIndent => 1 ); return $xml; } This code almost works but produces an extra unwanted outer <feed> tag: <feed> <feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> I understand this is more of a 'Perl' question than a 'SimpleFeed' question but maybe you could suggest how to fix the sort line? My Perl is very rusty I haven't used it in a few years! Regards, James
On Thu Jan 24 03:22:27 2008, james.every@gmail.com wrote: Show quoted text
> it is easier for me to sort the entries in time order when generating > the XML rather than adding the entries to the feed in the correct > order.
Why? The order of entries in a feed doesn’t matter. Show quoted text
> I have added a sort call to the as_string method (see below code from > v0.7 though your v0.8 looks similar):
Not actually. 0.7 uses XML::Simple to generate the feed; 0.8 uses a hand-rolled XML emitter and a very different data structure – entries are rendered to strings immediately, so if you want to sort them based on their contents you’d have to parse them back apart at sorting time. I have long meant to revamp XML::Atom::SimpleFeed to use a much better internal format so I could also largely clean up the code, but I’ve yet to get around to that. Show quoted text
> I understand this is more of a ‘Perl’ question than a ‘SimpleFeed’ > question but maybe you could suggest how to fix the sort line?
It’s actually neither – it’s an XML::Simple question, which means, I’m afraid, that I have no idea how to fix the problem. I never used that module. (SimpleFeed has only been in my care since the 0.8 release; 0.7 was H. Wade Minter’s work.) Sorry. :-( PS.: the 0.7 release you’re using only supports the pre-standard Atom 0.3 feed format, which has been deprecated for nearly 2.5 years. Updating it to generate Atom 1.0 was the reason Wade passed me the maintainer hat.