NAME
UnixODBC::RSS.pm - Create RSS output from a UnixODBC query.
SYNOPSIS
use UnixODBC ':all';
use UnixODBC::RSS;
my $rdf = new UnixODBC::RSS;
$rdf -> Channel ({'title' => 'feed_title',
'description' => 'feed_description',
'link' => 'url'});
$rdf -> ChannelImage ('url' => 'image_url',
'title' => 'alt_title',
'description' => 'image_description');
$rdf -> TextInput ({'title' => 'resource_title',
'description' => 'resource_description',
'name' => 'resource_name',
'link' => 'resource_uri'});
$rdf -> ColumnHeadings ($array_ref);
$rdf -> Syn ({'updatePeriod' => 'hourly',
'updateFrequency' => 1,
'updateBase' => '2000-01-01T12:00+00.00'});
$rdf -> ItemColumns ({'column_name_of_title_content' => 'title',
'column_name_of_description_content' => 'description',
'column_name_of_name_content' => 'name',
'column_name_of_link_content' => 'link'});
# @resultset is an array of row references.
$rdf -> Output (\@resultset, *STDOUT);
DESCRIPTION
UnixODBC::RSS.pm formats query results as RSS RDF output.
The Channel() method's argument is an anonymous hash or hash reference that provides RSS channel identification for <channel> and member tags: <title>, <description>, and <url>.
ChannelImage() optionally provides information about an image resource. An <image><link> member content is identical to the <channel><link> member content.
The method, ItemColumns(), takes as its argument an anonymous hash or hash reference. Each key-value describes the result set column that provides content for an <item> member: <title>, <name>, <description>, or <link>.
Syn() optionally adds syndication extensions to the output. The content of "updatePeriod" may be: "hourly," "daily," "weekly," "monthly," or "yearly." The positive integer value of, "updateFrequency," is the number of, "updatePeriod," time units between updates. The content of, "updateBase," is a W3C-format date-time stamp.
ColumnHeadings() saves a query's column headings as an array reference. Refer to the example below.
The TextInput() arguments, given as a hash reference, provide the content of a <textinput> section.
Output() takes as its arguments the result set as an array reference and an output filehandle.
Creating a RSS RDF file follows approximately these steps.
# Allocate Environment, Connection, and statement handles, and connect
# to DSN....
$r = SQLPrepare ($sth, $Query, length ($Query));
$r = SQLExecute ($sth);
my $ncols;
$r = SQLNumResultCols ($sth,$ncols);
my ($col, $buf, $rfetch, $rget, $colarrayref, @rowarray, $rlen, $n);
my $colheadref = new_array_ref ();
# Get column headings
for ($col = 1; $col <= $ncols; $col++) {
$r = SQLColAttribute ($sth, $col, $SQL_COLUMN_NAME, $buf,
$SQL_MAX_MESSAGE_LENGTH, $rlen, $n);
$$colheadref[$col - 1] = $buf;
}
$rss -> ColumnHeadings ($colheadref);
# Get column data
while (1) {
$rfetch = SQLFetch ($sth);
last if $rfetch == $SQL_NO_DATA;
$colarrayref = new_array_ref ();
for ( $col = 1; $col <= $ncols; $col++) {
$rget = SQLGetData ($sth, $col, $SQL_CHAR, $buf,
$SQL_MAX_MESSAGE_LENGTH, $rlen);
$$colarrayref[$col - 1] = $buf;
}
push @rowarray, ($colarrayref);
}
$rss -> Output (\@rowarray, *STDOUT);
sub new_array_ref { my @a; return \@a; }
VERSION INFORMATION AND CREDITS
Version 0.06
Copyright © 2004, 2008 Robert Kiesling, rkies@cpan.org.
Licensed under the same terms as Perl. Refer to the file, "Artistic," for details.
BUGS
Does not perform validation and does not check for required content.
SEE ALSO
UnixODBC(3), XML::RSS(3), rssoutput(1)
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 206:
Non-ASCII character seen before =encoding in '©'. Assuming CP1252