Loading ...
Sorry, an error occurred while loading the content.

Bug in 0.33

Expand Messages
  • whitbygreg
    Hi I was parsing a RSS 2.0 feed and was unable to get the pubDate from the items. I looked through the code and found in package
    Message 1 of 7 , Mar 1, 2008
    View Source
    • 0 Attachment
      Hi I was parsing a RSS 2.0 feed and was unable to get the pubDate
      from the items.

      I looked through the code and found in package
      XML::FeedPP::RSS::Item->pubDate() that it called
      get_pubDate_w3cdtf(), however unlike the other packages _w2cdtf was
      not mapped to _native, I added add:

      *get_pubDate_w3cdtf = \&get_pubDate_native;

      just after the _native function and all seems to work correctly.

      Greg
    • whitbygreg
      Looks like the same is true for XML::FeedPP::RSS::Feed- ... Greg ... pubDate
      Message 2 of 7 , Mar 1, 2008
      View Source
      • 0 Attachment
        Looks like the same is true for XML::FeedPP::RSS::Feed-
        >pubDate(), same fix seems to work.

        Greg

        --- In xml-feedpp@yahoogroups.com, "whitbygreg" <greg@...> wrote:
        >
        >
        > Hi I was parsing a RSS 2.0 feed and was unable to get the
        pubDate
        > from the items.
        >
        > I looked through the code and found in package
        > XML::FeedPP::RSS::Item->pubDate() that it called
        > get_pubDate_w3cdtf(), however unlike the other packages _w2cdtf was
        > not mapped to _native, I added add:
        >
        > *get_pubDate_w3cdtf = \&get_pubDate_native;
        >
        > just after the _native function and all seems to work correctly.
        >
        > Greg
        >
      • Kawasaki Yusuke
        Greg, X::F::RSS::Item class does not have _w3cdtf function. However, The X::F::RSS::Item class inherits X::F::Item class which has _w3cdtf function. In this
        Message 3 of 7 , Mar 1, 2008
        View Source
        • 0 Attachment
          Greg,

          X::F::RSS::Item class does not have _w3cdtf function.
          However, The X::F::RSS::Item class inherits X::F::Item class which has
          _w3cdtf function.
          In this case, I don't think _w3cdtf function is required in
          X::F::RSS::Item class.

          Calling pubDate() without instance:
          XML::FeedPP::RSS::Item::pubDate() ; # error
          Calling pubDate() with a instance:
          XML::FeedPP::RSS::Item->new->pubDate() ; # ok

          08_datetime.t supposes that pubDate must be called with instance.
          Let us know other cases you faced to the problem (with sample feed or code).

          ----

          Possibly, when you want to call _w3cdtf-type functions directly from your code,
          use XML::FeedPP::Util class which is undocumented yet.

          XML::FeedPP::Util::get_w3cdtf($date); # rfc1123/epoch to w3cdtf
          XML::FeedPP::Util::get_rfc1123($date); # w3cdtf/epoch to rfc1123
          XML::FeedPP::Util::get_epoch($date); # w3cdtf/rfc1123 to epoch

          The X::F::Util calss has light-weight functions to manipulate
          date, time and some of timezone representations.
          I'd not like to make XML::FeedPP require the great
          DateTime-family modules which have heavy dependencies.

          #### Base class

          package XML::FeedPP;
          sub get_pubDate_w3cdtf {
          my $self = shift;
          my $date = $self->get_pubDate_native();
          XML::FeedPP::Util::get_w3cdtf($date);
          }

          package XML::FeedPP::Item;
          *get_pubDate_w3cdtf = \&XML::FeedPP::get_pubDate_w3cdtf; # import

          #### RSS (RSS 2.0)

          package XML::FeedPP::RSS;
          @ISA = qw( XML::FeedPP );
          # here is no *get_pubDate_w3cdtf alias

          package XML::FeedPP::RSS::Item;
          @ISA = qw( XML::FeedPP::Item );
          # here is no *get_pubDate_w3cdtf alias

          #### RDF (RSS 1.0)

          package XML::FeedPP::RDF;
          @ISA = qw( XML::FeedPP );
          *get_pubDate_w3cdtf = \&get_pubDate_native;

          package XML::FeedPP::RDF::Item;
          @ISA = qw( XML::FeedPP::Item );
          *get_pubDate_w3cdtf = \&get_pubDate_native;

          #### Atom 0.3/1.0

          package XML::FeedPP::Atom::Atom03;
          @ISA = qw( XML::FeedPP::Atom::Common );
          *get_pubDate_w3cdtf = \&get_pubDate_native;

          package XML::FeedPP::Atom::Atom10;
          @ISA = qw( XML::FeedPP::Atom::Common );
          *get_pubDate_w3cdtf = \&get_pubDate_native;

          package XML::FeedPP::Atom::Atom03::Entry;
          @ISA = qw( XML::FeedPP::Atom::Common::Entry );
          *get_pubDate_w3cdtf = \&get_pubDate_native;

          package XML::FeedPP::Atom::Atom10::Entry;
          @ISA = qw( XML::FeedPP::Atom::Common::Entry );
          *get_pubDate_w3cdtf = \&get_pubDate_native;

          --
          Kawasaki Yusuke
          http://www.kawa.net/




          On Sun, Mar 2, 2008 at 1:49 PM, whitbygreg <greg@...> wrote:
          >
          > Hi I was parsing a RSS 2.0 feed and was unable to get the pubDate
          > from the items.
          >
          > I looked through the code and found in package
          > XML::FeedPP::RSS::Item->pubDate() that it called
          > get_pubDate_w3cdtf(), however unlike the other packages _w2cdtf was
          > not mapped to _native, I added add:
          >
          > *get_pubDate_w3cdtf = \&get_pubDate_native;
          >
          > just after the _native function and all seems to work correctly.
          >
          > Greg
        • whitbygreg
          I m not calling _w3cdtf from my code, here s an example of where it fails: use XML::FeedPP; my $source = http://rss.theweathernetwork.com/weather/caon0696 ;
          Message 4 of 7 , Mar 2, 2008
          View Source
          • 0 Attachment
            I'm not calling _w3cdtf from my code, here's an example of where it
            fails:

            use XML::FeedPP;

            my $source = 'http://rss.theweathernetwork.com/weather/caon0696';
            my $feed = XML::FeedPP->new( $source );
            print "Title: ", $feed->title(), "\n";
            print "Date: ", $feed->pubDate(), "\n";
            foreach my $item ( $feed->get_item() ) {
            print "URL: ", $item->link(), "\n";
            print "Title: ", $item->title(), "\n";
            print "Date: ", $item->pubDate(), "\n";
            }


            You'll notice that the rss and items don't have associated date
            information, for the feed that's fine, it's not present in the feed,
            but the item date data is but is not returned.

            So there's something wrong somewhere and my 'fix' below seems to
            correct the issue. I don't have much experience with perl so perhaps
            there's something else amiss that is really the issue.

            Thanks for any help.

            Greg



            --- In xml-feedpp@yahoogroups.com, "Kawasaki Yusuke" <u-suke@...>
            wrote:
            >
            > Greg,
            >
            > X::F::RSS::Item class does not have _w3cdtf function.
            > However, The X::F::RSS::Item class inherits X::F::Item class which
            has
            > _w3cdtf function.
            > In this case, I don't think _w3cdtf function is required in
            > X::F::RSS::Item class.
            >
            > Calling pubDate() without instance:
            > XML::FeedPP::RSS::Item::pubDate() ; # error
            > Calling pubDate() with a instance:
            > XML::FeedPP::RSS::Item->new->pubDate() ; # ok
            >
            > 08_datetime.t supposes that pubDate must be called with instance.
            > Let us know other cases you faced to the problem (with sample feed
            or code).
            >
            > ----
            >
            > Possibly, when you want to call _w3cdtf-type functions directly
            from your code,
            > use XML::FeedPP::Util class which is undocumented yet.
            >
            > XML::FeedPP::Util::get_w3cdtf($date); # rfc1123/epoch to
            w3cdtf
            > XML::FeedPP::Util::get_rfc1123($date); # w3cdtf/epoch to
            rfc1123
            > XML::FeedPP::Util::get_epoch($date); # w3cdtf/rfc1123 to
            epoch
            >
            > The X::F::Util calss has light-weight functions to manipulate
            > date, time and some of timezone representations.
            > I'd not like to make XML::FeedPP require the great
            > DateTime-family modules which have heavy dependencies.
            >
            > #### Base class
            >
            > package XML::FeedPP;
            > sub get_pubDate_w3cdtf {
            > my $self = shift;
            > my $date = $self->get_pubDate_native();
            > XML::FeedPP::Util::get_w3cdtf($date);
            > }
            >
            > package XML::FeedPP::Item;
            > *get_pubDate_w3cdtf = \&XML::FeedPP::get_pubDate_w3cdtf; # import
            >
            > #### RSS (RSS 2.0)
            >
            > package XML::FeedPP::RSS;
            > @ISA = qw( XML::FeedPP );
            > # here is no *get_pubDate_w3cdtf alias
            >
            > package XML::FeedPP::RSS::Item;
            > @ISA = qw( XML::FeedPP::Item );
            > # here is no *get_pubDate_w3cdtf alias
            >
            > #### RDF (RSS 1.0)
            >
            > package XML::FeedPP::RDF;
            > @ISA = qw( XML::FeedPP );
            > *get_pubDate_w3cdtf = \&get_pubDate_native;
            >
            > package XML::FeedPP::RDF::Item;
            > @ISA = qw( XML::FeedPP::Item );
            > *get_pubDate_w3cdtf = \&get_pubDate_native;
            >
            > #### Atom 0.3/1.0
            >
            > package XML::FeedPP::Atom::Atom03;
            > @ISA = qw( XML::FeedPP::Atom::Common );
            > *get_pubDate_w3cdtf = \&get_pubDate_native;
            >
            > package XML::FeedPP::Atom::Atom10;
            > @ISA = qw( XML::FeedPP::Atom::Common );
            > *get_pubDate_w3cdtf = \&get_pubDate_native;
            >
            > package XML::FeedPP::Atom::Atom03::Entry;
            > @ISA = qw( XML::FeedPP::Atom::Common::Entry );
            > *get_pubDate_w3cdtf = \&get_pubDate_native;
            >
            > package XML::FeedPP::Atom::Atom10::Entry;
            > @ISA = qw( XML::FeedPP::Atom::Common::Entry );
            > *get_pubDate_w3cdtf = \&get_pubDate_native;
            >
            > --
            > Kawasaki Yusuke
            > http://www.kawa.net/
            >
            >
            >
            >
            > On Sun, Mar 2, 2008 at 1:49 PM, whitbygreg <greg@...> wrote:
            > >
            > > Hi I was parsing a RSS 2.0 feed and was unable to get the
            pubDate
            > > from the items.
            > >
            > > I looked through the code and found in package
            > > XML::FeedPP::RSS::Item->pubDate() that it called
            > > get_pubDate_w3cdtf(), however unlike the other packages _w2cdtf
            was
            > > not mapped to _native, I added add:
            > >
            > > *get_pubDate_w3cdtf = \&get_pubDate_native;
            > >
            > > just after the _native function and all seems to work
            correctly.
            > >
            > > Greg
            >
          • Kawasaki Yusuke
            I see. The feed has pubDate elements like: Sun, 02 March 2008 12:00:00 EST XML::FeedPP modules expects: Sun, 02 Mar 2008 12:00:00
            Message 5 of 7 , Mar 2, 2008
            View Source
            • 0 Attachment
              I see. The feed has pubDate elements like:
              <pubDate>Sun, 02 March 2008 12:00:00 EST</pubDate>
              XML::FeedPP modules expects:
              <pubDate>Sun, 02 Mar 2008 12:00:00 EST</pubDate>
              Longer name of month is used in the feed.

              In FeedPP.pm, change the regexp below:
              ------------------------------------------------
              my $rfc1123_regexp = qr{
              - ^(?:[A-Za-z]+,\s*)? (\d+)\s+ ([A-Za-z]+)\s+ (\d+)\s+
              + ^(?:[A-Za-z]+,\s*)? (\d+)\s+ ([A-Za-z]{3})(?:[A-Za-z]*)\s+ (\d+)\s+
              (\d+):(\d+)(?::(\d+)(?:\.\d*)?)?\s*
              ([\+\-]\d+:?\d{2} | [ECMP][DS]T )?
              }xi;
              ------------------------------------------------

              * before: ([A-Za-z]+) after: ([A-Za-z]{3})(?:[A-Za-z]*)

              This patch would be applied at the next release.
              Thanks!

              On Mon, Mar 3, 2008 at 1:57 AM, whitbygreg <greg@...> wrote:
              > I'm not calling _w3cdtf from my code, here's an example of where it
              > fails:
              >
              > use XML::FeedPP;
              >
              > my $source = 'http://rss.theweathernetwork.com/weather/caon0696';
              > my $feed = XML::FeedPP->new( $source );
              > print "Title: ", $feed->title(), "\n";
              > print "Date: ", $feed->pubDate(), "\n";
              > foreach my $item ( $feed->get_item() ) {
              > print "URL: ", $item->link(), "\n";
              > print "Title: ", $item->title(), "\n";
              > print "Date: ", $item->pubDate(), "\n";
              > }
              >
              >
              > You'll notice that the rss and items don't have associated date
              > information, for the feed that's fine, it's not present in the feed,
              > but the item date data is but is not returned.
              >
              > So there's something wrong somewhere and my 'fix' below seems to
              > correct the issue. I don't have much experience with perl so perhaps
              > there's something else amiss that is really the issue.
              >
              > Thanks for any help.
              >
              > Greg



              --
              Kawasaki Yusuke
              http://www.kawa.net/
            • whitbygreg
              It returns a date now, but it s not exactly what I was expecting ... Is there a way to specify which date format is returned? I was expecting the native RSS
              Message 6 of 7 , Mar 2, 2008
              View Source
              • 0 Attachment
                It returns a date now, but it's not exactly what I was expecting
                :)

                Is there a way to specify which date format is returned? I was
                expecting the native RSS 2.0 format not the W3CDTF format.

                Greg


                --- In xml-feedpp@yahoogroups.com, "Kawasaki Yusuke" <u-suke@...>
                wrote:
                >
                > I see. The feed has pubDate elements like:
                > <pubDate>Sun, 02 March 2008 12:00:00 EST</pubDate>
                > XML::FeedPP modules expects:
                > <pubDate>Sun, 02 Mar 2008 12:00:00 EST</pubDate>
                > Longer name of month is used in the feed.
                >
                > In FeedPP.pm, change the regexp below:
                > ------------------------------------------------
                > my $rfc1123_regexp = qr{
                > - ^(?:[A-Za-z]+,\s*)? (\d+)\s+ ([A-Za-z]+)\s+ (\d+)\s+
                > + ^(?:[A-Za-z]+,\s*)? (\d+)\s+ ([A-Za-z]{3})(?:[A-Za-z]*)\s+
                (\d+)\s+
                > (\d+):(\d+)(?::(\d+)(?:\.\d*)?)?\s*
                > ([\+\-]\d+:?\d{2} | [ECMP][DS]T )?
                > }xi;
                > ------------------------------------------------
                >
                > * before: ([A-Za-z]+) after: ([A-Za-z]{3})(?:[A-Za-z]*)
                >
                > This patch would be applied at the next release.
                > Thanks!
                >
                > On Mon, Mar 3, 2008 at 1:57 AM, whitbygreg <greg@...> wrote:
                > > I'm not calling _w3cdtf from my code, here's an example of where
                it
                > > fails:
                > >
                > > use XML::FeedPP;
                > >
                > > my $source = 'http://rss.theweathernetwork.com/weather/caon0696';
                > > my $feed = XML::FeedPP->new( $source );
                > > print "Title: ", $feed->title(), "\n";
                > > print "Date: ", $feed->pubDate(), "\n";
                > > foreach my $item ( $feed->get_item() ) {
                > > print "URL: ", $item->link(), "\n";
                > > print "Title: ", $item->title(), "\n";
                > > print "Date: ", $item->pubDate(), "\n";
                > > }
                > >
                > >
                > > You'll notice that the rss and items don't have associated date
                > > information, for the feed that's fine, it's not present in the
                feed,
                > > but the item date data is but is not returned.
                > >
                > > So there's something wrong somewhere and my 'fix' below seems to
                > > correct the issue. I don't have much experience with perl so
                perhaps
                > > there's something else amiss that is really the issue.
                > >
                > > Thanks for any help.
                > >
                > > Greg
                >
                >
                >
                > --
                > Kawasaki Yusuke
                > http://www.kawa.net/
                >
              • whitbygreg
                Ok, I ve worked out the date issue, now I have another one :) http://www.stargateworlds.com/rss/ Doens t have and XML tag around the feed, so of course it
                Message 7 of 7 , Mar 3, 2008
                View Source
                • 0 Attachment
                  Ok, I've worked out the date issue, now I have another one :)

                  http://www.stargateworlds.com/rss/

                  Doens't have and XML tag around the feed, so of course it breaks
                  when parsed...

                  I'm not sure what the proper response should be, should the feed
                  fix it's feed or should FeedPP accept the broken format?

                  Greg

                  --- In xml-feedpp@yahoogroups.com, "whitbygreg" <greg@...> wrote:
                  >
                  >
                  > It returns a date now, but it's not exactly what I was
                  expecting
                  > :)
                  >
                  > Is there a way to specify which date format is returned? I
                  was
                  > expecting the native RSS 2.0 format not the W3CDTF format.
                  >
                  > Greg
                  >
                  >
                  > --- In xml-feedpp@yahoogroups.com, "Kawasaki Yusuke" <u-suke@>
                  > wrote:
                  > >
                  > > I see. The feed has pubDate elements like:
                  > > <pubDate>Sun, 02 March 2008 12:00:00 EST</pubDate>
                  > > XML::FeedPP modules expects:
                  > > <pubDate>Sun, 02 Mar 2008 12:00:00 EST</pubDate>
                  > > Longer name of month is used in the feed.
                  > >
                  > > In FeedPP.pm, change the regexp below:
                  > > ------------------------------------------------
                  > > my $rfc1123_regexp = qr{
                  > > - ^(?:[A-Za-z]+,\s*)? (\d+)\s+ ([A-Za-z]+)\s+ (\d+)\s+
                  > > + ^(?:[A-Za-z]+,\s*)? (\d+)\s+ ([A-Za-z]{3})(?:[A-Za-z]*)\s+
                  > (\d+)\s+
                  > > (\d+):(\d+)(?::(\d+)(?:\.\d*)?)?\s*
                  > > ([\+\-]\d+:?\d{2} | [ECMP][DS]T )?
                  > > }xi;
                  > > ------------------------------------------------
                  > >
                  > > * before: ([A-Za-z]+) after: ([A-Za-z]{3})(?:[A-Za-z]*)
                  > >
                  > > This patch would be applied at the next release.
                  > > Thanks!
                  > >
                  > > On Mon, Mar 3, 2008 at 1:57 AM, whitbygreg <greg@> wrote:
                  > > > I'm not calling _w3cdtf from my code, here's an example of
                  where
                  > it
                  > > > fails:
                  > > >
                  > > > use XML::FeedPP;
                  > > >
                  > > > my $source = 'http://rss.theweathernetwork.com/weather/
                  caon0696';
                  > > > my $feed = XML::FeedPP->new( $source );
                  > > > print "Title: ", $feed->title(), "\n";
                  > > > print "Date: ", $feed->pubDate(), "\n";
                  > > > foreach my $item ( $feed->get_item() ) {
                  > > > print "URL: ", $item->link(), "\n";
                  > > > print "Title: ", $item->title(), "\n";
                  > > > print "Date: ", $item->pubDate(), "\n";
                  > > > }
                  > > >
                  > > >
                  > > > You'll notice that the rss and items don't have associated
                  date
                  > > > information, for the feed that's fine, it's not present in
                  the
                  > feed,
                  > > > but the item date data is but is not returned.
                  > > >
                  > > > So there's something wrong somewhere and my 'fix' below seems
                  to
                  > > > correct the issue. I don't have much experience with perl so
                  > perhaps
                  > > > there's something else amiss that is really the issue.
                  > > >
                  > > > Thanks for any help.
                  > > >
                  > > > Greg
                  > >
                  > >
                  > >
                  > > --
                  > > Kawasaki Yusuke
                  > > http://www.kawa.net/
                  > >
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.