mldvx4 has asked for the wisdom of the Perl Monks concerning the following question:

If I read correctly in the manual page it is possible to add Dublin Core (DC) metadata to RSS 2.0 feeds, even via the XML::RSS module. I seem to be missing something.

#!/usr/bin/perl use XML::RSS; use strict; use warnings; my $rss = XML::RSS->new (version => '2.0'); $rss->channel(title => 'Example Corp, Inc', link => '', language => 'en', description => 'a one-stop-shop for all your Linux', ); $rss->add_item(title => "GTKeyboard 0.85", permaLink => "", description => 'blah blah', dc => { creator => 'an author', contributor => 'an editor', }, ); print $rss->as_string; exit(0);
If I run that, I get the following, without the Dublin Core. I was expecting the Dublin Core metadata elements to somehow show up.
<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:blogChannel="" > <channel> <title>Example Corp, Inc</title> <link></link> <description>the one-stop-shop for all your Linux</description> <language>en</language> <item> <title>GTKeyboard 0.85</title> <description>blah blah</description> <guid isPermaLink="true">< +/guid> </item> </channel>

I see that xmlns:dc="" is missing from the RSS element.

Perhaps I have to add the namespace

If so, how do I add it for RSS 2.0, not 1.0? The module seems to accept both legitimate DC elements as well as random stuff when making objects but does not print them.



I've also tried,

my $rss = XML::RSS->new (version => '2.0', 'xmlns:dc'=>" +", );


my $rss = XML::RSS->new (version => '2.0', namespaces => { 'xmlns:dc'=>" +dc/elements/1.1/" }, );

Neither produce any visible changes, even using Data::Dumper.

Replies are listed 'Best First'.
Re: Adding Dublin Core to RSS 2.0 via XML::RSS?
by Anonymous Monk on Sep 01, 2022 at 06:48 UTC
    Dublin core? Which version are you running XML::RSS

      Wait. I'm not sure any more since the source says one thing and the running module seems to say something else:

      $ perl -MXML::RSS -e 'print $XML::RSS::VERSION,"\n";' 1.59 $ grep -E '1.59|1.62' /usr/local/share/perl/5.34.0/XML/ $XML::RSS::VERSION = '1.62'; $VERSION = '1.59'; version 1.62

      I've deleted the existing module, reinstalled it (again) via CPAN, and double checked that there is only one instance:

      $ find /usr -type f -name '' -print 2>/dev/null /usr/share/perl5/XML/Feed/Entry/Format/ /usr/share/perl5/XML/Feed/Format/ /usr/local/share/perl/5.34.0/XML/ $ perl -e 'print join("\n",sort @INC),"\n";' /etc/perl /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.34 /usr/lib/x86_64-linux-gnu/perl5/5.34 /usr/local/lib/site_perl /usr/local/lib/x86_64-linux-gnu/perl/5.34.0 /usr/local/share/perl/5.34.0 /usr/share/perl/5.34 /usr/share/perl5

        Looking at the code, I'm fairly confident that you have v1.62, and that the claim of v1.59 is a release-process bug. I've reported this as a perl-XML-RSS issue.

      It appears to be XML::RSS version 1.62:

      $ head -n2 /usr/share/perl5/XML/ package XML::RSS; $XML::RSS::VERSION = '1.62';

      That supports RSS 2.0 and that, if I read the spec correctly, allows additional namespaces, such as Dublin Core.