Author image Marco Pessotto
and 1 contributors


XML::OPDS - OPDS (Open Publication Distribution System) feed creation


Version 0.06


This module facilitates the creation of OPDS feeds.

The specifications can be found at while the validator is at

The idea is that it should be enough to pass the navigation links and the title entries with some data, and have the feed back.

The OPDS feeds are basically Atom feeds, hence this module uses XML::Atom under the hood.

Some features are not supported yet, but patches are welcome. Also keep in mind that the applications which are supposed to talk to your server have a level of support which varies from decent to "keep crashing".

This is still very much a work in progress, but it's already generating valid and usable catalogs.


  use XML::OPDS;
  my $feed = XML::OPDS->new(prefix => '');
  # add two links, self and start are mandatory.
                            rel => 'self',
                            title => 'Root',
                            href => '/',
                            rel => 'start',
                            title => 'Root',
                            href => '/',
  # add a navigation for the title list, marking as leaf, where the
  # download links can be retrieved.
                            title => 'Titles',
                            description => 'texts sorted by title',
                            href => '/titles',
                            acquisition => 1,
  # and render
  print $feed->render;
  # you can reuse the object for leaf feeds (i.e. the acquistion
  # feeds), pushing another self navigation, which will replace the
  # previous one.
                            rel => 'self',
                            title => 'Titles',
                            description => 'texts sorted by title',
                            href => '/titles',

  # or, implicitely setting the self rel and cleaning the navigation
  # stash, keeping the meta
                                      title => 'Titles',
                                      acquisition => 1,
                                      href => '/titles',
                             href => '/my/title',
                             title => 'My title',
                             files => [ '/my/title.epub' ],
  # and here we have an acquisition feed, because of the presence of
  # the acquisition.
  print $feed->render;


Even if the module wants characters as input (decoded strings, not bytes), the output XML is an UTF-8 encoded string.


Arrayref of XML::OPDS::Navigation objects. An object with a rel self (the feed itself) and one with the rel start (the root feed) are mandatory. If not present, the module will crash while rendering the feed.


Arrayref of XML::OPDS::Acquisition objects. If one or more objects are present, the feed will become an acquistion feed.


The producer of the feed. Defaults to this class name and version.


The uri of the author. Defaults to (which is the home of this class).


Default to the empty string. On instances of this class, by itself has no effect. However, when calling add_to_acquisitions and add_to_navigations, it will be passed to the constructors of those objects.

This is usually the hostname of the OPDS server. So you need just to pass, e.g. '' and have all the links prefixed by that (no slash mangling or adding is performed). If you are going to pass the full urls, leave it at the default.


Default to current timestamp. When calling create_navigation or create_acquistion, use this timestamp as default.

The feed logo. If prefix is set, prepend it.


The feed icon. If prefix is set, prepend it.



Return the generated xml.


Return the XML::Atom::Feed object.


Create a XML::OPDS::Navigation object inheriting the prefix.


Create a XML::OPDS::Acquisition object inheriting the prefix.


Call create_navigation and add it to the navigations stack.


Like add_to_navigations, but it's meant to be used for rel:self elements.

The rel:self attribute is injected in the arguments which are passed to create_navigation.

If a navigation with the attribute rel set to self was already present in the stack, the new one will become the new self, while the old one will become an up rel.

Also, this will remove any existing navigation with the rel attribute set to subsection, given that you are creating a new level.

This is designed to play well with chained actions (so you can reuse the object, stack selfs, and the result will be correct).


Call create_acquisition and add it to the acquisition stack.


Return a list of XML::OPDS::Navigation objects excluding unique relationships like self, start, up, previous, next, first, last.

Return an hashref, where the keys are the rel attributes of the navigation objects. The value is an object if the navigation is meant to be unique, or an arrayref of objects if not so.


Return true if there are acquisition objects stacked.


The following attributes can be set if you are building an Atom response for OpenSearch. See XML::OPDS::OpenSearch::Query for a concrete example.


A Data::Page object with the specification of the pages.


A string with the query for which you are serving the results.


Additional Query elements, should be an arrayref of XML::OPDS::OpenSearch::Query objects.


Marco Pessotto, <melmothx at>


Please report any bugs or feature requests to bug-xml-opds at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc XML::OPDS

You can also look for information at:


Copyright 2016 Marco Pessotto.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.