XML::RAI::Channel - An interface to the channel elements of a RSS


XML-RAI documentation Contained in the XML-RAI distribution.

Index


Code Index:


XML-RAI documentation Contained in the XML-RAI distribution.

# Copyright (c) 2004-2009 Timothy Appnel
# http://appnel.com/
# This code is released under the Artistic License.
#
# XML::RAI::Channel - an interface to the channel elements of a RSS feed.
#

package XML::RAI::Channel;

use strict;
use XML::RAI::Object;

use vars qw(@ISA $XMap);
@ISA = qw( XML::RAI::Object );

use XML::RAI;

$XMap = {
    'format' => ['dc:format'],

    # 'link'=>['link','@rdf:about'], #special handler
    contributor => ['dc:contributor'],
    coverage    => ['dc:coverage'],
    creator     => ['dc:creator'],
    description => [
        'description',      'dc:description',
        'dcterms:abstract', 'dcterms:alternative'
    ],
    generator => [
        'admin:generatorAgent/@rdf:resource', 'admin:generatorAgent',
        'generator'
    ],
    identifier    => ['dc:identifier/@rdf:resource', 'dc:identifier', 'link'],
    issued_strict => ['dcterms:issued'],
    issued =>
      ['dcterms:issued', 'dc:date', 'lastBuildDate', 'rss091:lastBuildDate'],
    language   => ['@xml:lang', 'dc:language', 'language', 'rss091:language'],
    maintainer => [
        'admin:errorReportsTo/@rdf:resource', 'admin:errorReportsTo',
        'webMaster'
    ],
    modified_strict => ['dcterms:modified'],
    modified        => [
        'dcterms:modified', 'dc:date',
        'lastBuildDate',    'rss091:lastBuildDate',
    ],
    publisher => ['dc:publisher', 'managingEditor', 'rss091:managingEditor'],
    relation => ['dc:relation/@rdf:resource', 'dc:relation'],
    rights   => [
        'dc:rights',               'copyright',
        'creativeCommons:license', 'rss091:copyright'
    ],
    source  => ['dc:source',  'source/@url', 'source', 'title'],
    subject => ['dc:subject', 'category'],
    title   => ['title',      'dc:title'],
    type    => ['dc:type'],
    valid => ['dcterms:valid', 'expirationDate'],
};

# Class::XPath is missing some functionality we need here so we
# help it along.
sub link {
    my $this = shift;
    my @nodes;

    # awkward use, but achieves the effect we need.
    if (@nodes = $this->src->query('link')) { }
    elsif (
        @nodes = grep {
            $_->attributes->{type} =~ m!^(text/html|application/xhtml+xml)$!
        } $this->src->query('l:link[@rel="permalink"]')
      )
    {
    }
    elsif (@nodes = $this->src->query('dc:relation/@rdf:resource')) {
    }
    elsif (@nodes = $this->src->query('dc:relation')) {
    }
    return unless (defined $nodes[0]);
    my @n = map { ref($_) ? $_->text_content : $_ } @nodes;
    wantarray ? @n : $n[0];
}

1;

__END__