View on
MetaCPAN
Aaron Straup Cope > XML-Filter-XML_Directory_2RSS-0.9.1 > XML::Filter::XML_Directory_2RSS

Download:
XML-Filter-XML_Directory_2RSS-0.9.1.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.9.1   Source  

NAME ^

XML::Filter::XML_Directory_2RSS - SAX2 filter for generating RSS from the output of XML::Directory::SAX

SYNOPSIS ^

  use IO::File;
  use XML::SAX::Writer;

  use XML::Directory::SAX;
  use XML::Filter::XML_Directory_2RSS;

  my $rss       = "/path/to/rss.xml";
  my $directory = "/path/to/some/directory";

 #

  my $output = IO::File->new(">$rss");
  my $writer = XML::SAX::Writer->new(Output=>$output);
  my $filter = XML::Filter::XML_Directory_2RSS->new(Handler=>$writer);

 # Various RSS meta data methods
  
  $rss->uri("http://www.foo.com/rss.xml");

  $rss->channel_data({title      => "foo",
                      link       => "http://foo.com",
                      subject    => "bar",
                      descripion => "foo is to bar as bar is to foo"});

  $rss->generator($0);

 # Set up one or more events for affecting the 
 # data describe in your RSS document

  $rss->callbacks({link => \&do_link});
  $rss->handlers({title=>MySax::Title->new(Handler=>$writer)});

 # Describe items to be explicily excluded (or included)
 # in your RSS document.

  $rss->exclude(exclude=>["RCS","CVS"],ending=>["~"]);

 # Parse parse parse

  my $directory = XML::Directory::SAX->new(Handler => $filter,
                                           detail  => 2,
                                           depth   => 1);

  $directory->order_by("a");
  $directory->parse_dir($directory);

 # 

  sub do_link { 
    my $link = shift; 
    $link =~ s!$directory!http://www.foo.com!s; 
    return $link; 
  }

DESCRIPTION ^

SAX2 filter for generating RSS from the output of XML::Directory::SAX.

NOTES ^

OBJECT METHODS ^

$pkg->encoding($enc)

Set the encoding type for your RSS document. Default is UTF-8

$pkg->uri($uri)

Set the URI for your RSS document. This is the value of the channel@rdf:about attribute.

$pkg->channel_data(\%args)

Set channel data for your RSS document.

Valid arguments are :

Proper support for RSS 1.0 modules is in the works.

$pkg->image(\%args)

Set image data for your RSS document.

Valid arguments are :

$pkg->textinput(\%args)

Set textinput data for your RSS document.

Valid arguments are :

$pkg->generator($agent)

Set generator agent data for your RSS document.

Currently this is really only used by the Syndic8 project, but it's a good idea so we'll add hooks it for.

$pkg->exclude(%args)

This method is inherited from XML::Filter::XML_Directory_Pruner. See docs for details.

$pkg->include(%args);

This method is inherited from XML::Filter::XML_Directory_Pruner. See docs for details.

$pkg->handlers(\%args)

A is a valid SAX2 thingy for assigning the title or description element of an RSS item. Thingies are like any other SAX2 thingy with a few requirements :

 # If this...

 my $writer = XML::SAX::Writer->new();
 my $rss = XML::Filter::XML_Directory_2RSS->new(Handler=>$writer);
 $rss->handler({title=>MySAX::TitleHandler->new(Handler=>$writer)});

 # Called this...

 package MySAX::TitleHandler;
 use base qw (XML::SAX::Base);
 
 sub parse_uri {
    my ($pkg,$path,$title) = @_;

    $pkg->SUPER::start_prefix_mapping({Prefix=>"me",NamespaceURI=>"..."});
    $pkg->SUPER::start_element({Name=>"me:woot"});
    $pkg->SUPER::characters({Data=>&get_title_from_file($path)});
    $pkg->SUPER::end_element({Name=>"me:woot"});
    $pkg->SUPER::end_prefix_mapping({Prefix=>"me"});
 }

 # Then the output would look like this...

 <item>
  <title>
   <me:woot xmlns:me="...">I Got My Title From the File</me:woot>
  </title>
  <link>...</link>
  <description />
 </item>

Valid arguments are :

Handlers have a higher precedence than callbacks.

$pkg->callbacks(\%args)

Register one of more callbacks for your RSS document.

Callbacks are like handlers except that they are code references instead of SAX2 thingies.

A code reference might be used to munge the link value of an item into a URI suitable for viewing in a web browser.

Valid arguments are

Callbacks have a lower precedence than handlers.

VERSION ^

0.9.1

DATE ^

May 24, 2002

AUTHOR ^

Aaron Straup Cope

TO DO ^

SEE ALSO ^

XML::Filter::XML_Directory::Pruner

XML::Directory::SAX

http://groups.yahoo.com/group/rss-dev/files/specification.html

LICENSE ^

Copyright (c) 2002, Aaron Straup Cope. All Rights Reserved.

This is free software, you may use it and distribute it under the same terms as Perl itself.

syntax highlighting: