<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.eprints.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DaveTarrant</id>
	<title>EPrints Documentation - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.eprints.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DaveTarrant"/>
	<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/Special:Contributions/DaveTarrant"/>
	<updated>2026-04-10T12:29:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.8</generator>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Installing_EPrints_on_Debian/Ubuntu&amp;diff=10111</id>
		<title>Installing EPrints on Debian/Ubuntu</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Installing_EPrints_on_Debian/Ubuntu&amp;diff=10111"/>
		<updated>2011-12-05T15:30:49Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Debian and Ubuntu]]&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
David Tarrant has built a Debian/Ubuntu package for Eprints.&lt;br /&gt;
&lt;br /&gt;
=APT Mirrors=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Add one of the following mirrors (2 lines) to your /etc/apt/sources.list file as the root user. Please ensure that there is only one set in the file or you may not experience the correct behaviour.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==EPrints Latest==&lt;br /&gt;
&lt;br /&gt;
To install the testing build add *one* the following to /etc/apt/sources.list:&lt;br /&gt;
&lt;br /&gt;
===Stable Builds===&lt;br /&gt;
&lt;br /&gt;
 deb http://deb.eprints.org/ stable/&lt;br /&gt;
 deb-src http://deb.eprints.org/ source/&lt;br /&gt;
&lt;br /&gt;
===Testing Builds===&lt;br /&gt;
&lt;br /&gt;
 deb http://deb.eprints.org/ unstable/&lt;br /&gt;
 deb-src http://deb.eprints.org/ source/&lt;br /&gt;
&lt;br /&gt;
===Nightly Build===&lt;br /&gt;
&lt;br /&gt;
Rather than the above add the following to /etc/apt/sources.list (note that this code is in developement and will not neccessarily compile):&lt;br /&gt;
&lt;br /&gt;
 deb http://deb.eprints.org/ nightly/&lt;br /&gt;
 deb-src http://deb.eprints.org/ source/&lt;br /&gt;
&lt;br /&gt;
==EPrints 3.X (Specific Version Locking)==&lt;br /&gt;
===Stable Release===&lt;br /&gt;
&lt;br /&gt;
Add the following to /etc/apt/sources.list:&lt;br /&gt;
&lt;br /&gt;
 deb http://deb.eprints.org/3.X/ stable/&lt;br /&gt;
 deb-src http://deb.eprints.org/3.X/ source/&lt;br /&gt;
&lt;br /&gt;
===Unstable Release===&lt;br /&gt;
&lt;br /&gt;
To install the latest '''unstable''' release add the following to /etc/apt/sources.list:&lt;br /&gt;
&lt;br /&gt;
 deb http://deb.eprints.org/3.X/ unstable/&lt;br /&gt;
 deb-src http://deb.eprints.org/3.X/ source/&lt;br /&gt;
&lt;br /&gt;
===Nightly Build===&lt;br /&gt;
&lt;br /&gt;
To install the nightly build add the following to /etc/apt/sources.list:&lt;br /&gt;
&lt;br /&gt;
 deb http://deb.eprints.org/3.X/ nightly/&lt;br /&gt;
 deb-src http://deb.eprints.org/3.X/ source/&lt;br /&gt;
&lt;br /&gt;
=Installing Eprints via apt-get=&lt;br /&gt;
&lt;br /&gt;
To install Eprints and all its dependencies execute the following (as root):&lt;br /&gt;
&lt;br /&gt;
 apt-get update&lt;br /&gt;
 apt-get install eprints&lt;br /&gt;
&lt;br /&gt;
=Setting up a Repository=&lt;br /&gt;
You should now have a working installation of eprints in /usr/share/eprints3/. Please follow the on-screen instructions to set up an eprints repository. You probably want to start with (as root):&lt;br /&gt;
&lt;br /&gt;
'''For more information about setting up an EPrints repository take a look at [[Getting Started with EPrints 3]]'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Read First: Known issues with the Debian/Ubuntu package can be found at [[Debian Known Issues]].&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 su eprints&lt;br /&gt;
 cd&lt;br /&gt;
 ./bin/epadmin create&lt;br /&gt;
 logout&lt;br /&gt;
 a2ensite eprints3&lt;br /&gt;
 apache2ctl restart&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you have any problems getting set up you can get free help and support from the EP-Tech mailing list. {{EPrintsTech}}&lt;br /&gt;
&lt;br /&gt;
=Getting and Compiling from Source (not required)=&lt;br /&gt;
&lt;br /&gt;
To install dependencies and retrieve the Eprints source execute the following:&lt;br /&gt;
&lt;br /&gt;
 apt-get update&lt;br /&gt;
 apt-get build-dep eprints&lt;br /&gt;
 apt-get source eprints&lt;br /&gt;
&lt;br /&gt;
The source will be saved to a tarball in the current directory.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Cron_Events_and_Simple_email_Reports&amp;diff=10098</id>
		<title>Cron Events and Simple email Reports</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Cron_Events_and_Simple_email_Reports&amp;diff=10098"/>
		<updated>2011-11-22T15:49:52Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Step 4: Email the report to the repository admins */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to create an Event plug-in which will run every day and produce a report of all the EPrints which have been added in the last day.&lt;br /&gt;
&lt;br /&gt;
= Step 1: Create the Event Plug-In = &lt;br /&gt;
&lt;br /&gt;
In the lib/plugins/EPrints/Plugin/Event directory create your main plugin with the following:&lt;br /&gt;
&lt;br /&gt;
  Package EPrints::Plugin::Event::EPrintsReportEx;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Event;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = qw( EPrints::Plugin::Event );&lt;br /&gt;
  &lt;br /&gt;
  sub action_send_email &lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
        &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  sub generate_content&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
        &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
= Step 2: Create your package =&lt;br /&gt;
&lt;br /&gt;
Create your package and don't forget to enable the Event Plugin according to http://wiki.eprints.org/w/My_First_Bazaar_Package&lt;br /&gt;
&lt;br /&gt;
= Step 3: Search for EPrints Added in the Last Day = &lt;br /&gt;
&lt;br /&gt;
In your event fill the generate_content routine with the following:&lt;br /&gt;
&lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
        my $xml = $repository-&amp;gt;xml;&lt;br /&gt;
  &lt;br /&gt;
        my $content = $xml-&amp;gt;create_document_fragment();&lt;br /&gt;
        my $h1 = $xml-&amp;gt;create_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
        $content-&amp;gt;appendChild($h1);&lt;br /&gt;
        $h1-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;EPrints Added in the Last Day&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        my $ds = $repository-&amp;gt;dataset( &amp;quot;eprint&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        my $date = time() - 86400; # 1 day ago&lt;br /&gt;
        $date = EPrints::Time::iso_date( $date ) . &amp;quot; 00:00:00&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_section;&lt;br /&gt;
  &lt;br /&gt;
        $ds-&amp;gt;search(&lt;br /&gt;
                custom_order =&amp;gt; &amp;quot;-datestamp&amp;quot;,&lt;br /&gt;
         )-&amp;gt;map(sub {&lt;br /&gt;
                my( undef, undef, $item ) = @_;&lt;br /&gt;
                return if(!defined $item);&lt;br /&gt;
   &lt;br /&gt;
                my $ep_date = $item-&amp;gt;get_value(&amp;quot;datestamp&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                last if($ep_date lt $date);&lt;br /&gt;
  &lt;br /&gt;
                if (!defined $eprint_section) {&lt;br /&gt;
                        $eprint_section = $xml-&amp;gt;create_document_fragment();&lt;br /&gt;
                }&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_value(&amp;quot;title&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_citation_link());&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot; (&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_value(&amp;quot;eprint_status&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;)&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($xml-&amp;gt;create_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($xml-&amp;gt;create_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        });&lt;br /&gt;
  &lt;br /&gt;
        if (defined $eprint_section) {&lt;br /&gt;
                $content-&amp;gt;appendChild($eprint_section);&lt;br /&gt;
        } else {&lt;br /&gt;
                $content-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;Nothing has happened!&amp;quot;));&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $content;&lt;br /&gt;
&lt;br /&gt;
=Step 4: Email the report to the repository admins=&lt;br /&gt;
&lt;br /&gt;
In the action_send_email sub routine, add the following code:&lt;br /&gt;
&lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $mail_body = $self-&amp;gt;generate_content();&lt;br /&gt;
  &lt;br /&gt;
        my $subject = &amp;quot;id/report_email_title&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $ds = $repository-&amp;gt;dataset( &amp;quot;user&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        $ds-&amp;gt;search(&lt;br /&gt;
                filters =&amp;gt; [&lt;br /&gt;
                        { meta_fields =&amp;gt; [qw( usertype )], value =&amp;gt; &amp;quot;admin&amp;quot; },&lt;br /&gt;
                ],&lt;br /&gt;
        )-&amp;gt;map(sub {&lt;br /&gt;
                my( undef, undef, $user ) = @_;&lt;br /&gt;
                $user-&amp;gt;mail( $subject, $mail_body,undef,undef );&lt;br /&gt;
        });&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
&lt;br /&gt;
= Step 5: Set up the crontab to email you this report =&lt;br /&gt;
&lt;br /&gt;
In order to set up the cron event we need to add some code to an EPMC screen related to this package, follow the instructions @ http://wiki.eprints.org/w/XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package on creating an EPMC screen with and enable and disable method.&lt;br /&gt;
&lt;br /&gt;
To enable cron we need to add the following to the enable method:&lt;br /&gt;
&lt;br /&gt;
        EPrints::DataObj::EventQueue-&amp;gt;create_unique( $repository, {&lt;br /&gt;
                pluginid =&amp;gt; &amp;quot;Event&amp;quot;,&lt;br /&gt;
                action =&amp;gt; &amp;quot;cron&amp;quot;,&lt;br /&gt;
                params =&amp;gt; [&amp;quot;0,15,30,45,60 * * * *&amp;quot;,&lt;br /&gt;
                        &amp;quot;Event::EPrintsReportEx&amp;quot;,&lt;br /&gt;
                        &amp;quot;action_send_email&amp;quot;,&lt;br /&gt;
                ],&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
This will send you an update email every 15 minutes, note that EPrints uses the standard cron syntax so you can change this as you will. &lt;br /&gt;
&lt;br /&gt;
A guide on using cron can be found @ http://en.wikipedia.org/wiki/Cron&lt;br /&gt;
&lt;br /&gt;
We also need to disable this event again when the package is removed, to do this add the following to the disable method:&lt;br /&gt;
&lt;br /&gt;
        my $event = EPrints::DataObj::EventQueue-&amp;gt;new_from_hash( $repository, {&lt;br /&gt;
                pluginid =&amp;gt; &amp;quot;Event&amp;quot;,&lt;br /&gt;
                action =&amp;gt; &amp;quot;cron&amp;quot;,&lt;br /&gt;
                params =&amp;gt; [&amp;quot;0,15,30,45,60 * * * *&amp;quot;,&lt;br /&gt;
                        &amp;quot;Event::EPrintsReportEx&amp;quot;,&lt;br /&gt;
                        &amp;quot;action_send_email&amp;quot;,&lt;br /&gt;
                ],&lt;br /&gt;
        });&lt;br /&gt;
        $event-&amp;gt;delete if (defined $event);&lt;br /&gt;
&lt;br /&gt;
Note that the 2 events and cron syntax's MUST match.&lt;br /&gt;
&lt;br /&gt;
= Step 6 - Package Test and Wait for Email =&lt;br /&gt;
&lt;br /&gt;
Finish up, package and enable your code. Note that we have not defined any nice phrases here that will be needed to make a proper package.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Cron_Events_and_Simple_email_Reports&amp;diff=9937</id>
		<title>Cron Events and Simple email Reports</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Cron_Events_and_Simple_email_Reports&amp;diff=9937"/>
		<updated>2011-08-05T11:53:13Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Step 4: Email the report to the repository admins */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to create an Event plug-in which will run every day and produce a report of all the EPrints which have been added in the last day.&lt;br /&gt;
&lt;br /&gt;
= Step 1: Create the Event Plug-In = &lt;br /&gt;
&lt;br /&gt;
In the lib/plugins/EPrints/Plugin/Event directory create your main plugin with the following:&lt;br /&gt;
&lt;br /&gt;
  Package EPrints::Plugin::Event::EPrintsReportEx;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Event;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = qw( EPrints::Plugin::Event );&lt;br /&gt;
  &lt;br /&gt;
  sub action_send_email &lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
        &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  sub generate_content&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
        &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
= Step 2: Create your package =&lt;br /&gt;
&lt;br /&gt;
Create your package and don't forget to enable the Event Plugin according to http://wiki.eprints.org/w/My_First_Bazaar_Package&lt;br /&gt;
&lt;br /&gt;
= Step 3: Search for EPrints Added in the Last Day = &lt;br /&gt;
&lt;br /&gt;
In your event fill the generate_content routine with the following:&lt;br /&gt;
&lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
        my $xml = $repository-&amp;gt;xml;&lt;br /&gt;
  &lt;br /&gt;
        my $content = $xml-&amp;gt;create_document_fragment();&lt;br /&gt;
        my $h1 = $xml-&amp;gt;create_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
        $content-&amp;gt;appendChild($h1);&lt;br /&gt;
        $h1-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;EPrints Added in the Last Day&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        my $ds = $repository-&amp;gt;dataset( &amp;quot;eprint&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        my $date = time() - 86400; # 1 day ago&lt;br /&gt;
        $date = EPrints::Time::iso_date( $date ) . &amp;quot; 00:00:00&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_section;&lt;br /&gt;
  &lt;br /&gt;
        $ds-&amp;gt;search(&lt;br /&gt;
                custom_order =&amp;gt; &amp;quot;-datestamp&amp;quot;,&lt;br /&gt;
         )-&amp;gt;map(sub {&lt;br /&gt;
                my( undef, undef, $item ) = @_;&lt;br /&gt;
                return if(!defined $item);&lt;br /&gt;
   &lt;br /&gt;
                my $ep_date = $item-&amp;gt;get_value(&amp;quot;datestamp&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                last if($ep_date lt $date);&lt;br /&gt;
  &lt;br /&gt;
                if (!defined $eprint_section) {&lt;br /&gt;
                        $eprint_section = $xml-&amp;gt;create_document_fragment();&lt;br /&gt;
                }&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_value(&amp;quot;title&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_citation_link());&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot; (&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_value(&amp;quot;eprint_status&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;)&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($xml-&amp;gt;create_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($xml-&amp;gt;create_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        });&lt;br /&gt;
  &lt;br /&gt;
        if (defined $eprint_section) {&lt;br /&gt;
                $content-&amp;gt;appendChild($eprint_section);&lt;br /&gt;
        } else {&lt;br /&gt;
                $content-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;Nothing has happened!&amp;quot;));&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $content;&lt;br /&gt;
&lt;br /&gt;
=Step 4: Email the report to the repository admins=&lt;br /&gt;
&lt;br /&gt;
In the action_send_email sub routine, add the following code:&lt;br /&gt;
&lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $receiver = $repository-&amp;gt;user(7);&lt;br /&gt;
        return unless( defined $receiver );&lt;br /&gt;
  &lt;br /&gt;
        my $mail_body = $self-&amp;gt;generate_content();&lt;br /&gt;
  &lt;br /&gt;
        my $subject = &amp;quot;id/report_email_title&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $ds = $repository-&amp;gt;dataset( &amp;quot;user&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        $ds-&amp;gt;search(&lt;br /&gt;
                filters =&amp;gt; [&lt;br /&gt;
                        { meta_fields =&amp;gt; [qw( usertype )], value =&amp;gt; &amp;quot;admin&amp;quot; },&lt;br /&gt;
                ],&lt;br /&gt;
        )-&amp;gt;map(sub {&lt;br /&gt;
                my( undef, undef, $user ) = @_;&lt;br /&gt;
                $user-&amp;gt;mail( $subject, $mail_body,undef,undef );&lt;br /&gt;
        });&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
&lt;br /&gt;
= Step 5: Set up the crontab to email you this report =&lt;br /&gt;
&lt;br /&gt;
In order to set up the cron event we need to add some code to an EPMC screen related to this package, follow the instructions @ http://wiki.eprints.org/w/XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package on creating an EPMC screen with and enable and disable method.&lt;br /&gt;
&lt;br /&gt;
To enable cron we need to add the following to the enable method:&lt;br /&gt;
&lt;br /&gt;
        EPrints::DataObj::EventQueue-&amp;gt;create_unique( $repository, {&lt;br /&gt;
                pluginid =&amp;gt; &amp;quot;Event&amp;quot;,&lt;br /&gt;
                action =&amp;gt; &amp;quot;cron&amp;quot;,&lt;br /&gt;
                params =&amp;gt; [&amp;quot;0,15,30,45,60 * * * *&amp;quot;,&lt;br /&gt;
                        &amp;quot;Event::EPrintsReportEx&amp;quot;,&lt;br /&gt;
                        &amp;quot;action_send_email&amp;quot;,&lt;br /&gt;
                ],&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
This will send you an update email every 15 minutes, note that EPrints uses the standard cron syntax so you can change this as you will. &lt;br /&gt;
&lt;br /&gt;
A guide on using cron can be found @ http://en.wikipedia.org/wiki/Cron&lt;br /&gt;
&lt;br /&gt;
We also need to disable this event again when the package is removed, to do this add the following to the disable method:&lt;br /&gt;
&lt;br /&gt;
        my $event = EPrints::DataObj::EventQueue-&amp;gt;new_from_hash( $repository, {&lt;br /&gt;
                pluginid =&amp;gt; &amp;quot;Event&amp;quot;,&lt;br /&gt;
                action =&amp;gt; &amp;quot;cron&amp;quot;,&lt;br /&gt;
                params =&amp;gt; [&amp;quot;0,15,30,45,60 * * * *&amp;quot;,&lt;br /&gt;
                        &amp;quot;Event::EPrintsReportEx&amp;quot;,&lt;br /&gt;
                        &amp;quot;action_send_email&amp;quot;,&lt;br /&gt;
                ],&lt;br /&gt;
        });&lt;br /&gt;
        $event-&amp;gt;delete if (defined $event);&lt;br /&gt;
&lt;br /&gt;
Note that the 2 events and cron syntax's MUST match.&lt;br /&gt;
&lt;br /&gt;
= Step 6 - Package Test and Wait for Email =&lt;br /&gt;
&lt;br /&gt;
Finish up, package and enable your code. Note that we have not defined any nice phrases here that will be needed to make a proper package.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Cron_Events_and_Simple_email_Reports&amp;diff=9936</id>
		<title>Cron Events and Simple email Reports</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Cron_Events_and_Simple_email_Reports&amp;diff=9936"/>
		<updated>2011-08-05T11:52:59Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to create an Event plug-in which will run every day and produce a report of all the EPrints which have been added in the last day.&lt;br /&gt;
&lt;br /&gt;
= Step 1: Create the Event Plug-In = &lt;br /&gt;
&lt;br /&gt;
In the lib/plugins/EPrints/Plugin/Event directory create your main plugin with the following:&lt;br /&gt;
&lt;br /&gt;
  Package EPrints::Plugin::Event::EPrintsReportEx;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Event;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = qw( EPrints::Plugin::Event );&lt;br /&gt;
  &lt;br /&gt;
  sub action_send_email &lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
        &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  sub generate_content&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
        &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
= Step 2: Create your package =&lt;br /&gt;
&lt;br /&gt;
Create your package and don't forget to enable the Event Plugin according to http://wiki.eprints.org/w/My_First_Bazaar_Package&lt;br /&gt;
&lt;br /&gt;
= Step 3: Search for EPrints Added in the Last Day = &lt;br /&gt;
&lt;br /&gt;
In your event fill the generate_content routine with the following:&lt;br /&gt;
&lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
        my $xml = $repository-&amp;gt;xml;&lt;br /&gt;
  &lt;br /&gt;
        my $content = $xml-&amp;gt;create_document_fragment();&lt;br /&gt;
        my $h1 = $xml-&amp;gt;create_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
        $content-&amp;gt;appendChild($h1);&lt;br /&gt;
        $h1-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;EPrints Added in the Last Day&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        my $ds = $repository-&amp;gt;dataset( &amp;quot;eprint&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        my $date = time() - 86400; # 1 day ago&lt;br /&gt;
        $date = EPrints::Time::iso_date( $date ) . &amp;quot; 00:00:00&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_section;&lt;br /&gt;
  &lt;br /&gt;
        $ds-&amp;gt;search(&lt;br /&gt;
                custom_order =&amp;gt; &amp;quot;-datestamp&amp;quot;,&lt;br /&gt;
         )-&amp;gt;map(sub {&lt;br /&gt;
                my( undef, undef, $item ) = @_;&lt;br /&gt;
                return if(!defined $item);&lt;br /&gt;
   &lt;br /&gt;
                my $ep_date = $item-&amp;gt;get_value(&amp;quot;datestamp&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                last if($ep_date lt $date);&lt;br /&gt;
  &lt;br /&gt;
                if (!defined $eprint_section) {&lt;br /&gt;
                        $eprint_section = $xml-&amp;gt;create_document_fragment();&lt;br /&gt;
                }&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_value(&amp;quot;title&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_citation_link());&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot; (&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_value(&amp;quot;eprint_status&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;)&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($xml-&amp;gt;create_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($xml-&amp;gt;create_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        });&lt;br /&gt;
  &lt;br /&gt;
        if (defined $eprint_section) {&lt;br /&gt;
                $content-&amp;gt;appendChild($eprint_section);&lt;br /&gt;
        } else {&lt;br /&gt;
                $content-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;Nothing has happened!&amp;quot;));&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $content;&lt;br /&gt;
&lt;br /&gt;
=Step 4: Email the report to the repository admins=&lt;br /&gt;
&lt;br /&gt;
In the action_send_email sub routine, add the following code:&lt;br /&gt;
&lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $receiver = $repository-&amp;gt;user(7);&lt;br /&gt;
        return unless( defined $receiver );&lt;br /&gt;
  &lt;br /&gt;
        my $mail_body = $self-&amp;gt;generate_content();&lt;br /&gt;
  &lt;br /&gt;
        my $subject = &amp;quot;id/report_email_title&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $ds = $repository-&amp;gt;dataset( &amp;quot;user&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        $ds-&amp;gt;search(&lt;br /&gt;
                filters =&amp;gt; [&lt;br /&gt;
                        { meta_fields =&amp;gt; [qw( usertype )], value =&amp;gt; &amp;quot;admin&amp;quot; },&lt;br /&gt;
                ],&lt;br /&gt;
        )-&amp;gt;map(sub {&lt;br /&gt;
                my( undef, undef, $user ) = @_;&lt;br /&gt;
                $user-&amp;gt;mail( $subject, $mail_body,undef,undef );&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  &lt;br /&gt;
= Step 5: Set up the crontab to email you this report =&lt;br /&gt;
&lt;br /&gt;
In order to set up the cron event we need to add some code to an EPMC screen related to this package, follow the instructions @ http://wiki.eprints.org/w/XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package on creating an EPMC screen with and enable and disable method.&lt;br /&gt;
&lt;br /&gt;
To enable cron we need to add the following to the enable method:&lt;br /&gt;
&lt;br /&gt;
        EPrints::DataObj::EventQueue-&amp;gt;create_unique( $repository, {&lt;br /&gt;
                pluginid =&amp;gt; &amp;quot;Event&amp;quot;,&lt;br /&gt;
                action =&amp;gt; &amp;quot;cron&amp;quot;,&lt;br /&gt;
                params =&amp;gt; [&amp;quot;0,15,30,45,60 * * * *&amp;quot;,&lt;br /&gt;
                        &amp;quot;Event::EPrintsReportEx&amp;quot;,&lt;br /&gt;
                        &amp;quot;action_send_email&amp;quot;,&lt;br /&gt;
                ],&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
This will send you an update email every 15 minutes, note that EPrints uses the standard cron syntax so you can change this as you will. &lt;br /&gt;
&lt;br /&gt;
A guide on using cron can be found @ http://en.wikipedia.org/wiki/Cron&lt;br /&gt;
&lt;br /&gt;
We also need to disable this event again when the package is removed, to do this add the following to the disable method:&lt;br /&gt;
&lt;br /&gt;
        my $event = EPrints::DataObj::EventQueue-&amp;gt;new_from_hash( $repository, {&lt;br /&gt;
                pluginid =&amp;gt; &amp;quot;Event&amp;quot;,&lt;br /&gt;
                action =&amp;gt; &amp;quot;cron&amp;quot;,&lt;br /&gt;
                params =&amp;gt; [&amp;quot;0,15,30,45,60 * * * *&amp;quot;,&lt;br /&gt;
                        &amp;quot;Event::EPrintsReportEx&amp;quot;,&lt;br /&gt;
                        &amp;quot;action_send_email&amp;quot;,&lt;br /&gt;
                ],&lt;br /&gt;
        });&lt;br /&gt;
        $event-&amp;gt;delete if (defined $event);&lt;br /&gt;
&lt;br /&gt;
Note that the 2 events and cron syntax's MUST match.&lt;br /&gt;
&lt;br /&gt;
= Step 6 - Package Test and Wait for Email =&lt;br /&gt;
&lt;br /&gt;
Finish up, package and enable your code. Note that we have not defined any nice phrases here that will be needed to make a proper package.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Cron_Events_and_Simple_email_Reports&amp;diff=9935</id>
		<title>Cron Events and Simple email Reports</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Cron_Events_and_Simple_email_Reports&amp;diff=9935"/>
		<updated>2011-08-05T11:52:37Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to create an Event plug-in which will run every day and produce a report of all the EPrints which have been added in the last day.&lt;br /&gt;
&lt;br /&gt;
= Step 1: Create the Event Plug-In = &lt;br /&gt;
&lt;br /&gt;
In the lib/plugins/EPrints/Plugin/Event directory create your main plugin with the following:&lt;br /&gt;
&lt;br /&gt;
  Package EPrints::Plugin::Event::EPrintsReportEx;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Event;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = qw( EPrints::Plugin::Event );&lt;br /&gt;
  &lt;br /&gt;
  sub action_send_email &lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
        &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  sub generate_content&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
        &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
1;&lt;br /&gt;
&lt;br /&gt;
= Step 2: Create your package =&lt;br /&gt;
&lt;br /&gt;
Create your package and don't forget to enable the Event Plugin according to http://wiki.eprints.org/w/My_First_Bazaar_Package&lt;br /&gt;
&lt;br /&gt;
= Step 3: Search for EPrints Added in the Last Day = &lt;br /&gt;
&lt;br /&gt;
In your event fill the generate_content routine with the following:&lt;br /&gt;
&lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
        my $xml = $repository-&amp;gt;xml;&lt;br /&gt;
  &lt;br /&gt;
        my $content = $xml-&amp;gt;create_document_fragment();&lt;br /&gt;
        my $h1 = $xml-&amp;gt;create_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
        $content-&amp;gt;appendChild($h1);&lt;br /&gt;
        $h1-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;EPrints Added in the Last Day&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        my $ds = $repository-&amp;gt;dataset( &amp;quot;eprint&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        my $date = time() - 86400; # 1 day ago&lt;br /&gt;
        $date = EPrints::Time::iso_date( $date ) . &amp;quot; 00:00:00&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_section;&lt;br /&gt;
  &lt;br /&gt;
        $ds-&amp;gt;search(&lt;br /&gt;
                custom_order =&amp;gt; &amp;quot;-datestamp&amp;quot;,&lt;br /&gt;
         )-&amp;gt;map(sub {&lt;br /&gt;
                my( undef, undef, $item ) = @_;&lt;br /&gt;
                return if(!defined $item);&lt;br /&gt;
   &lt;br /&gt;
                my $ep_date = $item-&amp;gt;get_value(&amp;quot;datestamp&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                last if($ep_date lt $date);&lt;br /&gt;
  &lt;br /&gt;
                if (!defined $eprint_section) {&lt;br /&gt;
                        $eprint_section = $xml-&amp;gt;create_document_fragment();&lt;br /&gt;
                }&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_value(&amp;quot;title&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_citation_link());&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot; (&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($item-&amp;gt;render_value(&amp;quot;eprint_status&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;)&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($xml-&amp;gt;create_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
                $eprint_section-&amp;gt;appendChild($xml-&amp;gt;create_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
  &lt;br /&gt;
        if (defined $eprint_section) {&lt;br /&gt;
                $content-&amp;gt;appendChild($eprint_section);&lt;br /&gt;
        } else {&lt;br /&gt;
                $content-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;Nothing has happened!&amp;quot;));&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $content;&lt;br /&gt;
&lt;br /&gt;
=Step 4: Email the report to the repository admins=&lt;br /&gt;
&lt;br /&gt;
In the action_send_email sub routine, add the following code:&lt;br /&gt;
&lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $receiver = $repository-&amp;gt;user(7);&lt;br /&gt;
        return unless( defined $receiver );&lt;br /&gt;
  &lt;br /&gt;
        my $mail_body = $self-&amp;gt;generate_content();&lt;br /&gt;
  &lt;br /&gt;
        my $subject = &amp;quot;id/report_email_title&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $ds = $repository-&amp;gt;dataset( &amp;quot;user&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        $ds-&amp;gt;search(&lt;br /&gt;
                filters =&amp;gt; [&lt;br /&gt;
                        { meta_fields =&amp;gt; [qw( usertype )], value =&amp;gt; &amp;quot;admin&amp;quot; },&lt;br /&gt;
                ],&lt;br /&gt;
        )-&amp;gt;map(sub {&lt;br /&gt;
                my( undef, undef, $user ) = @_;&lt;br /&gt;
                $user-&amp;gt;mail( $subject, $mail_body,undef,undef );&lt;br /&gt;
&lt;br /&gt;
        });&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  &lt;br /&gt;
= Step 5: Set up the crontab to email you this report =&lt;br /&gt;
&lt;br /&gt;
In order to set up the cron event we need to add some code to an EPMC screen related to this package, follow the instructions @ http://wiki.eprints.org/w/XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package on creating an EPMC screen with and enable and disable method.&lt;br /&gt;
&lt;br /&gt;
To enable cron we need to add the following to the enable method:&lt;br /&gt;
&lt;br /&gt;
        EPrints::DataObj::EventQueue-&amp;gt;create_unique( $repository, {&lt;br /&gt;
                pluginid =&amp;gt; &amp;quot;Event&amp;quot;,&lt;br /&gt;
                action =&amp;gt; &amp;quot;cron&amp;quot;,&lt;br /&gt;
                params =&amp;gt; [&amp;quot;0,15,30,45,60 * * * *&amp;quot;,&lt;br /&gt;
                        &amp;quot;Event::EPrintsReportEx&amp;quot;,&lt;br /&gt;
                        &amp;quot;action_send_email&amp;quot;,&lt;br /&gt;
                ],&lt;br /&gt;
        });&lt;br /&gt;
&lt;br /&gt;
This will send you an update email every 15 minutes, note that EPrints uses the standard cron syntax so you can change this as you will. &lt;br /&gt;
&lt;br /&gt;
A guide on using cron can be found @ http://en.wikipedia.org/wiki/Cron&lt;br /&gt;
&lt;br /&gt;
We also need to disable this event again when the package is removed, to do this add the following to the disable method:&lt;br /&gt;
&lt;br /&gt;
        my $event = EPrints::DataObj::EventQueue-&amp;gt;new_from_hash( $repository, {&lt;br /&gt;
                pluginid =&amp;gt; &amp;quot;Event&amp;quot;,&lt;br /&gt;
                action =&amp;gt; &amp;quot;cron&amp;quot;,&lt;br /&gt;
                params =&amp;gt; [&amp;quot;0,15,30,45,60 * * * *&amp;quot;,&lt;br /&gt;
                        &amp;quot;Event::EPrintsReportEx&amp;quot;,&lt;br /&gt;
                        &amp;quot;action_send_email&amp;quot;,&lt;br /&gt;
                ],&lt;br /&gt;
        });&lt;br /&gt;
        $event-&amp;gt;delete if (defined $event);&lt;br /&gt;
&lt;br /&gt;
Note that the 2 events and cron syntax's MUST match.&lt;br /&gt;
&lt;br /&gt;
= Step 6 - Package Test and Wait for Email =&lt;br /&gt;
&lt;br /&gt;
Finish up, package and enable your code. Note that we have not defined any nice phrases here that will be needed to make a proper package.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Cron_Events_and_Simple_email_Reports&amp;diff=9932</id>
		<title>Cron Events and Simple email Reports</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Cron_Events_and_Simple_email_Reports&amp;diff=9932"/>
		<updated>2011-08-03T09:46:06Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: Place Holder&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
Coming Soon...&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Upgrading_3.2_to_3.3&amp;diff=9926</id>
		<title>Upgrading 3.2 to 3.3</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Upgrading_3.2_to_3.3&amp;diff=9926"/>
		<updated>2011-07-26T10:25:06Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: Created page with '=Install Procedure =  1) Install the additional perl libraries (see below) unless you are installing via the debian/ubuntu package manager.   2) Install EPrints 3.3  3) Run epadm…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Install Procedure =&lt;br /&gt;
&lt;br /&gt;
1) Install the additional perl libraries (see below) unless you are installing via the debian/ubuntu package manager. &lt;br /&gt;
&lt;br /&gt;
2) Install EPrints 3.3&lt;br /&gt;
&lt;br /&gt;
3) Run epadmin upgrade on your archives&lt;br /&gt;
&lt;br /&gt;
4) Update config files (see below)&lt;br /&gt;
&lt;br /&gt;
=Additional Perl Libraries=&lt;br /&gt;
&lt;br /&gt;
In order to improve search, we have decided to make use of external search libraries within EPrints. The easiest one to use and install is the Xapian search library with is available as a CPAN module. This is automatically installed on Debian/Ubuntu systems with EPrints 3.3. Other installs may require this to be installed manually along with the other libraries listed in the additional libraries section below:&lt;br /&gt;
&lt;br /&gt;
It is highly recommended that the following pre-requisites be installed to enable full functionality in EPrints 3.3. These are all installed automatically on debian/ubuntu platforms.&lt;br /&gt;
&lt;br /&gt;
* libmime-types-perl (MIME::Types)&lt;br /&gt;
* libxml-libxslt-perl (XML::XSLT)&lt;br /&gt;
* libdigest-sha-perl (DIGEST::SHA)&lt;br /&gt;
* libarchive-any-perl ~(Archive::Zip &amp;amp;&amp;amp; Archive::Tar)&lt;br /&gt;
* libsearch-xapian-perl (Search::Xapian)&lt;br /&gt;
* unzip (system tool)&lt;br /&gt;
&lt;br /&gt;
=Update Config (Optional)=&lt;br /&gt;
&lt;br /&gt;
Many installs will have changed their templates so IGNORE this stage. However if you want to revert to the new default templates then please follow the instructions below:&lt;br /&gt;
&lt;br /&gt;
1) Delete the archives built in template directories e.g. &lt;br /&gt;
   $ rm -fR archive_name/lib/lang/en/templates&lt;br /&gt;
&lt;br /&gt;
2) Update the branding config file&lt;br /&gt;
   $ cp lib/defaultcfg/cfg.d/branding.pl archive_name/cfg/cfg.d&lt;br /&gt;
&lt;br /&gt;
3) Restart Apache web server&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Dataset_Manipulation,_Triggers_and_Events&amp;diff=9925</id>
		<title>Dataset Manipulation, Triggers and Events</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Dataset_Manipulation,_Triggers_and_Events&amp;diff=9925"/>
		<updated>2011-07-21T13:09:20Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Adding New Datasets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
In this exercise, we are going to look at a lot of capabilities of EPrints combined in one exercise. &lt;br /&gt;
&lt;br /&gt;
The overall aim is to add a '''Trigger''' which queues an '''Event''' on the indexer to scan a file for it's mime type (according to the unix file command) and update this data in the file '''dataset'''&lt;br /&gt;
&lt;br /&gt;
We shall also add a new '''dataset''' although we won't specifically be using it. &lt;br /&gt;
&lt;br /&gt;
=Adding To Datasets=&lt;br /&gt;
&lt;br /&gt;
This is done with a config file under cfg/cfg.d/ which we can call package_name.pl for example. &lt;br /&gt;
&lt;br /&gt;
The following shows an example of adding the file_cmd_mime to the file dataset.&lt;br /&gt;
&lt;br /&gt;
  $c-&amp;gt;add_dataset_field( &amp;quot;file&amp;quot;, {&lt;br /&gt;
        name =&amp;gt; &amp;quot;file_cmd_mime&amp;quot;,&lt;br /&gt;
        type =&amp;gt; &amp;quot;text&amp;quot;,&lt;br /&gt;
  }, reuse =&amp;gt; 1 );&lt;br /&gt;
&lt;br /&gt;
Note that we can specify the reuse flag to say if we can reuse this field if it already exists. If this is set to 0 (or not defined) and the field already exists the package install will fail. &lt;br /&gt;
&lt;br /&gt;
Note also that if none of the config files define the field, then it is assumed it no longer required and it is removed (data included). Some investigation is need to see if upgrades work... (:S)&lt;br /&gt;
&lt;br /&gt;
=Adding New Datasets=&lt;br /&gt;
&lt;br /&gt;
Adding new datasets is much the same as adding to an existing one other than the fact we need to define the dataset and the basic class wrappers.&lt;br /&gt;
&lt;br /&gt;
  # Enable the event&lt;br /&gt;
  $c-&amp;gt;{plugins}{&amp;quot;Event::ScanFile&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
  &lt;br /&gt;
  # Define the dataset&lt;br /&gt;
  $c-&amp;gt;{datasets}-&amp;gt;{package_dataset} = {&lt;br /&gt;
       class =&amp;gt; &amp;quot;EPrints::DataObj::PackageDataset&amp;quot;,&lt;br /&gt;
       sqlname =&amp;gt; &amp;quot;package_dataset&amp;quot;,&lt;br /&gt;
       datestamp =&amp;gt; &amp;quot;datestamp&amp;quot;,       &lt;br /&gt;
       sql_counter =&amp;gt; &amp;quot;datasetid&amp;quot;,&lt;br /&gt;
  };&lt;br /&gt;
  &lt;br /&gt;
  # Add fields to the dataset&lt;br /&gt;
  $c-&amp;gt;add_dataset_field( &amp;quot;package_dataset&amp;quot;, { name=&amp;gt;&amp;quot;datasetid&amp;quot;, type=&amp;gt;&amp;quot;counter&amp;quot;, required=&amp;gt;1, can_clone=&amp;gt;0, sql_counter=&amp;gt;&amp;quot;datasetid&amp;quot; }, );&lt;br /&gt;
  $c-&amp;gt;add_dataset_field( &amp;quot;package_dataset&amp;quot;, { name=&amp;gt;&amp;quot;name&amp;quot;, type=&amp;gt;&amp;quot;text&amp;quot;, required=&amp;gt;0, }, );&lt;br /&gt;
  $c-&amp;gt;add_dataset_field( &amp;quot;package_dataset&amp;quot;, { name=&amp;gt;&amp;quot;count&amp;quot;, type=&amp;gt;&amp;quot;int&amp;quot;, required=&amp;gt;0, }, );&lt;br /&gt;
  &lt;br /&gt;
  # Define the class, this can either be done using a new file in the right place, or by using this override trick, open a '{' and then continue as it this is new file&lt;br /&gt;
  {&lt;br /&gt;
    package EPrints::DataObj::PackageDataset;&lt;br /&gt;
  &lt;br /&gt;
    our @ISA = qw( EPrints::DataObj );&lt;br /&gt;
    &lt;br /&gt;
    # The new method can simply return the constructor of the super class (Dataset)&lt;br /&gt;
    sub new&lt;br /&gt;
    {&lt;br /&gt;
        return shift-&amp;gt;SUPER::new( @_ );&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    # This method is required to just return the dataset_id.&lt;br /&gt;
    sub get_dataset_id&lt;br /&gt;
    {&lt;br /&gt;
        my ($self) = @_;&lt;br /&gt;
        return &amp;quot;package_dataset&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Events=&lt;br /&gt;
&lt;br /&gt;
Events are things which can be triggered by the indexer at various times. Because we don't want to have to wait for out mime type scan to complete and are not bothered when it completes we may as well make an event which can run at a convienient time. &lt;br /&gt;
&lt;br /&gt;
Other examples of events are:&lt;br /&gt;
&lt;br /&gt;
* Thumbnail Generation&lt;br /&gt;
* Full text indexing&lt;br /&gt;
* RDF generation&lt;br /&gt;
&lt;br /&gt;
These are all things which can be queued up so as not to slow the deposit process. &lt;br /&gt;
&lt;br /&gt;
The last thing to note about events is that the indexer obeys the eprint edit-lock, so if someone has the resource locked, the events won't happen yet. &lt;br /&gt;
&lt;br /&gt;
The indexer trys to execute queued events every 30 seconds and you can view the status of events and the indexer via the &amp;quot;status&amp;quot; button under the &amp;quot;System Tools&amp;quot; tab of the admin interface.&lt;br /&gt;
&lt;br /&gt;
==ScanFile event==&lt;br /&gt;
&lt;br /&gt;
An Event is just another type of plug-in thus you create it in a the archives cfg/plugins/EPrints/Plugin/Event/ folder. &lt;br /&gt;
&lt;br /&gt;
Below is an event with a single sub which performs the needed operation, all this needs to be parsed is a file_id. &lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Event::ScanFile;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = qw( EPrints::Plugin::Event );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub scanfile&lt;br /&gt;
  {&lt;br /&gt;
        my( $self, $file_id ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $file = new EPrints::DataObj::File( $repository, $file_id );&lt;br /&gt;
  &lt;br /&gt;
        my $src_path = $file-&amp;gt;get_local_copy;&lt;br /&gt;
  &lt;br /&gt;
        my $cmd = &amp;quot;file -i $src_path | awk '{split (\$0, a, \&amp;quot; \&amp;quot;); print a[2]}'&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $ret = `$cmd`;&lt;br /&gt;
  &lt;br /&gt;
        $ret =~ s/\r?\n//;&lt;br /&gt;
  &lt;br /&gt;
        if (defined $ret and (!($ret eq &amp;quot;&amp;quot;))) {&lt;br /&gt;
                $file-&amp;gt;set_value(&amp;quot;file_cmd_mime&amp;quot;, $ret);&lt;br /&gt;
                $file-&amp;gt;commit();&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Triggers= &lt;br /&gt;
&lt;br /&gt;
Triggers in EPrints and like message queues, you register a function which is called when a trigger point is hit.&lt;br /&gt;
&lt;br /&gt;
There are lots of triggers in EPrints which are defined in the EPrints/Const.pm file however not all of them have trigger points at the time of writing. &lt;br /&gt;
&lt;br /&gt;
Ideally we would want to use the EP_TRIGGER_FILES_MODIFIED as our trigger, however this is one of the ones which currently has no trigger point. So instead we are going to register our code against the EP_TRIGGER_AFTER_COMMIT on the '''file''' dataset only.&lt;br /&gt;
&lt;br /&gt;
There are two types of trigger:&lt;br /&gt;
&lt;br /&gt;
* Repository Triggers: General purpose triggers which should always be called with the same params and types. &lt;br /&gt;
* Dataset Triggers: Similar to repository triggers except they operate on a single dataset which changes depending on the trigger point.&lt;br /&gt;
&lt;br /&gt;
We are thus going to register our trigger against the '''file''' dataset using a dataset trigger. &lt;br /&gt;
&lt;br /&gt;
==Our Dataset Trigger==&lt;br /&gt;
&lt;br /&gt;
Triggers are registered in the repository config on load, thus the code can sit in our config file under cfg/cfg.d/. &lt;br /&gt;
&lt;br /&gt;
Don't forget to reload the config to load the trigger. &lt;br /&gt;
&lt;br /&gt;
  $c-&amp;gt;add_dataset_trigger( &amp;quot;file&amp;quot;, EP_TRIGGER_AFTER_COMMIT , sub {&lt;br /&gt;
        my ( %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = %params-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        return undef if (!defined $repository);&lt;br /&gt;
  &lt;br /&gt;
        if (defined %params-&amp;gt;{dataobj}) {&lt;br /&gt;
                my $file = %params-&amp;gt;{dataobj};&lt;br /&gt;
                my $file_id = $file-&amp;gt;value(&amp;quot;fileid&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                $repository-&amp;gt;dataset( &amp;quot;event_queue&amp;quot; )-&amp;gt;create_dataobj({&lt;br /&gt;
                        pluginid =&amp;gt; &amp;quot;Event::ScanFile&amp;quot;,&lt;br /&gt;
                        action =&amp;gt; &amp;quot;scanfile&amp;quot;,&lt;br /&gt;
                        params =&amp;gt; [$file_id],&lt;br /&gt;
                });&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=Finish and test=&lt;br /&gt;
&lt;br /&gt;
Once again we can package up these files and package install them, beware of testing the dataset stuff on the database and leaving the fields there after you remove you file for packaging.&lt;br /&gt;
&lt;br /&gt;
To test this is all working we can look in the indexer status to ensure the event it getting queued and not failing, hopefully on this page you won't see anything. &lt;br /&gt;
&lt;br /&gt;
To see the resultant values which are written to the dataset you will need to either print them back out in the file citation, or hack your way into the mysql database for your repository and see if it is putting the values in the file table.&lt;br /&gt;
&lt;br /&gt;
  select fileid,filename,file_cmd_mime from file where datasetid=&amp;quot;document&amp;quot; order by fileid desc limit 10;&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_Abstract_page_using_a_Bazaar_Module&amp;diff=9924</id>
		<title>XML manipulation of the Abstract page using a Bazaar Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_Abstract_page_using_a_Bazaar_Module&amp;diff=9924"/>
		<updated>2011-07-21T13:01:26Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
Before you can carry out the work outlined on this page you will need to prepare your package by following the steps on the [[XML manipulation of the EPrints Workflow using a Bazaar Package]] page up until the start of Exercise 1.&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to manipulate the abstract page by changing the citation XML which is displayed on various parts of the rendered abstract page.&lt;br /&gt;
&lt;br /&gt;
=Pre-Requisits=&lt;br /&gt;
&lt;br /&gt;
To do this exercise you will need:&lt;br /&gt;
&lt;br /&gt;
* A live EPrint record of type article. Training repositories should come set up with the test data. &lt;br /&gt;
* A rights field added to the EPrints workflow and filled in for this eprint.&lt;br /&gt;
&lt;br /&gt;
To add the rights field is simply a replication of the [[XML manipulation of the EPrints Workflow using a Bazaar Package]] exercise, with the following code block to manipulate the workflow needing to be added to '''enable''':&lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  my $string = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;core&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;epc:if test=&amp;quot;type = 'article'&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;field ref=&amp;quot;copyright_holders&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/epc:if&amp;gt;&lt;br /&gt;
        &amp;lt;/component&amp;gt;&lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
  &amp;lt;/workflow&amp;gt;&lt;br /&gt;
  ';&lt;br /&gt;
  &lt;br /&gt;
  EPrints::XML::add_to_xml( $filename, $string, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
  Don't forget the equivalent code block in '''disable''' to remoce it again.&lt;br /&gt;
&lt;br /&gt;
=Exercise 1=&lt;br /&gt;
&lt;br /&gt;
We are going to directly manipulate the EPrints summary page to add the copyright holder data directly below the main citation. This could be done with the citation file in exactly the same way, we have just chosen to do the XML manipulation on the summary_page.xml instead. &lt;br /&gt;
&lt;br /&gt;
Firstly we fetch the citation (code needed in both the '''enable''' and '''disable''' methods. &lt;br /&gt;
&lt;br /&gt;
  my $citation = $repository-&amp;gt;dataset( &amp;quot;eprint&amp;quot; )-&amp;gt;citation( &amp;quot;summary_page&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  my $filename = $citation-&amp;gt;{filename};&lt;br /&gt;
&lt;br /&gt;
Then we specify our xml to add in '''enable''' &lt;br /&gt;
&lt;br /&gt;
  $string = &amp;quot;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;cite:citation xmlns='http://www.w3.org/1999/xhtml' xmlns:epc='http://eprints.org/ep3/control' xmlns:cite='http://eprints.org/ep3/citation'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;&amp;lt;p style='margin-bottom: 1em'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
       &amp;lt;nowiki&amp;gt;&amp;lt;div align='center'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
         &amp;lt;nowiki&amp;gt;&amp;lt;i&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
           &amp;lt;nowiki&amp;gt;&amp;lt;epc:foreach expr='copyright_holders' iterator='item'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
             &amp;lt;nowiki&amp;gt;&amp;lt;epc:print expr='\$item'/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
           &amp;lt;nowiki&amp;gt;&amp;lt;/epc:foreach&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
         &amp;lt;nowiki&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
       &amp;lt;nowiki&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;/cite:citation&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Apply it.&lt;br /&gt;
&lt;br /&gt;
    EPrints::XML::add_to_xml( $filename,$string,$self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Along with the 2 lines from earlier we need to call the inverse operation in disable to remove the stuff the package has added:&lt;br /&gt;
&lt;br /&gt;
    EPrints::XML::remove_package_from_xml($filename,$self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Note that this is same call as the workflow XML removal, just with a different filename. &lt;br /&gt;
&lt;br /&gt;
==Expiring your Abstract Pages==&lt;br /&gt;
&lt;br /&gt;
Due the fact we are adding to the abstract pages of an eprint record we need to expire them so that next time they are requested they are re-drawn. This code needs to be added to both the '''enable''' and '''disable''' methods.&lt;br /&gt;
&lt;br /&gt;
  unless( $repository-&amp;gt;expire_abstracts() )&lt;br /&gt;
  {&lt;br /&gt;
       $self-&amp;gt;{processor}-&amp;gt;add_message( &amp;quot;warning&amp;quot;,&amp;quot;You need to regenerate abstracts&amp;quot; ); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This is an example of returning a code which is not true of false. In this case the code means &amp;quot;I was successful but the user needs to do something extra&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
This time to test you can just add some copyright holder metadata to an article and then refresh that articles abstract to see if it worked.&lt;br /&gt;
&lt;br /&gt;
=Exercise 2 - Overriding whole sections of the abstract page=&lt;br /&gt;
&lt;br /&gt;
This feature allows you to replace entire sections of the abstract page with your own code.&lt;br /&gt;
&lt;br /&gt;
This is a simple enough operation to do, instead of simply matching XML elements and adding ones that aren't there like we have been doing up to this point, we now specify a flag on an element to begin the replacement. &lt;br /&gt;
&lt;br /&gt;
See if you can work out what this piece of XML will do, why not add it to your package and try it.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;cite:citation xmlns='http://www.w3.org/1999/xhtml' xmlns:epc='http://eprints.org/ep3/control' xmlns:cite='http://eprints.org/ep3/citation'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    &amp;lt;epc:set operation='replace' name='docs' expr='\$item.documents()'&amp;gt;Hello&amp;lt;/epc:set&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;/cite:citation&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Other Possible Operations (r6016)==&lt;br /&gt;
&lt;br /&gt;
* replace: Causes the node you are defining to replace any node which has exactly the same definition.&lt;br /&gt;
* disbale: Disables any node with the exact same attributes.&lt;br /&gt;
&lt;br /&gt;
Currently there is no add_node_after or add_node_before operation however these are being looked into.&lt;br /&gt;
&lt;br /&gt;
=Exercise 3=&lt;br /&gt;
&lt;br /&gt;
Our copyright section doesn't really say what it is all about, how about adding a phrase, clue:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;epc:phrase ref=&amp;quot;myphrase_ref&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Exercise 4=&lt;br /&gt;
&lt;br /&gt;
Select any section on the abstract page to replace and see if you can replace it with something much prettier. Could you recognise the epub format and display this in a specific way which is different to other articles.&lt;br /&gt;
&lt;br /&gt;
=Final Note=&lt;br /&gt;
In these exercises I keep overriding the return code each time an operation is performed and not returning. Final versions of packages should decide what to do with the return codes at each stage and when and what to finally return. The return codes are going to replaced by constants in the near future.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_Abstract_page_using_a_Bazaar_Module&amp;diff=9923</id>
		<title>XML manipulation of the Abstract page using a Bazaar Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_Abstract_page_using_a_Bazaar_Module&amp;diff=9923"/>
		<updated>2011-07-21T12:30:07Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
Before you can carry out the work outlined on this page you will need to prepare your package by following the steps on the [[XML manipulation of the EPrints Workflow using a Bazaar Package]] page up until the start of Exercise 1.&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to manipulate the abstract page by changing the citation XML which is displayed on various parts of the rendered abstract page.&lt;br /&gt;
&lt;br /&gt;
=Pre-Requisits=&lt;br /&gt;
&lt;br /&gt;
To do this exercise you will need:&lt;br /&gt;
&lt;br /&gt;
* A live EPrint record of type article. Training repositories should come set up with the test data. &lt;br /&gt;
* A rights field added to the EPrints workflow and filled in for this eprint.&lt;br /&gt;
&lt;br /&gt;
To add the rights field is simply a replication of the [[XML manipulation of the EPrints Workflow using a Bazaar Package]] exercise, with the following code block to manipulate the workflow needing to be added to '''enable''':&lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  my $string = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;core&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;epc:if test=&amp;quot;type = 'article'&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;field ref=&amp;quot;copyright_holders&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/epc:if&amp;gt;&lt;br /&gt;
        &amp;lt;/component&amp;gt;&lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
  &amp;lt;/workflow&amp;gt;&lt;br /&gt;
  ';&lt;br /&gt;
  &lt;br /&gt;
  my $rc = add_to_xml( $filename, $string, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
  Don't forget the equivalent code block in '''disable''' to remoce it again.&lt;br /&gt;
&lt;br /&gt;
=Exercise 1=&lt;br /&gt;
&lt;br /&gt;
We are going to directly manipulate the EPrints summary page to add the copyright holder data directly below the main citation. This could be done with the citation file in exactly the same way, we have just chosen to do the XML manipulation on the summary_page.xml instead. &lt;br /&gt;
&lt;br /&gt;
Firstly we fetch the citation (code needed in both the '''enable''' and '''disable''' methods. &lt;br /&gt;
&lt;br /&gt;
  my $citation = $repository-&amp;gt;dataset( &amp;quot;eprint&amp;quot; )-&amp;gt;citation( &amp;quot;summary_page&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  my $filename = $citation-&amp;gt;{filename};&lt;br /&gt;
&lt;br /&gt;
Then we specify our xml to add in '''enable''' &lt;br /&gt;
&lt;br /&gt;
  $string = &amp;quot;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;cite:citation xmlns='http://www.w3.org/1999/xhtml' xmlns:epc='http://eprints.org/ep3/control' xmlns:cite='http://eprints.org/ep3/citation'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;&amp;lt;p style='margin-bottom: 1em'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
       &amp;lt;nowiki&amp;gt;&amp;lt;div align='center'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
         &amp;lt;nowiki&amp;gt;&amp;lt;i&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
           &amp;lt;nowiki&amp;gt;&amp;lt;epc:foreach expr='copyright_holders' iterator='item'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
             &amp;lt;nowiki&amp;gt;&amp;lt;epc:print expr='\$item'/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
           &amp;lt;nowiki&amp;gt;&amp;lt;/epc:foreach&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
         &amp;lt;nowiki&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
       &amp;lt;nowiki&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;/cite:citation&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Apply it.&lt;br /&gt;
&lt;br /&gt;
    my $rc = EPrints::XML::add_to_xml( $filename,$string,$self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Along with the 2 lines from earlier we need to call the inverse operation in disable to remove the stuff the package has added:&lt;br /&gt;
&lt;br /&gt;
    my $rc = EPrints::XML::remove_package_from_xml($filename,$self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Note that this is same call as the workflow XML removal, just with a different filename. &lt;br /&gt;
&lt;br /&gt;
==Expiring your Abstract Pages==&lt;br /&gt;
&lt;br /&gt;
Due the fact we are adding to the abstract pages of an eprint record we need to expire them so that next time they are requested they are re-drawn. This code needs to be added to both the '''enable''' and '''disable''' methods.&lt;br /&gt;
&lt;br /&gt;
  unless( $repository-&amp;gt;expire_abstracts() )&lt;br /&gt;
  {&lt;br /&gt;
        $message = &amp;quot;You need to regenerate abstracts&amp;quot;;&lt;br /&gt;
        $rc = 0.5;&lt;br /&gt;
        return($rc,$message);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This is an example of returning a code which is not true of false. In this case the code means &amp;quot;I was successful but the user needs to do something extra&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
This time to test you can just add some copyright holder metadata to an article and then refresh that articles abstract to see if it worked.&lt;br /&gt;
&lt;br /&gt;
=Exercise 2 - Overriding whole sections of the abstract page=&lt;br /&gt;
&lt;br /&gt;
This feature allows you to replace entire sections of the abstract page with your own code.&lt;br /&gt;
&lt;br /&gt;
This is a simple enough operation to do, instead of simply matching XML elements and adding ones that aren't there like we have been doing up to this point, we now specify a flag on an element to begin the replacement. &lt;br /&gt;
&lt;br /&gt;
See if you can work out what this piece of XML will do, why not add it to your package and try it.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;cite:citation xmlns='http://www.w3.org/1999/xhtml' xmlns:epc='http://eprints.org/ep3/control' xmlns:cite='http://eprints.org/ep3/citation'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    &amp;lt;epc:set operation='replace' name='docs' expr='\$item.documents()'&amp;gt;Hello&amp;lt;/epc:set&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;/cite:citation&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Other Possible Operations (r6016)==&lt;br /&gt;
&lt;br /&gt;
* replace: Causes the node you are defining to replace any node which has exactly the same definition.&lt;br /&gt;
* disbale: Disables any node with the exact same attributes.&lt;br /&gt;
&lt;br /&gt;
Currently there is no add_node_after or add_node_before operation however these are being looked into.&lt;br /&gt;
&lt;br /&gt;
=Exercise 3=&lt;br /&gt;
&lt;br /&gt;
Our copyright section doesn't really say what it is all about, how about adding a phrase, clue:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;epc:phrase ref=&amp;quot;myphrase_ref&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Exercise 4=&lt;br /&gt;
&lt;br /&gt;
Select any section on the abstract page to replace and see if you can replace it with something much prettier. Could you recognise the epub format and display this in a specific way which is different to other articles.&lt;br /&gt;
&lt;br /&gt;
=Final Note=&lt;br /&gt;
In these exercises I keep overriding the return code each time an operation is performed and not returning. Final versions of packages should decide what to do with the return codes at each stage and when and what to finally return. The return codes are going to replaced by constants in the near future.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_Abstract_page_using_a_Bazaar_Module&amp;diff=9922</id>
		<title>XML manipulation of the Abstract page using a Bazaar Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_Abstract_page_using_a_Bazaar_Module&amp;diff=9922"/>
		<updated>2011-07-21T12:28:35Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Pre-Requisits */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
Before you can carry out the work outlined on this page you will need to prepare your package by following the steps on the [[XML manipulation of the EPrints Workflow using a Bazaar Package]] page up until the start of Exercise 1.&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to manipulate the abstract page by changing the citation XML which is displayed on various parts of the rendered abstract page.&lt;br /&gt;
&lt;br /&gt;
=Pre-Requisits=&lt;br /&gt;
&lt;br /&gt;
To do this exercise you will need:&lt;br /&gt;
&lt;br /&gt;
* A live EPrint record of type article. Training repositories should come set up with the test data. &lt;br /&gt;
* A rights field added to the EPrints workflow and filled in for this eprint.&lt;br /&gt;
&lt;br /&gt;
To add the rights field is simply a replication of the [[XML manipulation of the EPrints Workflow using a Bazaar Package]] exercise, with the following code block to manipulate the workflow needing to be added to '''enable''':&lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  my $string = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;core&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;epc:if test=&amp;quot;type = 'article'&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;field ref=&amp;quot;copyright_holders&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/epc:if&amp;gt;&lt;br /&gt;
        &amp;lt;/component&amp;gt;&lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
  &amp;lt;/workflow&amp;gt;&lt;br /&gt;
  ';&lt;br /&gt;
  &lt;br /&gt;
  my $rc = add_to_xml( $filename, $string, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
  Don't forget the equivalent code block in '''disable''' to remoce it again.&lt;br /&gt;
&lt;br /&gt;
=Exercise 1=&lt;br /&gt;
&lt;br /&gt;
We are going to directly manipulate the EPrints summary page to add the copyright holder data directly below the main citation. This could be done with the citation file in exactly the same way, we have just chosen to do the XML manipulation on the summary_page.xml instead. &lt;br /&gt;
&lt;br /&gt;
Firstly we fetch the citation (code needed in both the '''postinst'' and '''prerm''' methods. &lt;br /&gt;
&lt;br /&gt;
  my $citation = $repository-&amp;gt;dataset( &amp;quot;eprint&amp;quot; )-&amp;gt;citation( &amp;quot;summary_page&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  my $filename = $citation-&amp;gt;{filename};&lt;br /&gt;
&lt;br /&gt;
Then we specify our xml to add in '''postinst''' &lt;br /&gt;
&lt;br /&gt;
  $string = &amp;quot;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;cite:citation xmlns='http://www.w3.org/1999/xhtml' xmlns:epc='http://eprints.org/ep3/control' xmlns:cite='http://eprints.org/ep3/citation'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;&amp;lt;p style='margin-bottom: 1em'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
       &amp;lt;nowiki&amp;gt;&amp;lt;div align='center'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
         &amp;lt;nowiki&amp;gt;&amp;lt;i&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
           &amp;lt;nowiki&amp;gt;&amp;lt;epc:foreach expr='copyright_holders' iterator='item'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
             &amp;lt;nowiki&amp;gt;&amp;lt;epc:print expr='\$item'/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
           &amp;lt;nowiki&amp;gt;&amp;lt;/epc:foreach&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
         &amp;lt;nowiki&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
       &amp;lt;nowiki&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;/cite:citation&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;quot;;&lt;br /&gt;
&lt;br /&gt;
Apply it.&lt;br /&gt;
&lt;br /&gt;
    my $rc = EPrints::XML::add_to_xml( $filename,$string,$self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Along with the 2 lines from earlier we need to call the inverse operation in prerm to remove the stuff the package has added:&lt;br /&gt;
&lt;br /&gt;
    my $rc = EPrints::XML::remove_package_from_xml($filename,$self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Note that this is same call as the workflow XML removal, just with a different filename. &lt;br /&gt;
&lt;br /&gt;
==Expiring your Abstract Pages==&lt;br /&gt;
&lt;br /&gt;
Due the fact we are adding to the abstract pages of an eprint record we need to expire them so that next time they are requested they are re-drawn. This code needs to be added to both the '''postinst''' and '''prerm''' methods.&lt;br /&gt;
&lt;br /&gt;
  unless( $repository-&amp;gt;expire_abstracts() )&lt;br /&gt;
  {&lt;br /&gt;
        $message = &amp;quot;You need to regenerate abstracts&amp;quot;;&lt;br /&gt;
        $rc = 0.5;&lt;br /&gt;
        return($rc,$message);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
This is an example of returning a code which is not true of false. In this case the code means &amp;quot;I was successful but the user needs to do something extra&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
This time to test you can just add some copyright holder metadata to an article and then refresh that articles abstract to see if it worked.&lt;br /&gt;
&lt;br /&gt;
=Exercise 2 - Overriding whole sections of the abstract page=&lt;br /&gt;
&lt;br /&gt;
This feature allows you to replace entire sections of the abstract page with your own code.&lt;br /&gt;
&lt;br /&gt;
This is a simple enough operation to do, instead of simply matching XML elements and adding ones that aren't there like we have been doing up to this point, we now specify a flag on an element to begin the replacement. &lt;br /&gt;
&lt;br /&gt;
See if you can work out what this piece of XML will do, why not add it to your package and try it.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;cite:citation xmlns='http://www.w3.org/1999/xhtml' xmlns:epc='http://eprints.org/ep3/control' xmlns:cite='http://eprints.org/ep3/citation'&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    &amp;lt;epc:set operation='replace' name='docs' expr='\$item.documents()'&amp;gt;Hello&amp;lt;/epc:set&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;/cite:citation&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Other Possible Operations (r6016)==&lt;br /&gt;
&lt;br /&gt;
* replace: Causes the node you are defining to replace any node which has exactly the same definition.&lt;br /&gt;
* disbale: Disables any node with the exact same attributes.&lt;br /&gt;
&lt;br /&gt;
Currently there is no add_node_after or add_node_before operation however these are being looked into.&lt;br /&gt;
&lt;br /&gt;
=Exercise 3=&lt;br /&gt;
&lt;br /&gt;
Our copyright section doesn't really say what it is all about, how about adding a phrase, clue:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;epc:phrase ref=&amp;quot;myphrase_ref&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Exercise 4=&lt;br /&gt;
&lt;br /&gt;
Select any section on the abstract page to replace and see if you can replace it with something much prettier. Could you recognise the epub format and display this in a specific way which is different to other articles.&lt;br /&gt;
&lt;br /&gt;
=Final Note=&lt;br /&gt;
In these exercises I keep overriding the return code each time an operation is performed and not returning. Final versions of packages should decide what to do with the return codes at each stage and when and what to finally return. The return codes are going to replaced by constants in the near future.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package&amp;diff=9921</id>
		<title>XML manipulation of the EPrints Workflow using a Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package&amp;diff=9921"/>
		<updated>2011-07-21T11:35:13Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Pre-Requisites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
Manipulation of built in EPrint files, such as the Workflows, is currently performed using the enable method which is run as a package is being installed on a single repository. &lt;br /&gt;
&lt;br /&gt;
Likewise when the package is removed, the disable method needs to call exactly the opposite set of operations to clean itself up before full removal.&lt;br /&gt;
&lt;br /&gt;
Every package has an enable and disable method which is called, we simply need to subclass the EPMC screen and add our own enable and disable methods. &lt;br /&gt;
&lt;br /&gt;
=Pre-Requisites=&lt;br /&gt;
&lt;br /&gt;
Below is a simple framework for your plug-in (it's a Screen::EPMC plug-in so needs to go in the lib/plugins/EPrints/Plugin/Screen/EPMC directory). Remember to name it applicably and remember the EPMC::Package_Name when filling out your package specification (this is what calls it!). &lt;br /&gt;
&lt;br /&gt;
NOTE: The following line:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{package_name} = &amp;quot;package_name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
If your package name is &amp;quot;my_package&amp;quot;, this line should read:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{package_name} = &amp;quot;my_package&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
This way you don't need to type your package name in anywhere else in the code, You can just use $self-&amp;gt;{package_name} which is the variable that contains the name.&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Screen::EPMC::Package_Name;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = ( 'EPrints::Plugin::Screen::EPMC' );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  # Make the plug-in&lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new( %params );&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{actions} = [qw( enable disable )];&lt;br /&gt;
        $self-&amp;gt;{disable} = 0; # always enabled, even in lib/plugins&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{package_name} = &amp;quot;Package_Name&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  =item $screen-&amp;gt;action_enable( [ SKIP_RELOAD ] )&lt;br /&gt;
  &lt;br /&gt;
  Enable the L&amp;lt;EPrints::DataObj::EPM&amp;gt; for the current repository.&lt;br /&gt;
  &lt;br /&gt;
  If SKIP_RELOAD is true will not reload the repository configuration.&lt;br /&gt;
  &lt;br /&gt;
  =cut&lt;br /&gt;
  &lt;br /&gt;
  sub action_enable&lt;br /&gt;
  {&lt;br /&gt;
        my( $self, $skip_reload ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;SUPER::action_enable( $skip_reload );&lt;br /&gt;
  &lt;br /&gt;
        my $repo = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        # ADD STUFF HERE&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;reload_config if !$skip_reload;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  =item $screen-&amp;gt;action_disable( [ SKIP_RELOAD ] )&lt;br /&gt;
  &lt;br /&gt;
  Disable the L&amp;lt;EPrints::DataObj::EPM&amp;gt; for the current repository.&lt;br /&gt;
  &lt;br /&gt;
  If SKIP_RELOAD is true will not reload the repository configuration.&lt;br /&gt;
  &lt;br /&gt;
  =cut&lt;br /&gt;
  &lt;br /&gt;
  sub action_disable&lt;br /&gt;
  {&lt;br /&gt;
        my( $self, $skip_reload ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;SUPER::action_disable( $skip_reload );&lt;br /&gt;
        my $repo = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        # ADD STUFF HERE&lt;br /&gt;
        &lt;br /&gt;
        $self-&amp;gt;reload_config if !$skip_reload;&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
=Exercise 1=&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to do some simple workflow editing exercises. These follow the standard EPrints training materials which teach you how to manually edit the workflow. Here we are going to do all the same stuff with API calls. &lt;br /&gt;
&lt;br /&gt;
=Adding a Divisions Stage to the Workflow=&lt;br /&gt;
&lt;br /&gt;
Basically we are simply editing XML so all we need to do is tell the repository which file to manipulate and then give it the stuff add to this file. &lt;br /&gt;
&lt;br /&gt;
So to the '''enable''' routine we need to add the following lines. Note that you '''don't''' need to manually specify your package_name &lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # Gap for the stuff to be defined we need to add&lt;br /&gt;
  &lt;br /&gt;
  EPrints::XML::add_to_xml( $filename, $xml, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At the same time then it is worth adding the equivalent remove lines to the '''disable''' method. Again you need to specify your package name. &lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  EPrints::XML::remove_package_from_xml( $filename, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Lastly we need to actually tell the enable method the block of XML to add.&lt;br /&gt;
&lt;br /&gt;
  my $xml = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;flow&amp;gt;&lt;br /&gt;
                &amp;lt;stage ref=&amp;quot;divisions&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/flow&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;divisions&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;component type=&amp;quot;Field::Subject&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;field ref=&amp;quot;divisions&amp;quot; required=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/component&amp;gt;&lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
 &amp;lt;/workflow&amp;gt;&lt;br /&gt;
 ';&lt;br /&gt;
&lt;br /&gt;
Here you can see that we can simply specify the XML as a string. We can then either parse this string and send a dom object to the add method, or simply send the string and let the add_to_xml method do it for us. &lt;br /&gt;
&lt;br /&gt;
If you want to parse it yourself you will need the following code block:&lt;br /&gt;
&lt;br /&gt;
  my $xml = EPrints::XML::parse_string( undef, $string );&lt;br /&gt;
  &lt;br /&gt;
The XML represents the exact same tree as in the workflow XML file we are attempting to edit. You can view this by clicking the &amp;quot;View Configuration&amp;quot; button on the &amp;quot;Config. Tools&amp;quot; tab of the admin screen. Once here you will need to scroll down to find the file you specified (in this case /workflows/eprint/default.xml). Since it represents the same tree, only nodes which don't exist are added and marked as belonging to your package. This marker is how they are removed. &lt;br /&gt;
&lt;br /&gt;
Alternatively you can build an XML tree using the EPrints::XML methods like make_element(&amp;quot;flow&amp;quot;) etc. At this point (unless you added blank nodes) you won't need the remove line, but it doesn't hurt to leave it in there. &lt;br /&gt;
&lt;br /&gt;
==Divisions Phrases==&lt;br /&gt;
&lt;br /&gt;
For the divisions screen to work fully you will need to define a number of phrases.&lt;br /&gt;
&lt;br /&gt;
As usual you need a new file, basically take a copy of lib/lang/en/phrases/zz_webcfg in cfg/lang/en/phrases/package_name. &lt;br /&gt;
&lt;br /&gt;
The clear all the defined phrases from this file and add the follow 2:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;epp:phrase id=&amp;quot;metapage_title_divisions&amp;quot;&amp;gt;Divisions&amp;lt;/epp:phrase&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;epp:phrase id=&amp;quot;Plugin/InputForm/Component/Field/Subject:divisions_search_bar&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;ep_subjectinput_searchbar&amp;quot;&amp;gt;Search for division: &amp;lt;epc:pin name=&amp;quot;input&amp;quot;/&amp;gt; &amp;lt;epc:pin name=&amp;quot;search_button&amp;quot;/&amp;gt; &amp;lt;epc:pin name=&amp;quot;clear_button&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/epp:phrase&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Package and Test=&lt;br /&gt;
&lt;br /&gt;
Finally, package all these files up and test in from the Bazaar. Note that in the spec file you need to set your Control Screen to EPMC::PackageName or whatever your screen is called. &lt;br /&gt;
&lt;br /&gt;
You can test this package by click the &amp;quot;manage deposits&amp;quot;  link in the admin toolbar and adding a new item. You should see a divisions tab.&lt;br /&gt;
&lt;br /&gt;
=Exercise 2=&lt;br /&gt;
&lt;br /&gt;
Change this package to add a conditional element somewhere, for example:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;epc:if test=&amp;quot;type = 'book'&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;field ref=&amp;quot;pres_type&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/epc:if&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Experiment with this and use the &amp;quot;view configuration&amp;quot; to see what your changes do to the workflow file each time.&lt;br /&gt;
&lt;br /&gt;
Clue: The correct place to put this code block is under the &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt; tag which is in the core stage &amp;lt;stage name=&amp;quot;core&amp;quot;&amp;gt;. You need to wrap the above code blog in both these tags.&lt;br /&gt;
&lt;br /&gt;
If you are using the same package as before you will need to updated your cached version and then restart apache to make it work. This is a known bug and applies the the XML manipulation code only.&lt;br /&gt;
&lt;br /&gt;
=Exercise 3=&lt;br /&gt;
&lt;br /&gt;
Here we are going to define a whole new type &amp;quot;map&amp;quot; and a different set of stages for it.&lt;br /&gt;
&lt;br /&gt;
This exercise is also one of manual customisation exercises we run. &lt;br /&gt;
&lt;br /&gt;
==Add a new depoist type==&lt;br /&gt;
&lt;br /&gt;
This stage involves the editing of the repository namedsets, specifically the eprints namedset. &lt;br /&gt;
&lt;br /&gt;
Again this used to be an entirely manual process however it can now be done with an API call via the enable/disable methods:&lt;br /&gt;
&lt;br /&gt;
In '''enable''':&lt;br /&gt;
  &lt;br /&gt;
  # Load your namedset, in this case the eprint namedset&lt;br /&gt;
  my $namedset = EPrints::NamedSet-&amp;gt;new( &amp;quot;eprint&amp;quot;,repository =&amp;gt; $repository );&lt;br /&gt;
  &lt;br /&gt;
  # Add a new option (string type, package_name, offset from top) &lt;br /&gt;
  # Setting the offset to 0 will add the item at the top of list of eprint types in this case. &lt;br /&gt;
  $namedset-&amp;gt;add_option( &amp;quot;map&amp;quot;, $self-&amp;gt;{package_name}, 0 );&lt;br /&gt;
  &lt;br /&gt;
In '''diable''' we need the corresponding remove calls! &lt;br /&gt;
&lt;br /&gt;
  my $namedset = EPrints::NamedSet-&amp;gt;new( &amp;quot;eprint&amp;quot;,repository =&amp;gt; $repository );&lt;br /&gt;
  &lt;br /&gt;
  $namedset-&amp;gt;remove_option( &amp;quot;map&amp;quot;, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Each namedset item also needs some phrase so in our phrase file we need to add phrases for &amp;quot;eprint_typename_map&amp;quot; and &amp;quot;eprint_optdetails_type_map&amp;quot;. Lets set these to &amp;quot;Map&amp;quot; and &amp;quot;A map or chart.&amp;quot; respectively.&lt;br /&gt;
&lt;br /&gt;
==Adding a new stage and simple map workflow==&lt;br /&gt;
&lt;br /&gt;
In this section we are going to define a whole new workflow for our &amp;quot;map&amp;quot; type, so if someone selects this as their EPrint type they won't see upload (files), subjects and divisions, just a new state we going to call &amp;quot;map_stage&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Of course in order to customise the workflow we need to handle if/else statements. Helpfully there is a clever API call that does it for you. &lt;br /&gt;
&lt;br /&gt;
All we have to define in the types we want to match and the stages that these types have. Everything that doesn't match thus goes in the else condition. &lt;br /&gt;
&lt;br /&gt;
So in our '''enable''' lets now define some variables&lt;br /&gt;
&lt;br /&gt;
  #our matching types &lt;br /&gt;
  my @types = ( &amp;quot;map&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  #the stages&lt;br /&gt;
  my @stages = ( &amp;quot;map_stage&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Then we add these to our workflow with a similar API call to before.&lt;br /&gt;
&lt;br /&gt;
  $rc = EPrints::Workflow::add_workflow_flow( $repository, $filename, $self-&amp;gt;{package_name}, \@types, \@stages );&lt;br /&gt;
&lt;br /&gt;
We can then use the xml string which we defined before to add the new stage:&lt;br /&gt;
&lt;br /&gt;
  my $string = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;map_stage&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt;&lt;br /&gt;
                     &amp;lt;title&amp;gt;Publisher Details&amp;lt;/title&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;place_of_pub&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;publisher&amp;quot; required=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;date&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;date_type&amp;quot; /&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;&lt;br /&gt;
               &amp;lt;component&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;id_number&amp;quot; /&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;&lt;br /&gt;
               &amp;lt;component&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;official_url&amp;quot;/&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;      &lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
  &amp;lt;/workflow&amp;gt;&lt;br /&gt;
  ';&lt;br /&gt;
&lt;br /&gt;
=Package and Test=&lt;br /&gt;
&lt;br /&gt;
Finally, package all these files up and test in from the Bazaar. &lt;br /&gt;
&lt;br /&gt;
You can test this package by click the &amp;quot;manage deposits&amp;quot;  link in the admin toolbar and adding a new item. You should now have a new eprint type on the first screen called &amp;quot;map&amp;quot; and selecting this will give you a much shorter workflow containing only a few fields. &lt;br /&gt;
&lt;br /&gt;
Are all your phrases defined?&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package&amp;diff=9920</id>
		<title>XML manipulation of the EPrints Workflow using a Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package&amp;diff=9920"/>
		<updated>2011-07-21T11:34:41Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
Manipulation of built in EPrint files, such as the Workflows, is currently performed using the enable method which is run as a package is being installed on a single repository. &lt;br /&gt;
&lt;br /&gt;
Likewise when the package is removed, the disable method needs to call exactly the opposite set of operations to clean itself up before full removal.&lt;br /&gt;
&lt;br /&gt;
Every package has an enable and disable method which is called, we simply need to subclass the EPMC screen and add our own enable and disable methods. &lt;br /&gt;
&lt;br /&gt;
=Pre-Requisites=&lt;br /&gt;
&lt;br /&gt;
Below is a simple framework for your plug-in (it's a Screen::EPMC plug-in so needs to go in the lib/plugins/EPrints/Plugin/Screen/EPMC directory). Remember to name it applicably and remember the EPMC::Package_Name when filling out your package specification (this is what calls it!). &lt;br /&gt;
&lt;br /&gt;
NOTE: The following line:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{package_name} = &amp;quot;package_name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
If your package name is &amp;quot;my_package&amp;quot;, this line should read:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{package_name} = &amp;quot;my_package&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
This way you don't need to type your package name in anywhere else in the code, You can just use $self-&amp;gt;{package_name} which is the variable that contains the name.&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Screen::EPMC::Package_Name;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = ( 'EPrints::Plugin::Screen::EPMC' );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  # Make the plug-in&lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new( %params );&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{actions} = [qw( enable disable )];&lt;br /&gt;
        $self-&amp;gt;{disable} = 0; # always enabled, even in lib/plugins&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{package_name} = &amp;quot;Manipulate_Workflow_Ex&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  =item $screen-&amp;gt;action_enable( [ SKIP_RELOAD ] )&lt;br /&gt;
  &lt;br /&gt;
  Enable the L&amp;lt;EPrints::DataObj::EPM&amp;gt; for the current repository.&lt;br /&gt;
  &lt;br /&gt;
  If SKIP_RELOAD is true will not reload the repository configuration.&lt;br /&gt;
  &lt;br /&gt;
  =cut&lt;br /&gt;
  &lt;br /&gt;
  sub action_enable&lt;br /&gt;
  {&lt;br /&gt;
        my( $self, $skip_reload ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;SUPER::action_enable( $skip_reload );&lt;br /&gt;
  &lt;br /&gt;
        my $repo = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        # ADD STUFF HERE&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;reload_config if !$skip_reload;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  =item $screen-&amp;gt;action_disable( [ SKIP_RELOAD ] )&lt;br /&gt;
  &lt;br /&gt;
  Disable the L&amp;lt;EPrints::DataObj::EPM&amp;gt; for the current repository.&lt;br /&gt;
  &lt;br /&gt;
  If SKIP_RELOAD is true will not reload the repository configuration.&lt;br /&gt;
  &lt;br /&gt;
  =cut&lt;br /&gt;
  &lt;br /&gt;
  sub action_disable&lt;br /&gt;
  {&lt;br /&gt;
        my( $self, $skip_reload ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;SUPER::action_disable( $skip_reload );&lt;br /&gt;
        my $repo = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        # ADD STUFF HERE&lt;br /&gt;
        &lt;br /&gt;
        $self-&amp;gt;reload_config if !$skip_reload;&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
=Exercise 1=&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to do some simple workflow editing exercises. These follow the standard EPrints training materials which teach you how to manually edit the workflow. Here we are going to do all the same stuff with API calls. &lt;br /&gt;
&lt;br /&gt;
=Adding a Divisions Stage to the Workflow=&lt;br /&gt;
&lt;br /&gt;
Basically we are simply editing XML so all we need to do is tell the repository which file to manipulate and then give it the stuff add to this file. &lt;br /&gt;
&lt;br /&gt;
So to the '''enable''' routine we need to add the following lines. Note that you '''don't''' need to manually specify your package_name &lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # Gap for the stuff to be defined we need to add&lt;br /&gt;
  &lt;br /&gt;
  EPrints::XML::add_to_xml( $filename, $xml, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At the same time then it is worth adding the equivalent remove lines to the '''disable''' method. Again you need to specify your package name. &lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  EPrints::XML::remove_package_from_xml( $filename, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Lastly we need to actually tell the enable method the block of XML to add.&lt;br /&gt;
&lt;br /&gt;
  my $xml = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;flow&amp;gt;&lt;br /&gt;
                &amp;lt;stage ref=&amp;quot;divisions&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/flow&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;divisions&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;component type=&amp;quot;Field::Subject&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;field ref=&amp;quot;divisions&amp;quot; required=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/component&amp;gt;&lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
 &amp;lt;/workflow&amp;gt;&lt;br /&gt;
 ';&lt;br /&gt;
&lt;br /&gt;
Here you can see that we can simply specify the XML as a string. We can then either parse this string and send a dom object to the add method, or simply send the string and let the add_to_xml method do it for us. &lt;br /&gt;
&lt;br /&gt;
If you want to parse it yourself you will need the following code block:&lt;br /&gt;
&lt;br /&gt;
  my $xml = EPrints::XML::parse_string( undef, $string );&lt;br /&gt;
  &lt;br /&gt;
The XML represents the exact same tree as in the workflow XML file we are attempting to edit. You can view this by clicking the &amp;quot;View Configuration&amp;quot; button on the &amp;quot;Config. Tools&amp;quot; tab of the admin screen. Once here you will need to scroll down to find the file you specified (in this case /workflows/eprint/default.xml). Since it represents the same tree, only nodes which don't exist are added and marked as belonging to your package. This marker is how they are removed. &lt;br /&gt;
&lt;br /&gt;
Alternatively you can build an XML tree using the EPrints::XML methods like make_element(&amp;quot;flow&amp;quot;) etc. At this point (unless you added blank nodes) you won't need the remove line, but it doesn't hurt to leave it in there. &lt;br /&gt;
&lt;br /&gt;
==Divisions Phrases==&lt;br /&gt;
&lt;br /&gt;
For the divisions screen to work fully you will need to define a number of phrases.&lt;br /&gt;
&lt;br /&gt;
As usual you need a new file, basically take a copy of lib/lang/en/phrases/zz_webcfg in cfg/lang/en/phrases/package_name. &lt;br /&gt;
&lt;br /&gt;
The clear all the defined phrases from this file and add the follow 2:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;epp:phrase id=&amp;quot;metapage_title_divisions&amp;quot;&amp;gt;Divisions&amp;lt;/epp:phrase&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;epp:phrase id=&amp;quot;Plugin/InputForm/Component/Field/Subject:divisions_search_bar&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;ep_subjectinput_searchbar&amp;quot;&amp;gt;Search for division: &amp;lt;epc:pin name=&amp;quot;input&amp;quot;/&amp;gt; &amp;lt;epc:pin name=&amp;quot;search_button&amp;quot;/&amp;gt; &amp;lt;epc:pin name=&amp;quot;clear_button&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/epp:phrase&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Package and Test=&lt;br /&gt;
&lt;br /&gt;
Finally, package all these files up and test in from the Bazaar. Note that in the spec file you need to set your Control Screen to EPMC::PackageName or whatever your screen is called. &lt;br /&gt;
&lt;br /&gt;
You can test this package by click the &amp;quot;manage deposits&amp;quot;  link in the admin toolbar and adding a new item. You should see a divisions tab.&lt;br /&gt;
&lt;br /&gt;
=Exercise 2=&lt;br /&gt;
&lt;br /&gt;
Change this package to add a conditional element somewhere, for example:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;epc:if test=&amp;quot;type = 'book'&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;field ref=&amp;quot;pres_type&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/epc:if&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Experiment with this and use the &amp;quot;view configuration&amp;quot; to see what your changes do to the workflow file each time.&lt;br /&gt;
&lt;br /&gt;
Clue: The correct place to put this code block is under the &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt; tag which is in the core stage &amp;lt;stage name=&amp;quot;core&amp;quot;&amp;gt;. You need to wrap the above code blog in both these tags.&lt;br /&gt;
&lt;br /&gt;
If you are using the same package as before you will need to updated your cached version and then restart apache to make it work. This is a known bug and applies the the XML manipulation code only.&lt;br /&gt;
&lt;br /&gt;
=Exercise 3=&lt;br /&gt;
&lt;br /&gt;
Here we are going to define a whole new type &amp;quot;map&amp;quot; and a different set of stages for it.&lt;br /&gt;
&lt;br /&gt;
This exercise is also one of manual customisation exercises we run. &lt;br /&gt;
&lt;br /&gt;
==Add a new depoist type==&lt;br /&gt;
&lt;br /&gt;
This stage involves the editing of the repository namedsets, specifically the eprints namedset. &lt;br /&gt;
&lt;br /&gt;
Again this used to be an entirely manual process however it can now be done with an API call via the enable/disable methods:&lt;br /&gt;
&lt;br /&gt;
In '''enable''':&lt;br /&gt;
  &lt;br /&gt;
  # Load your namedset, in this case the eprint namedset&lt;br /&gt;
  my $namedset = EPrints::NamedSet-&amp;gt;new( &amp;quot;eprint&amp;quot;,repository =&amp;gt; $repository );&lt;br /&gt;
  &lt;br /&gt;
  # Add a new option (string type, package_name, offset from top) &lt;br /&gt;
  # Setting the offset to 0 will add the item at the top of list of eprint types in this case. &lt;br /&gt;
  $namedset-&amp;gt;add_option( &amp;quot;map&amp;quot;, $self-&amp;gt;{package_name}, 0 );&lt;br /&gt;
  &lt;br /&gt;
In '''diable''' we need the corresponding remove calls! &lt;br /&gt;
&lt;br /&gt;
  my $namedset = EPrints::NamedSet-&amp;gt;new( &amp;quot;eprint&amp;quot;,repository =&amp;gt; $repository );&lt;br /&gt;
  &lt;br /&gt;
  $namedset-&amp;gt;remove_option( &amp;quot;map&amp;quot;, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Each namedset item also needs some phrase so in our phrase file we need to add phrases for &amp;quot;eprint_typename_map&amp;quot; and &amp;quot;eprint_optdetails_type_map&amp;quot;. Lets set these to &amp;quot;Map&amp;quot; and &amp;quot;A map or chart.&amp;quot; respectively.&lt;br /&gt;
&lt;br /&gt;
==Adding a new stage and simple map workflow==&lt;br /&gt;
&lt;br /&gt;
In this section we are going to define a whole new workflow for our &amp;quot;map&amp;quot; type, so if someone selects this as their EPrint type they won't see upload (files), subjects and divisions, just a new state we going to call &amp;quot;map_stage&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Of course in order to customise the workflow we need to handle if/else statements. Helpfully there is a clever API call that does it for you. &lt;br /&gt;
&lt;br /&gt;
All we have to define in the types we want to match and the stages that these types have. Everything that doesn't match thus goes in the else condition. &lt;br /&gt;
&lt;br /&gt;
So in our '''enable''' lets now define some variables&lt;br /&gt;
&lt;br /&gt;
  #our matching types &lt;br /&gt;
  my @types = ( &amp;quot;map&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  #the stages&lt;br /&gt;
  my @stages = ( &amp;quot;map_stage&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Then we add these to our workflow with a similar API call to before.&lt;br /&gt;
&lt;br /&gt;
  $rc = EPrints::Workflow::add_workflow_flow( $repository, $filename, $self-&amp;gt;{package_name}, \@types, \@stages );&lt;br /&gt;
&lt;br /&gt;
We can then use the xml string which we defined before to add the new stage:&lt;br /&gt;
&lt;br /&gt;
  my $string = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;map_stage&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt;&lt;br /&gt;
                     &amp;lt;title&amp;gt;Publisher Details&amp;lt;/title&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;place_of_pub&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;publisher&amp;quot; required=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;date&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;date_type&amp;quot; /&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;&lt;br /&gt;
               &amp;lt;component&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;id_number&amp;quot; /&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;&lt;br /&gt;
               &amp;lt;component&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;official_url&amp;quot;/&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;      &lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
  &amp;lt;/workflow&amp;gt;&lt;br /&gt;
  ';&lt;br /&gt;
&lt;br /&gt;
=Package and Test=&lt;br /&gt;
&lt;br /&gt;
Finally, package all these files up and test in from the Bazaar. &lt;br /&gt;
&lt;br /&gt;
You can test this package by click the &amp;quot;manage deposits&amp;quot;  link in the admin toolbar and adding a new item. You should now have a new eprint type on the first screen called &amp;quot;map&amp;quot; and selecting this will give you a much shorter workflow containing only a few fields. &lt;br /&gt;
&lt;br /&gt;
Are all your phrases defined?&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Boxes_on_Abstract_Pages&amp;diff=9919</id>
		<title>Boxes on Abstract Pages</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Boxes_on_Abstract_Pages&amp;diff=9919"/>
		<updated>2011-07-20T15:17:29Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
This tutorial looks at ways to add items to eprint abstract pages without the need to manipulate any XML code. &lt;br /&gt;
&lt;br /&gt;
This can be done by adding a box to either the top,bottom,left or right of the abstract page. &lt;br /&gt;
&lt;br /&gt;
These can be useful but don't always turn out in the correct place, hence manipulating XML can be more preferable in the long run. &lt;br /&gt;
&lt;br /&gt;
=An EPrints Box=&lt;br /&gt;
&lt;br /&gt;
These are very simple and live under the Screen plug-ins Box directory:&lt;br /&gt;
&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Screen/EPrint/Box/package_name.pm&lt;br /&gt;
&lt;br /&gt;
All they require is a render method as shown in the basic shell below:&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Screen::EPrint::Box::package_name;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = ( 'EPrints::Plugin::Screen::EPrint::Box' );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub render&lt;br /&gt;
  {&lt;br /&gt;
        my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
        my $eprint = $self-&amp;gt;{processor}-&amp;gt;{eprint};&lt;br /&gt;
  &lt;br /&gt;
        my $frag = $repository-&amp;gt;make_doc_fragment;&lt;br /&gt;
        &lt;br /&gt;
        $frag-&amp;gt;appendChild($repository-&amp;gt;make_text(&amp;quot;HELLO&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        return $frag;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Configuring your box=&lt;br /&gt;
&lt;br /&gt;
For this you need a config file in cfg/cfg.d/package_name.pl which contains the following:&lt;br /&gt;
&lt;br /&gt;
  $c-&amp;gt;{plugins}-&amp;gt;{&amp;quot;Screen::EPrint::Box::package_name&amp;quot;}-&amp;gt;{appears}-&amp;gt;{summary_top} = undef;&lt;br /&gt;
  $c-&amp;gt;{plugins}-&amp;gt;{&amp;quot;Screen::EPrint::Box::package_name&amp;quot;}-&amp;gt;{appears}-&amp;gt;{summary_right} = undef;&lt;br /&gt;
  $c-&amp;gt;{plugins}-&amp;gt;{&amp;quot;Screen::EPrint::Box::package_name&amp;quot;}-&amp;gt;{appears}-&amp;gt;{summary_bottom} = 800;&lt;br /&gt;
  $c-&amp;gt;{plugins}-&amp;gt;{&amp;quot;Screen::EPrint::Box::package_name&amp;quot;}-&amp;gt;{appears}-&amp;gt;{summary_left} = undef;&lt;br /&gt;
&lt;br /&gt;
So this box will appear bellow the summary_page citation with a priority of 800 (anything less will appear below and anything more above).&lt;br /&gt;
&lt;br /&gt;
=Installing as a package=&lt;br /&gt;
&lt;br /&gt;
To see your box you will need to invalidate the abstarct pages which can be done via the &amp;quot;Regenerate Abstracts&amp;quot; button under the &amp;quot;System Tools&amp;quot; tab of the admin interface. &lt;br /&gt;
&lt;br /&gt;
If you specify you config file properly in the spec file you should be able to click the &amp;quot;Configure Add-on&amp;quot; button to change these values.&lt;br /&gt;
&lt;br /&gt;
=Extension Exercise=&lt;br /&gt;
&lt;br /&gt;
It is recommended that this exercise is done after [[XML manipulation of the Abstract page using a Bazaar Module]]&lt;br /&gt;
&lt;br /&gt;
Make a screen plug-in which has a '''postinst''' and '''prerm''' which invalidate the abstract pages. The render method of this screen should still re-direct the user to the config file however!&lt;br /&gt;
&lt;br /&gt;
For the invalidate abstract code see [[XML manipulation of the Abstract page using a Bazaar Module]]&lt;br /&gt;
&lt;br /&gt;
Clue to the redirecting: &lt;br /&gt;
&lt;br /&gt;
  my $config_file = &amp;quot;cfg.d/package_name.pl&amp;quot;;&lt;br /&gt;
  my $screen_id = &amp;quot;Admin::Config::View::Perl&amp;quot;;&lt;br /&gt;
  my $redirect_url = $session-&amp;gt;current_url() . &amp;quot;?screen=&amp;quot; . $screen_id . &amp;quot;&amp;amp;configfile=&amp;quot; . $config_file;&lt;br /&gt;
  $session-&amp;gt;redirect( $redirect_url );&lt;br /&gt;
  exit();&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9918</id>
		<title>Import and Export Plug-ins</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9918"/>
		<updated>2011-07-20T14:03:34Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Exporting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
Import and Export Plug-ins are all about taking an object, de-serialising it into an eprint (or other object in the EPrints system) and re-serialising it back into an object to be supported. &lt;br /&gt;
&lt;br /&gt;
We would typically advocate that every import plug-in should have a corresponding export plug-in and visa-versa.&lt;br /&gt;
&lt;br /&gt;
=Enable the Plugin's=&lt;br /&gt;
&lt;br /&gt;
Create the package directory that will contain the package's configuration file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/epm/io_exercise/cfg/cfg.d&lt;br /&gt;
&lt;br /&gt;
Create a configuration file that enables the plugins in this package - this file is copied into the repository when the package is enabled:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/epm/hello_world/cfg/cfg.d/io_exercise.pl&lt;br /&gt;
 &lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Import::OPFXML&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Import::XSLT::DC&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
&lt;br /&gt;
=Input Data=&lt;br /&gt;
&lt;br /&gt;
We are going to attempt to import the following XML record into our system. If you know the format of this record all the better else we'll leave it as a surprise for now.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;package xmlns=&amp;quot;http://www.idpf.org/2007/opf&amp;quot; unique-identifier=&amp;quot;EPB-UUID&amp;quot; version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;metadata xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
             xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;dc:title&amp;gt;The Adventures of Sherlock Holmes&amp;lt;/dc:title&amp;gt;&lt;br /&gt;
      &amp;lt;dc:creator opf:role=&amp;quot;aut&amp;quot; opf:file-as=&amp;quot;Doyle, Sir Arthur Conan&amp;quot;&amp;gt;Sir Arthur Conan Doyle&amp;lt;/dc:creator&amp;gt;&lt;br /&gt;
      &amp;lt;dc:publisher&amp;gt;epubBooks (www.epubbooks.com)&amp;lt;/dc:publisher&amp;gt;&lt;br /&gt;
      &amp;lt;dc:date opf:event=&amp;quot;epub-publication&amp;quot;&amp;gt;2010-06-15&amp;lt;/dc:date&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Crime/Detective&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Short Stories&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:source&amp;gt;Project Gutenberg&amp;lt;/dc:source&amp;gt;&lt;br /&gt;
      &amp;lt;dc:rights&amp;gt;&lt;br /&gt;
            Provided for free by epubBooks.com. Not for commercial use.&lt;br /&gt;
            This EPUB eBook is released under a Creative Commons (BY-NC-ND/3.0) Licence.&lt;br /&gt;
            Source text and images are in the Public Domain.&lt;br /&gt;
      &amp;lt;/dc:rights&amp;gt;&lt;br /&gt;
      &amp;lt;dc:identifier id=&amp;quot;EPB-UUID&amp;quot;&amp;gt;urn:uuid:FF946905-6C08-1014-90EA-E81F8523F0DC&amp;lt;/dc:identifier&amp;gt;&lt;br /&gt;
      &amp;lt;dc:language&amp;gt;en-gb&amp;lt;/dc:language&amp;gt;&lt;br /&gt;
   &amp;lt;/metadata&amp;gt;&lt;br /&gt;
   &amp;lt;manifest&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/manifest&amp;gt;&lt;br /&gt;
   &amp;lt;spine&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/spine&amp;gt;&lt;br /&gt;
  &amp;lt;/package&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Importing=&lt;br /&gt;
&lt;br /&gt;
To import this record we need a fully featured import plug-in which is capable of handle both file and raw XML input, we are also going to use an XSLT plug-ins to make the process even easier. &lt;br /&gt;
&lt;br /&gt;
==The Files==&lt;br /&gt;
&lt;br /&gt;
We need the following:&lt;br /&gt;
&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Import/OPFXML.pm&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Import/XSLT/DC.xsl&lt;br /&gt;
&lt;br /&gt;
===OPFXML.pm===&lt;br /&gt;
&lt;br /&gt;
This will be our master import plug-in to handle the entire chunk of XML. We will then use the DC plug-in to map the metadata into an eprint we can use later. &lt;br /&gt;
&lt;br /&gt;
Since this is the master plug-in this requires quiet a sizeable amount of code:&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Import::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  # Declare Namespaces&lt;br /&gt;
  our $DC_NS = &amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;;&lt;br /&gt;
  our $DCTERMS_NS = &amp;quot;http://purl.org/dc/terms/&amp;quot;;&lt;br /&gt;
  our $OPF_NS = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # This is just a variant of the DefaultXML plug-in&lt;br /&gt;
  use EPrints::Plugin::Import::DefaultXML;&lt;br /&gt;
  &lt;br /&gt;
  our @ISA = qw/ EPrints::Plugin::Import::DefaultXML /;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;OPF Resource&amp;quot;;&lt;br /&gt;
        # Make it visible on the import menu and elsewhere&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{produce} = [ 'list/eprint', 'dataobj/eprint' ];&lt;br /&gt;
  &lt;br /&gt;
        # Functionality to recognise XML types on import by recognising the base namespace, works with the sword packaging format, dc:conformsTo or similar.&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $rc = EPrints::Utils::require_if_exists(&amp;quot;MIME::Types&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        unless( $rc )&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{visible} = &amp;quot;&amp;quot;;&lt;br /&gt;
                $self-&amp;gt;{error} = &amp;quot;Failed to load required module MIME::Types&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Input File Handle Method, for when files are uploaded&lt;br /&gt;
  sub input_fh&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $fh = $opts{&amp;quot;fh&amp;quot;};&lt;br /&gt;
  &lt;br /&gt;
        my $xml = join &amp;quot;&amp;quot;, &amp;lt;$fh&amp;gt;;&lt;br /&gt;
  &lt;br /&gt;
        my $list;&lt;br /&gt;
  &lt;br /&gt;
        if( $xml =~ /^&amp;lt;\?xml/ )&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_xml( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_list( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        $list ||= EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [] );&lt;br /&gt;
  &lt;br /&gt;
        return $list;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Handle direct XML input&lt;br /&gt;
  sub input_fh_xml&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $xml, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $doc = EPrints::XML::parse_xml_string( $xml );&lt;br /&gt;
  &lt;br /&gt;
        my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
        EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [defined($dataobj) ? $dataobj-&amp;gt;get_id : ()] );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Go grab input from a URL&lt;br /&gt;
  sub input_fh_list&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $url, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $url =~ s/\s+//g;&lt;br /&gt;
  &lt;br /&gt;
        my $tmpfile = File::Temp-&amp;gt;new;&lt;br /&gt;
  &lt;br /&gt;
        my $r = EPrints::Utils::wget( $plugin-&amp;gt;{session}, $url, $tmpfile );&lt;br /&gt;
        seek($tmpfile,0,0);&lt;br /&gt;
  &lt;br /&gt;
        if( $r-&amp;gt;is_error )&lt;br /&gt;
        {&lt;br /&gt;
                $plugin-&amp;gt;error( &amp;quot;Error reading resource from $url: &amp;quot;.$r-&amp;gt;code.&amp;quot; &amp;quot;.$r-&amp;gt;message );&lt;br /&gt;
                return;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        my @ids;&lt;br /&gt;
  &lt;br /&gt;
        while(my $url = &amp;lt;$tmpfile&amp;gt;)&lt;br /&gt;
        {&lt;br /&gt;
                $url =~ s/\s+//g;&lt;br /&gt;
                next unless $url =~ /^http/;&lt;br /&gt;
  &lt;br /&gt;
                my $doc;&lt;br /&gt;
                eval { $doc = EPrints::XML::parse_url( $url ) };&lt;br /&gt;
                if( $@ )&lt;br /&gt;
                {&lt;br /&gt;
                        $plugin-&amp;gt;warning( &amp;quot;Error parsing: $url\n&amp;quot; );&lt;br /&gt;
                }&lt;br /&gt;
  &lt;br /&gt;
                my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
                EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
                if( defined $dataobj )&lt;br /&gt;
                {&lt;br /&gt;
                        push @ids, $dataobj-&amp;gt;get_id;&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
          &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; \@ids );&lt;br /&gt;
  }&lt;br /&gt;
  # Translate this XML into an EPrint&lt;br /&gt;
  sub xml_to_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        # $xml is the PubmedArticle element&lt;br /&gt;
        my( $plugin, $dataset, $xml ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $session = $plugin-&amp;gt;{session};&lt;br /&gt;
  &lt;br /&gt;
        # Locate the metadata element&lt;br /&gt;
        my $metadata = $xml-&amp;gt;getElementsByTagNameNS( $OPF_NS, &amp;quot;metadata&amp;quot; )-&amp;gt;[0];&lt;br /&gt;
  &lt;br /&gt;
        # Load the DC plugin&lt;br /&gt;
        my $dc_plugin = $session-&amp;gt;plugin( &amp;quot;Import::XSLT::DC&amp;quot;,&lt;br /&gt;
                processor =&amp;gt; $plugin-&amp;gt;{processor},&lt;br /&gt;
                dataset =&amp;gt; $dataset,&lt;br /&gt;
        );&lt;br /&gt;
  &lt;br /&gt;
        $dc_plugin-&amp;gt;{Handler} = $plugin-&amp;gt;{Handler};&lt;br /&gt;
        $dc_plugin-&amp;gt;{parse_only} = $plugin-&amp;gt;{parse_only};&lt;br /&gt;
  &lt;br /&gt;
        # Spew the metadata element to a temp file&lt;br /&gt;
        my $tmpfile2 = File::Temp-&amp;gt;new;&lt;br /&gt;
        print $tmpfile2 $metadata-&amp;gt;toString();&lt;br /&gt;
        seek($tmpfile2,0,0);&lt;br /&gt;
  &lt;br /&gt;
        # Parse the file using the plug-in to get back a list of eprints&lt;br /&gt;
        my $list = $dc_plugin-&amp;gt;input_fh( fh =&amp;gt; $tmpfile2, dataset =&amp;gt; $dataset );&lt;br /&gt;
  &lt;br /&gt;
        my( $eprint ) = $list-&amp;gt;get_records( 0, 1 );&lt;br /&gt;
  &lt;br /&gt;
        return $eprint;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
===XSLT/DC.xsl===&lt;br /&gt;
&lt;br /&gt;
Using XSLT is really quiet a nice way of parsing data and well documented so I shouldn't have to say much about how this works here.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!-- DC Transformation --&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:stylesheet&lt;br /&gt;
        version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
        xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
        ept:name=&amp;quot;DC&amp;quot;&lt;br /&gt;
        ept:visible=&amp;quot;all&amp;quot;&lt;br /&gt;
        ept:advertise=&amp;quot;1&amp;quot;&lt;br /&gt;
        ept:sourceNamespace=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        ept:targetNamespace=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
        ept:produce=&amp;quot;list/eprint&amp;quot;&lt;br /&gt;
        xmlns:ept=&amp;quot;http://eprints.org/ep2/xslt/1.0&amp;quot;&lt;br /&gt;
        xmlns:oai_dc=&amp;quot;http://www.openarchives.org/OAI/2.0/oai_dc/&amp;quot;&lt;br /&gt;
        xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
        xmlns=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
  &amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; indent=&amp;quot;yes&amp;quot; encoding=&amp;quot;utf-8&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;eprints&amp;gt;&lt;br /&gt;
        &amp;lt;eprint&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;./*&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;eprint_status&amp;gt;inbox&amp;lt;/eprint_status&amp;gt;&lt;br /&gt;
        &amp;lt;creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:creator&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&amp;lt;name&amp;gt;&amp;lt;family/&amp;gt;&amp;lt;given&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot;/&amp;gt;&amp;lt;/given&amp;gt;&amp;lt;/name&amp;gt;&amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/creators&amp;gt;&lt;br /&gt;
        &amp;lt;corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:source&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&lt;br /&gt;
                        &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;keywords&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:subject&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;,&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/keywords&amp;gt;&lt;br /&gt;
        &amp;lt;/eprint&amp;gt;&lt;br /&gt;
        &amp;lt;/eprints&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:title&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:publisher&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;publisher&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/publisher&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:rights&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;copyright_holders&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/copyright_holders&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:date&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;date&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/date&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:identifier&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;id_number&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/id_number&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!--Ignored at this level--&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:language|dc:subject|dc:source|dc:creator&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
You can test your plug-ins by simply clicking on the &amp;quot;manage deposits&amp;quot; button in your toolbar and selecting &amp;quot;OPF Resource&amp;quot; from the drop down list of import plug-ins. If it doesn't appear restart you web server and check the error log!&lt;br /&gt;
&lt;br /&gt;
Reminder:&lt;br /&gt;
&lt;br /&gt;
  apache2ctl restart &amp;amp;&amp;amp; tail -f /var/log/apache2/error.log&lt;br /&gt;
&lt;br /&gt;
Once you have the import screen, copy and paste the XML from the top of this exercise into it and see if it creates you an EPrint (which you can see back at the manage deposits screen)&lt;br /&gt;
&lt;br /&gt;
=Exporting=&lt;br /&gt;
&lt;br /&gt;
So now we have imported our EPrint from this OPF format we need to be able to put it back into this format for exporting, this has the advantage that you can also export ALL other eprints in this format.&lt;br /&gt;
&lt;br /&gt;
We did most of the work on the importing so now it's your turn below is the basis of the Export plug-in which you can use to get started. To give you a clue this export plug-in needs to be located in lib/plugins/EPrints/Plugin/Export/OPFXML.pm&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Export::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Export::XMLFile;&lt;br /&gt;
  @ISA = ( &amp;quot;EPrints::Plugin::Export::XMLFile&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %opts ) = @_;&lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new( %opts );&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;Open Packaging Format XML&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # This plug-in can only output a single eprint record, no lists or other types of objects&lt;br /&gt;
        $self-&amp;gt;{accept} = [ 'dataobj/eprint' ];&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Specify the mimetype so we can use an HTTP ACCEPT header to get this back.&lt;br /&gt;
        $self-&amp;gt;{mimetype} = &amp;quot;application/oebps-package+xml; charset=utf-8&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Again specify what we are exporting&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{schemaLocation} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Method which is called to output the eprint, we would have output_list if we could handle lists&lt;br /&gt;
  sub output_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $dataobj ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $xml = $plugin-&amp;gt;xml_dataobj( $dataobj );&lt;br /&gt;
  &lt;br /&gt;
        return &amp;quot;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&amp;quot; . EPrints::XML::to_string( $xml );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The method which actually does the work&lt;br /&gt;
  sub xml_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $eprint ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repo = $plugin-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $package = $repo-&amp;gt;make_element(&amp;quot;package&amp;quot;, xmlns=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;unique-identifier&amp;quot;=&amp;gt;&amp;quot;EPB-UUID&amp;quot;, version=&amp;gt;&amp;quot;2.0&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        my $metadata = $repo-&amp;gt;make_element(&amp;quot;metadata&amp;quot;, &amp;quot;xmlns:opf&amp;quot;=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;xmlns:dc&amp;quot;=&amp;gt;&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;);&lt;br /&gt;
        $package-&amp;gt;appendChild($metadata);&lt;br /&gt;
  &lt;br /&gt;
        my $title = $repo-&amp;gt;make_element(&amp;quot;dc:title&amp;quot;);&lt;br /&gt;
        $title-&amp;gt;appendText($eprint-&amp;gt;value(&amp;quot;title&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        $metadata-&amp;gt;appendChild($title);&lt;br /&gt;
  &lt;br /&gt;
        if( $eprint-&amp;gt;exists_and_set( &amp;quot;creators&amp;quot; ) )&lt;br /&gt;
        {&lt;br /&gt;
                foreach my $name ( @{ $eprint-&amp;gt;get_value( &amp;quot;creators&amp;quot; ) } )&lt;br /&gt;
                {&lt;br /&gt;
                        # given name first&lt;br /&gt;
                        my $creator = $repo-&amp;gt;make_element(&amp;quot;dc:creator&amp;quot;);&lt;br /&gt;
                        $creator-&amp;gt;appendText(EPrints::Utils::make_name_string( $name-&amp;gt;{name}, 1 ));&lt;br /&gt;
                        $metadata-&amp;gt;appendChild($creator);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
        return $package;&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
'''Don't forget to add the line to enable the EXPORT::OPFXML in the packages config file'''&lt;br /&gt;
&lt;br /&gt;
This is no where near as complete as the original input from above, can you make the 2 match?&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
This is an easy one. &lt;br /&gt;
* Find the eprint you imported&lt;br /&gt;
* Click the Actions Tab&lt;br /&gt;
* Locate the Export options at the bottom of this tab&lt;br /&gt;
* Find your export plug-in (by name) and click it&lt;br /&gt;
&lt;br /&gt;
=Wrap it as a package=&lt;br /&gt;
&lt;br /&gt;
Once again, now this is working you want to remove the files and package them up with a spec file and icon. Then remove the files from your local install and try doing an install via the Bazaar to see if it works.&lt;br /&gt;
&lt;br /&gt;
Why not see the export plug-in working via a GET request to the id url of the eprint http://archive.org/id/eprint/XXX with the ACCEPT header set to the mime-type of your desired export plug-in. This is quick proof that content negotiation works in EPrints and it's that easy to add a new exporter.&lt;br /&gt;
&lt;br /&gt;
=Extension Exercises=&lt;br /&gt;
&lt;br /&gt;
This whole exercise has been the beginning of importing the epub format into EPrints!&lt;br /&gt;
&lt;br /&gt;
If you are feeling keen see if you can scope out or develop this further to import more of the format, maybe some of the chapters etc. &lt;br /&gt;
&lt;br /&gt;
The full epub for this book is available @ http://www.epubbooks.com/book/378/adventures-of-sherlock-holmes and you have been importing a small section of the epb.opf file which is listed in the META-INF/container.xml&lt;br /&gt;
&lt;br /&gt;
epub is a format we are keen to see EPrints support and there may be a bounty available for the first person to develop a complete Bazaar Package to support them.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9917</id>
		<title>Import and Export Plug-ins</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9917"/>
		<updated>2011-07-20T14:02:27Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Exporting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
Import and Export Plug-ins are all about taking an object, de-serialising it into an eprint (or other object in the EPrints system) and re-serialising it back into an object to be supported. &lt;br /&gt;
&lt;br /&gt;
We would typically advocate that every import plug-in should have a corresponding export plug-in and visa-versa.&lt;br /&gt;
&lt;br /&gt;
=Enable the Plugin's=&lt;br /&gt;
&lt;br /&gt;
Create the package directory that will contain the package's configuration file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/epm/io_exercise/cfg/cfg.d&lt;br /&gt;
&lt;br /&gt;
Create a configuration file that enables the plugins in this package - this file is copied into the repository when the package is enabled:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/epm/hello_world/cfg/cfg.d/io_exercise.pl&lt;br /&gt;
 &lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Import::OPFXML&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Import::XSLT::DC&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
&lt;br /&gt;
=Input Data=&lt;br /&gt;
&lt;br /&gt;
We are going to attempt to import the following XML record into our system. If you know the format of this record all the better else we'll leave it as a surprise for now.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;package xmlns=&amp;quot;http://www.idpf.org/2007/opf&amp;quot; unique-identifier=&amp;quot;EPB-UUID&amp;quot; version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;metadata xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
             xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;dc:title&amp;gt;The Adventures of Sherlock Holmes&amp;lt;/dc:title&amp;gt;&lt;br /&gt;
      &amp;lt;dc:creator opf:role=&amp;quot;aut&amp;quot; opf:file-as=&amp;quot;Doyle, Sir Arthur Conan&amp;quot;&amp;gt;Sir Arthur Conan Doyle&amp;lt;/dc:creator&amp;gt;&lt;br /&gt;
      &amp;lt;dc:publisher&amp;gt;epubBooks (www.epubbooks.com)&amp;lt;/dc:publisher&amp;gt;&lt;br /&gt;
      &amp;lt;dc:date opf:event=&amp;quot;epub-publication&amp;quot;&amp;gt;2010-06-15&amp;lt;/dc:date&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Crime/Detective&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Short Stories&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:source&amp;gt;Project Gutenberg&amp;lt;/dc:source&amp;gt;&lt;br /&gt;
      &amp;lt;dc:rights&amp;gt;&lt;br /&gt;
            Provided for free by epubBooks.com. Not for commercial use.&lt;br /&gt;
            This EPUB eBook is released under a Creative Commons (BY-NC-ND/3.0) Licence.&lt;br /&gt;
            Source text and images are in the Public Domain.&lt;br /&gt;
      &amp;lt;/dc:rights&amp;gt;&lt;br /&gt;
      &amp;lt;dc:identifier id=&amp;quot;EPB-UUID&amp;quot;&amp;gt;urn:uuid:FF946905-6C08-1014-90EA-E81F8523F0DC&amp;lt;/dc:identifier&amp;gt;&lt;br /&gt;
      &amp;lt;dc:language&amp;gt;en-gb&amp;lt;/dc:language&amp;gt;&lt;br /&gt;
   &amp;lt;/metadata&amp;gt;&lt;br /&gt;
   &amp;lt;manifest&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/manifest&amp;gt;&lt;br /&gt;
   &amp;lt;spine&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/spine&amp;gt;&lt;br /&gt;
  &amp;lt;/package&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Importing=&lt;br /&gt;
&lt;br /&gt;
To import this record we need a fully featured import plug-in which is capable of handle both file and raw XML input, we are also going to use an XSLT plug-ins to make the process even easier. &lt;br /&gt;
&lt;br /&gt;
==The Files==&lt;br /&gt;
&lt;br /&gt;
We need the following:&lt;br /&gt;
&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Import/OPFXML.pm&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Import/XSLT/DC.xsl&lt;br /&gt;
&lt;br /&gt;
===OPFXML.pm===&lt;br /&gt;
&lt;br /&gt;
This will be our master import plug-in to handle the entire chunk of XML. We will then use the DC plug-in to map the metadata into an eprint we can use later. &lt;br /&gt;
&lt;br /&gt;
Since this is the master plug-in this requires quiet a sizeable amount of code:&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Import::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  # Declare Namespaces&lt;br /&gt;
  our $DC_NS = &amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;;&lt;br /&gt;
  our $DCTERMS_NS = &amp;quot;http://purl.org/dc/terms/&amp;quot;;&lt;br /&gt;
  our $OPF_NS = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # This is just a variant of the DefaultXML plug-in&lt;br /&gt;
  use EPrints::Plugin::Import::DefaultXML;&lt;br /&gt;
  &lt;br /&gt;
  our @ISA = qw/ EPrints::Plugin::Import::DefaultXML /;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;OPF Resource&amp;quot;;&lt;br /&gt;
        # Make it visible on the import menu and elsewhere&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{produce} = [ 'list/eprint', 'dataobj/eprint' ];&lt;br /&gt;
  &lt;br /&gt;
        # Functionality to recognise XML types on import by recognising the base namespace, works with the sword packaging format, dc:conformsTo or similar.&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $rc = EPrints::Utils::require_if_exists(&amp;quot;MIME::Types&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        unless( $rc )&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{visible} = &amp;quot;&amp;quot;;&lt;br /&gt;
                $self-&amp;gt;{error} = &amp;quot;Failed to load required module MIME::Types&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Input File Handle Method, for when files are uploaded&lt;br /&gt;
  sub input_fh&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $fh = $opts{&amp;quot;fh&amp;quot;};&lt;br /&gt;
  &lt;br /&gt;
        my $xml = join &amp;quot;&amp;quot;, &amp;lt;$fh&amp;gt;;&lt;br /&gt;
  &lt;br /&gt;
        my $list;&lt;br /&gt;
  &lt;br /&gt;
        if( $xml =~ /^&amp;lt;\?xml/ )&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_xml( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_list( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        $list ||= EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [] );&lt;br /&gt;
  &lt;br /&gt;
        return $list;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Handle direct XML input&lt;br /&gt;
  sub input_fh_xml&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $xml, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $doc = EPrints::XML::parse_xml_string( $xml );&lt;br /&gt;
  &lt;br /&gt;
        my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
        EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [defined($dataobj) ? $dataobj-&amp;gt;get_id : ()] );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Go grab input from a URL&lt;br /&gt;
  sub input_fh_list&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $url, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $url =~ s/\s+//g;&lt;br /&gt;
  &lt;br /&gt;
        my $tmpfile = File::Temp-&amp;gt;new;&lt;br /&gt;
  &lt;br /&gt;
        my $r = EPrints::Utils::wget( $plugin-&amp;gt;{session}, $url, $tmpfile );&lt;br /&gt;
        seek($tmpfile,0,0);&lt;br /&gt;
  &lt;br /&gt;
        if( $r-&amp;gt;is_error )&lt;br /&gt;
        {&lt;br /&gt;
                $plugin-&amp;gt;error( &amp;quot;Error reading resource from $url: &amp;quot;.$r-&amp;gt;code.&amp;quot; &amp;quot;.$r-&amp;gt;message );&lt;br /&gt;
                return;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        my @ids;&lt;br /&gt;
  &lt;br /&gt;
        while(my $url = &amp;lt;$tmpfile&amp;gt;)&lt;br /&gt;
        {&lt;br /&gt;
                $url =~ s/\s+//g;&lt;br /&gt;
                next unless $url =~ /^http/;&lt;br /&gt;
  &lt;br /&gt;
                my $doc;&lt;br /&gt;
                eval { $doc = EPrints::XML::parse_url( $url ) };&lt;br /&gt;
                if( $@ )&lt;br /&gt;
                {&lt;br /&gt;
                        $plugin-&amp;gt;warning( &amp;quot;Error parsing: $url\n&amp;quot; );&lt;br /&gt;
                }&lt;br /&gt;
  &lt;br /&gt;
                my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
                EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
                if( defined $dataobj )&lt;br /&gt;
                {&lt;br /&gt;
                        push @ids, $dataobj-&amp;gt;get_id;&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
          &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; \@ids );&lt;br /&gt;
  }&lt;br /&gt;
  # Translate this XML into an EPrint&lt;br /&gt;
  sub xml_to_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        # $xml is the PubmedArticle element&lt;br /&gt;
        my( $plugin, $dataset, $xml ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $session = $plugin-&amp;gt;{session};&lt;br /&gt;
  &lt;br /&gt;
        # Locate the metadata element&lt;br /&gt;
        my $metadata = $xml-&amp;gt;getElementsByTagNameNS( $OPF_NS, &amp;quot;metadata&amp;quot; )-&amp;gt;[0];&lt;br /&gt;
  &lt;br /&gt;
        # Load the DC plugin&lt;br /&gt;
        my $dc_plugin = $session-&amp;gt;plugin( &amp;quot;Import::XSLT::DC&amp;quot;,&lt;br /&gt;
                processor =&amp;gt; $plugin-&amp;gt;{processor},&lt;br /&gt;
                dataset =&amp;gt; $dataset,&lt;br /&gt;
        );&lt;br /&gt;
  &lt;br /&gt;
        $dc_plugin-&amp;gt;{Handler} = $plugin-&amp;gt;{Handler};&lt;br /&gt;
        $dc_plugin-&amp;gt;{parse_only} = $plugin-&amp;gt;{parse_only};&lt;br /&gt;
  &lt;br /&gt;
        # Spew the metadata element to a temp file&lt;br /&gt;
        my $tmpfile2 = File::Temp-&amp;gt;new;&lt;br /&gt;
        print $tmpfile2 $metadata-&amp;gt;toString();&lt;br /&gt;
        seek($tmpfile2,0,0);&lt;br /&gt;
  &lt;br /&gt;
        # Parse the file using the plug-in to get back a list of eprints&lt;br /&gt;
        my $list = $dc_plugin-&amp;gt;input_fh( fh =&amp;gt; $tmpfile2, dataset =&amp;gt; $dataset );&lt;br /&gt;
  &lt;br /&gt;
        my( $eprint ) = $list-&amp;gt;get_records( 0, 1 );&lt;br /&gt;
  &lt;br /&gt;
        return $eprint;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
===XSLT/DC.xsl===&lt;br /&gt;
&lt;br /&gt;
Using XSLT is really quiet a nice way of parsing data and well documented so I shouldn't have to say much about how this works here.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!-- DC Transformation --&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:stylesheet&lt;br /&gt;
        version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
        xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
        ept:name=&amp;quot;DC&amp;quot;&lt;br /&gt;
        ept:visible=&amp;quot;all&amp;quot;&lt;br /&gt;
        ept:advertise=&amp;quot;1&amp;quot;&lt;br /&gt;
        ept:sourceNamespace=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        ept:targetNamespace=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
        ept:produce=&amp;quot;list/eprint&amp;quot;&lt;br /&gt;
        xmlns:ept=&amp;quot;http://eprints.org/ep2/xslt/1.0&amp;quot;&lt;br /&gt;
        xmlns:oai_dc=&amp;quot;http://www.openarchives.org/OAI/2.0/oai_dc/&amp;quot;&lt;br /&gt;
        xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
        xmlns=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
  &amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; indent=&amp;quot;yes&amp;quot; encoding=&amp;quot;utf-8&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;eprints&amp;gt;&lt;br /&gt;
        &amp;lt;eprint&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;./*&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;eprint_status&amp;gt;inbox&amp;lt;/eprint_status&amp;gt;&lt;br /&gt;
        &amp;lt;creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:creator&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&amp;lt;name&amp;gt;&amp;lt;family/&amp;gt;&amp;lt;given&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot;/&amp;gt;&amp;lt;/given&amp;gt;&amp;lt;/name&amp;gt;&amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/creators&amp;gt;&lt;br /&gt;
        &amp;lt;corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:source&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&lt;br /&gt;
                        &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;keywords&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:subject&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;,&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/keywords&amp;gt;&lt;br /&gt;
        &amp;lt;/eprint&amp;gt;&lt;br /&gt;
        &amp;lt;/eprints&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:title&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:publisher&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;publisher&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/publisher&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:rights&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;copyright_holders&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/copyright_holders&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:date&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;date&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/date&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:identifier&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;id_number&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/id_number&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!--Ignored at this level--&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:language|dc:subject|dc:source|dc:creator&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
You can test your plug-ins by simply clicking on the &amp;quot;manage deposits&amp;quot; button in your toolbar and selecting &amp;quot;OPF Resource&amp;quot; from the drop down list of import plug-ins. If it doesn't appear restart you web server and check the error log!&lt;br /&gt;
&lt;br /&gt;
Reminder:&lt;br /&gt;
&lt;br /&gt;
  apache2ctl restart &amp;amp;&amp;amp; tail -f /var/log/apache2/error.log&lt;br /&gt;
&lt;br /&gt;
Once you have the import screen, copy and paste the XML from the top of this exercise into it and see if it creates you an EPrint (which you can see back at the manage deposits screen)&lt;br /&gt;
&lt;br /&gt;
=Exporting=&lt;br /&gt;
&lt;br /&gt;
So now we have imported our EPrint from this OPF format we need to be able to put it back into this format for exporting, this has the advantage that you can also export ALL other eprints in this format.&lt;br /&gt;
&lt;br /&gt;
We did most of the work on the importing so now it's your turn below is the basis of the Export plug-in which you can use to get started. To give you a clue this export plug-in needs to be located in cfg/plugins/EPrints/Plugin/Export/OPFXML.pm&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Export::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Export::XMLFile;&lt;br /&gt;
  @ISA = ( &amp;quot;EPrints::Plugin::Export::XMLFile&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %opts ) = @_;&lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new( %opts );&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;Open Packaging Format XML&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # This plug-in can only output a single eprint record, no lists or other types of objects&lt;br /&gt;
        $self-&amp;gt;{accept} = [ 'dataobj/eprint' ];&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Specify the mimetype so we can use an HTTP ACCEPT header to get this back.&lt;br /&gt;
        $self-&amp;gt;{mimetype} = &amp;quot;application/oebps-package+xml; charset=utf-8&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Again specify what we are exporting&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{schemaLocation} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Method which is called to output the eprint, we would have output_list if we could handle lists&lt;br /&gt;
  sub output_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $dataobj ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $xml = $plugin-&amp;gt;xml_dataobj( $dataobj );&lt;br /&gt;
  &lt;br /&gt;
        return &amp;quot;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&amp;quot; . EPrints::XML::to_string( $xml );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The method which actually does the work&lt;br /&gt;
  sub xml_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $eprint ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repo = $plugin-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $package = $repo-&amp;gt;make_element(&amp;quot;package&amp;quot;, xmlns=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;unique-identifier&amp;quot;=&amp;gt;&amp;quot;EPB-UUID&amp;quot;, version=&amp;gt;&amp;quot;2.0&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        my $metadata = $repo-&amp;gt;make_element(&amp;quot;metadata&amp;quot;, &amp;quot;xmlns:opf&amp;quot;=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;xmlns:dc&amp;quot;=&amp;gt;&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;);&lt;br /&gt;
        $package-&amp;gt;appendChild($metadata);&lt;br /&gt;
  &lt;br /&gt;
        my $title = $repo-&amp;gt;make_element(&amp;quot;dc:title&amp;quot;);&lt;br /&gt;
        $title-&amp;gt;appendText($eprint-&amp;gt;value(&amp;quot;title&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        $metadata-&amp;gt;appendChild($title);&lt;br /&gt;
  &lt;br /&gt;
        if( $eprint-&amp;gt;exists_and_set( &amp;quot;creators&amp;quot; ) )&lt;br /&gt;
        {&lt;br /&gt;
                foreach my $name ( @{ $eprint-&amp;gt;get_value( &amp;quot;creators&amp;quot; ) } )&lt;br /&gt;
                {&lt;br /&gt;
                        # given name first&lt;br /&gt;
                        my $creator = $repo-&amp;gt;make_element(&amp;quot;dc:creator&amp;quot;);&lt;br /&gt;
                        $creator-&amp;gt;appendText(EPrints::Utils::make_name_string( $name-&amp;gt;{name}, 1 ));&lt;br /&gt;
                        $metadata-&amp;gt;appendChild($creator);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
        return $package;&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
'''Don't forget to add the line to enable the EXPORT::OPFXML in the packages config file'''&lt;br /&gt;
&lt;br /&gt;
This is no where near as complete as the original input from above, can you make the 2 match?&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
This is an easy one. &lt;br /&gt;
* Find the eprint you imported&lt;br /&gt;
* Click the Actions Tab&lt;br /&gt;
* Locate the Export options at the bottom of this tab&lt;br /&gt;
* Find your export plug-in (by name) and click it&lt;br /&gt;
&lt;br /&gt;
=Wrap it as a package=&lt;br /&gt;
&lt;br /&gt;
Once again, now this is working you want to remove the files and package them up with a spec file and icon. Then remove the files from your local install and try doing an install via the Bazaar to see if it works.&lt;br /&gt;
&lt;br /&gt;
Why not see the export plug-in working via a GET request to the id url of the eprint http://archive.org/id/eprint/XXX with the ACCEPT header set to the mime-type of your desired export plug-in. This is quick proof that content negotiation works in EPrints and it's that easy to add a new exporter.&lt;br /&gt;
&lt;br /&gt;
=Extension Exercises=&lt;br /&gt;
&lt;br /&gt;
This whole exercise has been the beginning of importing the epub format into EPrints!&lt;br /&gt;
&lt;br /&gt;
If you are feeling keen see if you can scope out or develop this further to import more of the format, maybe some of the chapters etc. &lt;br /&gt;
&lt;br /&gt;
The full epub for this book is available @ http://www.epubbooks.com/book/378/adventures-of-sherlock-holmes and you have been importing a small section of the epb.opf file which is listed in the META-INF/container.xml&lt;br /&gt;
&lt;br /&gt;
epub is a format we are keen to see EPrints support and there may be a bounty available for the first person to develop a complete Bazaar Package to support them.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9916</id>
		<title>Import and Export Plug-ins</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9916"/>
		<updated>2011-07-20T14:01:27Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Enable the Plugin's */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
Import and Export Plug-ins are all about taking an object, de-serialising it into an eprint (or other object in the EPrints system) and re-serialising it back into an object to be supported. &lt;br /&gt;
&lt;br /&gt;
We would typically advocate that every import plug-in should have a corresponding export plug-in and visa-versa.&lt;br /&gt;
&lt;br /&gt;
=Enable the Plugin's=&lt;br /&gt;
&lt;br /&gt;
Create the package directory that will contain the package's configuration file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/epm/io_exercise/cfg/cfg.d&lt;br /&gt;
&lt;br /&gt;
Create a configuration file that enables the plugins in this package - this file is copied into the repository when the package is enabled:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/epm/hello_world/cfg/cfg.d/io_exercise.pl&lt;br /&gt;
 &lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Import::OPFXML&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Import::XSLT::DC&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
&lt;br /&gt;
=Input Data=&lt;br /&gt;
&lt;br /&gt;
We are going to attempt to import the following XML record into our system. If you know the format of this record all the better else we'll leave it as a surprise for now.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;package xmlns=&amp;quot;http://www.idpf.org/2007/opf&amp;quot; unique-identifier=&amp;quot;EPB-UUID&amp;quot; version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;metadata xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
             xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;dc:title&amp;gt;The Adventures of Sherlock Holmes&amp;lt;/dc:title&amp;gt;&lt;br /&gt;
      &amp;lt;dc:creator opf:role=&amp;quot;aut&amp;quot; opf:file-as=&amp;quot;Doyle, Sir Arthur Conan&amp;quot;&amp;gt;Sir Arthur Conan Doyle&amp;lt;/dc:creator&amp;gt;&lt;br /&gt;
      &amp;lt;dc:publisher&amp;gt;epubBooks (www.epubbooks.com)&amp;lt;/dc:publisher&amp;gt;&lt;br /&gt;
      &amp;lt;dc:date opf:event=&amp;quot;epub-publication&amp;quot;&amp;gt;2010-06-15&amp;lt;/dc:date&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Crime/Detective&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Short Stories&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:source&amp;gt;Project Gutenberg&amp;lt;/dc:source&amp;gt;&lt;br /&gt;
      &amp;lt;dc:rights&amp;gt;&lt;br /&gt;
            Provided for free by epubBooks.com. Not for commercial use.&lt;br /&gt;
            This EPUB eBook is released under a Creative Commons (BY-NC-ND/3.0) Licence.&lt;br /&gt;
            Source text and images are in the Public Domain.&lt;br /&gt;
      &amp;lt;/dc:rights&amp;gt;&lt;br /&gt;
      &amp;lt;dc:identifier id=&amp;quot;EPB-UUID&amp;quot;&amp;gt;urn:uuid:FF946905-6C08-1014-90EA-E81F8523F0DC&amp;lt;/dc:identifier&amp;gt;&lt;br /&gt;
      &amp;lt;dc:language&amp;gt;en-gb&amp;lt;/dc:language&amp;gt;&lt;br /&gt;
   &amp;lt;/metadata&amp;gt;&lt;br /&gt;
   &amp;lt;manifest&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/manifest&amp;gt;&lt;br /&gt;
   &amp;lt;spine&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/spine&amp;gt;&lt;br /&gt;
  &amp;lt;/package&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Importing=&lt;br /&gt;
&lt;br /&gt;
To import this record we need a fully featured import plug-in which is capable of handle both file and raw XML input, we are also going to use an XSLT plug-ins to make the process even easier. &lt;br /&gt;
&lt;br /&gt;
==The Files==&lt;br /&gt;
&lt;br /&gt;
We need the following:&lt;br /&gt;
&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Import/OPFXML.pm&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Import/XSLT/DC.xsl&lt;br /&gt;
&lt;br /&gt;
===OPFXML.pm===&lt;br /&gt;
&lt;br /&gt;
This will be our master import plug-in to handle the entire chunk of XML. We will then use the DC plug-in to map the metadata into an eprint we can use later. &lt;br /&gt;
&lt;br /&gt;
Since this is the master plug-in this requires quiet a sizeable amount of code:&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Import::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  # Declare Namespaces&lt;br /&gt;
  our $DC_NS = &amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;;&lt;br /&gt;
  our $DCTERMS_NS = &amp;quot;http://purl.org/dc/terms/&amp;quot;;&lt;br /&gt;
  our $OPF_NS = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # This is just a variant of the DefaultXML plug-in&lt;br /&gt;
  use EPrints::Plugin::Import::DefaultXML;&lt;br /&gt;
  &lt;br /&gt;
  our @ISA = qw/ EPrints::Plugin::Import::DefaultXML /;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;OPF Resource&amp;quot;;&lt;br /&gt;
        # Make it visible on the import menu and elsewhere&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{produce} = [ 'list/eprint', 'dataobj/eprint' ];&lt;br /&gt;
  &lt;br /&gt;
        # Functionality to recognise XML types on import by recognising the base namespace, works with the sword packaging format, dc:conformsTo or similar.&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $rc = EPrints::Utils::require_if_exists(&amp;quot;MIME::Types&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        unless( $rc )&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{visible} = &amp;quot;&amp;quot;;&lt;br /&gt;
                $self-&amp;gt;{error} = &amp;quot;Failed to load required module MIME::Types&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Input File Handle Method, for when files are uploaded&lt;br /&gt;
  sub input_fh&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $fh = $opts{&amp;quot;fh&amp;quot;};&lt;br /&gt;
  &lt;br /&gt;
        my $xml = join &amp;quot;&amp;quot;, &amp;lt;$fh&amp;gt;;&lt;br /&gt;
  &lt;br /&gt;
        my $list;&lt;br /&gt;
  &lt;br /&gt;
        if( $xml =~ /^&amp;lt;\?xml/ )&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_xml( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_list( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        $list ||= EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [] );&lt;br /&gt;
  &lt;br /&gt;
        return $list;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Handle direct XML input&lt;br /&gt;
  sub input_fh_xml&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $xml, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $doc = EPrints::XML::parse_xml_string( $xml );&lt;br /&gt;
  &lt;br /&gt;
        my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
        EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [defined($dataobj) ? $dataobj-&amp;gt;get_id : ()] );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Go grab input from a URL&lt;br /&gt;
  sub input_fh_list&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $url, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $url =~ s/\s+//g;&lt;br /&gt;
  &lt;br /&gt;
        my $tmpfile = File::Temp-&amp;gt;new;&lt;br /&gt;
  &lt;br /&gt;
        my $r = EPrints::Utils::wget( $plugin-&amp;gt;{session}, $url, $tmpfile );&lt;br /&gt;
        seek($tmpfile,0,0);&lt;br /&gt;
  &lt;br /&gt;
        if( $r-&amp;gt;is_error )&lt;br /&gt;
        {&lt;br /&gt;
                $plugin-&amp;gt;error( &amp;quot;Error reading resource from $url: &amp;quot;.$r-&amp;gt;code.&amp;quot; &amp;quot;.$r-&amp;gt;message );&lt;br /&gt;
                return;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        my @ids;&lt;br /&gt;
  &lt;br /&gt;
        while(my $url = &amp;lt;$tmpfile&amp;gt;)&lt;br /&gt;
        {&lt;br /&gt;
                $url =~ s/\s+//g;&lt;br /&gt;
                next unless $url =~ /^http/;&lt;br /&gt;
  &lt;br /&gt;
                my $doc;&lt;br /&gt;
                eval { $doc = EPrints::XML::parse_url( $url ) };&lt;br /&gt;
                if( $@ )&lt;br /&gt;
                {&lt;br /&gt;
                        $plugin-&amp;gt;warning( &amp;quot;Error parsing: $url\n&amp;quot; );&lt;br /&gt;
                }&lt;br /&gt;
  &lt;br /&gt;
                my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
                EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
                if( defined $dataobj )&lt;br /&gt;
                {&lt;br /&gt;
                        push @ids, $dataobj-&amp;gt;get_id;&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
          &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; \@ids );&lt;br /&gt;
  }&lt;br /&gt;
  # Translate this XML into an EPrint&lt;br /&gt;
  sub xml_to_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        # $xml is the PubmedArticle element&lt;br /&gt;
        my( $plugin, $dataset, $xml ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $session = $plugin-&amp;gt;{session};&lt;br /&gt;
  &lt;br /&gt;
        # Locate the metadata element&lt;br /&gt;
        my $metadata = $xml-&amp;gt;getElementsByTagNameNS( $OPF_NS, &amp;quot;metadata&amp;quot; )-&amp;gt;[0];&lt;br /&gt;
  &lt;br /&gt;
        # Load the DC plugin&lt;br /&gt;
        my $dc_plugin = $session-&amp;gt;plugin( &amp;quot;Import::XSLT::DC&amp;quot;,&lt;br /&gt;
                processor =&amp;gt; $plugin-&amp;gt;{processor},&lt;br /&gt;
                dataset =&amp;gt; $dataset,&lt;br /&gt;
        );&lt;br /&gt;
  &lt;br /&gt;
        $dc_plugin-&amp;gt;{Handler} = $plugin-&amp;gt;{Handler};&lt;br /&gt;
        $dc_plugin-&amp;gt;{parse_only} = $plugin-&amp;gt;{parse_only};&lt;br /&gt;
  &lt;br /&gt;
        # Spew the metadata element to a temp file&lt;br /&gt;
        my $tmpfile2 = File::Temp-&amp;gt;new;&lt;br /&gt;
        print $tmpfile2 $metadata-&amp;gt;toString();&lt;br /&gt;
        seek($tmpfile2,0,0);&lt;br /&gt;
  &lt;br /&gt;
        # Parse the file using the plug-in to get back a list of eprints&lt;br /&gt;
        my $list = $dc_plugin-&amp;gt;input_fh( fh =&amp;gt; $tmpfile2, dataset =&amp;gt; $dataset );&lt;br /&gt;
  &lt;br /&gt;
        my( $eprint ) = $list-&amp;gt;get_records( 0, 1 );&lt;br /&gt;
  &lt;br /&gt;
        return $eprint;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
===XSLT/DC.xsl===&lt;br /&gt;
&lt;br /&gt;
Using XSLT is really quiet a nice way of parsing data and well documented so I shouldn't have to say much about how this works here.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!-- DC Transformation --&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:stylesheet&lt;br /&gt;
        version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
        xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
        ept:name=&amp;quot;DC&amp;quot;&lt;br /&gt;
        ept:visible=&amp;quot;all&amp;quot;&lt;br /&gt;
        ept:advertise=&amp;quot;1&amp;quot;&lt;br /&gt;
        ept:sourceNamespace=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        ept:targetNamespace=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
        ept:produce=&amp;quot;list/eprint&amp;quot;&lt;br /&gt;
        xmlns:ept=&amp;quot;http://eprints.org/ep2/xslt/1.0&amp;quot;&lt;br /&gt;
        xmlns:oai_dc=&amp;quot;http://www.openarchives.org/OAI/2.0/oai_dc/&amp;quot;&lt;br /&gt;
        xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
        xmlns=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
  &amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; indent=&amp;quot;yes&amp;quot; encoding=&amp;quot;utf-8&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;eprints&amp;gt;&lt;br /&gt;
        &amp;lt;eprint&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;./*&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;eprint_status&amp;gt;inbox&amp;lt;/eprint_status&amp;gt;&lt;br /&gt;
        &amp;lt;creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:creator&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&amp;lt;name&amp;gt;&amp;lt;family/&amp;gt;&amp;lt;given&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot;/&amp;gt;&amp;lt;/given&amp;gt;&amp;lt;/name&amp;gt;&amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/creators&amp;gt;&lt;br /&gt;
        &amp;lt;corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:source&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&lt;br /&gt;
                        &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;keywords&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:subject&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;,&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/keywords&amp;gt;&lt;br /&gt;
        &amp;lt;/eprint&amp;gt;&lt;br /&gt;
        &amp;lt;/eprints&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:title&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:publisher&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;publisher&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/publisher&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:rights&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;copyright_holders&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/copyright_holders&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:date&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;date&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/date&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:identifier&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;id_number&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/id_number&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!--Ignored at this level--&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:language|dc:subject|dc:source|dc:creator&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
You can test your plug-ins by simply clicking on the &amp;quot;manage deposits&amp;quot; button in your toolbar and selecting &amp;quot;OPF Resource&amp;quot; from the drop down list of import plug-ins. If it doesn't appear restart you web server and check the error log!&lt;br /&gt;
&lt;br /&gt;
Reminder:&lt;br /&gt;
&lt;br /&gt;
  apache2ctl restart &amp;amp;&amp;amp; tail -f /var/log/apache2/error.log&lt;br /&gt;
&lt;br /&gt;
Once you have the import screen, copy and paste the XML from the top of this exercise into it and see if it creates you an EPrint (which you can see back at the manage deposits screen)&lt;br /&gt;
&lt;br /&gt;
=Exporting=&lt;br /&gt;
&lt;br /&gt;
So now we have imported our EPrint from this OPF format we need to be able to put it back into this format for exporting, this has the advantage that you can also export ALL other eprints in this format.&lt;br /&gt;
&lt;br /&gt;
We did most of the work on the importing so now it's your turn below is the basis of the Export plug-in which you can use to get started. To give you a clue this export plug-in needs to be located in cfg/plugins/EPrints/Plugin/Export/OPFXML.pm&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Export::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Export::XMLFile;&lt;br /&gt;
  @ISA = ( &amp;quot;EPrints::Plugin::Export::XMLFile&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %opts ) = @_;&lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new( %opts );&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;Open Packaging Format XML&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # This plug-in can only output a single eprint record, no lists or other types of objects&lt;br /&gt;
        $self-&amp;gt;{accept} = [ 'dataobj/eprint' ];&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Specify the mimetype so we can use an HTTP ACCEPT header to get this back.&lt;br /&gt;
        $self-&amp;gt;{mimetype} = &amp;quot;application/oebps-package+xml; charset=utf-8&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Again specify what we are exporting&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{schemaLocation} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Method which is called to output the eprint, we would have output_list if we could handle lists&lt;br /&gt;
  sub output_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $dataobj ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $xml = $plugin-&amp;gt;xml_dataobj( $dataobj );&lt;br /&gt;
  &lt;br /&gt;
        return &amp;quot;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&amp;quot; . EPrints::XML::to_string( $xml );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The method which actually does the work&lt;br /&gt;
  sub xml_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $eprint ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repo = $plugin-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $package = $repo-&amp;gt;make_element(&amp;quot;package&amp;quot;, xmlns=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;unique-identifier&amp;quot;=&amp;gt;&amp;quot;EPB-UUID&amp;quot;, version=&amp;gt;&amp;quot;2.0&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        my $metadata = $repo-&amp;gt;make_element(&amp;quot;metadata&amp;quot;, &amp;quot;xmlns:opf&amp;quot;=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;xmlns:dc&amp;quot;=&amp;gt;&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;);&lt;br /&gt;
        $package-&amp;gt;appendChild($metadata);&lt;br /&gt;
  &lt;br /&gt;
        my $title = $repo-&amp;gt;make_element(&amp;quot;dc:title&amp;quot;);&lt;br /&gt;
        $title-&amp;gt;appendText($eprint-&amp;gt;value(&amp;quot;title&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        $metadata-&amp;gt;appendChild($title);&lt;br /&gt;
  &lt;br /&gt;
        if( $eprint-&amp;gt;exists_and_set( &amp;quot;creators&amp;quot; ) )&lt;br /&gt;
        {&lt;br /&gt;
                foreach my $name ( @{ $eprint-&amp;gt;get_value( &amp;quot;creators&amp;quot; ) } )&lt;br /&gt;
                {&lt;br /&gt;
                        # given name first&lt;br /&gt;
                        my $creator = $repo-&amp;gt;make_element(&amp;quot;dc:creator&amp;quot;);&lt;br /&gt;
                        $creator-&amp;gt;appendText(EPrints::Utils::make_name_string( $name-&amp;gt;{name}, 1 ));&lt;br /&gt;
                        $metadata-&amp;gt;appendChild($creator);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
        return $package;&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
This is no where near as complete as the original input from above, can you make the 2 match?&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
This is an easy one. &lt;br /&gt;
* Find the eprint you imported&lt;br /&gt;
* Click the Actions Tab&lt;br /&gt;
* Locate the Export options at the bottom of this tab&lt;br /&gt;
* Find your export plug-in (by name) and click it&lt;br /&gt;
&lt;br /&gt;
=Wrap it as a package=&lt;br /&gt;
&lt;br /&gt;
Once again, now this is working you want to remove the files and package them up with a spec file and icon. Then remove the files from your local install and try doing an install via the Bazaar to see if it works.&lt;br /&gt;
&lt;br /&gt;
Why not see the export plug-in working via a GET request to the id url of the eprint http://archive.org/id/eprint/XXX with the ACCEPT header set to the mime-type of your desired export plug-in. This is quick proof that content negotiation works in EPrints and it's that easy to add a new exporter.&lt;br /&gt;
&lt;br /&gt;
=Extension Exercises=&lt;br /&gt;
&lt;br /&gt;
This whole exercise has been the beginning of importing the epub format into EPrints!&lt;br /&gt;
&lt;br /&gt;
If you are feeling keen see if you can scope out or develop this further to import more of the format, maybe some of the chapters etc. &lt;br /&gt;
&lt;br /&gt;
The full epub for this book is available @ http://www.epubbooks.com/book/378/adventures-of-sherlock-holmes and you have been importing a small section of the epb.opf file which is listed in the META-INF/container.xml&lt;br /&gt;
&lt;br /&gt;
epub is a format we are keen to see EPrints support and there may be a bounty available for the first person to develop a complete Bazaar Package to support them.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9915</id>
		<title>Import and Export Plug-ins</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9915"/>
		<updated>2011-07-20T14:01:16Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
Import and Export Plug-ins are all about taking an object, de-serialising it into an eprint (or other object in the EPrints system) and re-serialising it back into an object to be supported. &lt;br /&gt;
&lt;br /&gt;
We would typically advocate that every import plug-in should have a corresponding export plug-in and visa-versa.&lt;br /&gt;
&lt;br /&gt;
=Enable the Plugin's=&lt;br /&gt;
&lt;br /&gt;
Create the package directory that will contain the package's configuration file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/epm/io_exercise/cfg/cfg.d&lt;br /&gt;
&lt;br /&gt;
Create a configuration file that enables the plugins in this package - this file is copied into the repository when the package is enabled:&lt;br /&gt;
&lt;br /&gt;
  $ gedit lib/epm/hello_world/cfg/cfg.d/io_exercise.pl&lt;br /&gt;
  &lt;br /&gt;
  $c-&amp;gt;{plugins}{&amp;quot;Import::OPFXML&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
  $c-&amp;gt;{plugins}{&amp;quot;Import::XSLT::DC&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
&lt;br /&gt;
=Input Data=&lt;br /&gt;
&lt;br /&gt;
We are going to attempt to import the following XML record into our system. If you know the format of this record all the better else we'll leave it as a surprise for now.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;package xmlns=&amp;quot;http://www.idpf.org/2007/opf&amp;quot; unique-identifier=&amp;quot;EPB-UUID&amp;quot; version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;metadata xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
             xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;dc:title&amp;gt;The Adventures of Sherlock Holmes&amp;lt;/dc:title&amp;gt;&lt;br /&gt;
      &amp;lt;dc:creator opf:role=&amp;quot;aut&amp;quot; opf:file-as=&amp;quot;Doyle, Sir Arthur Conan&amp;quot;&amp;gt;Sir Arthur Conan Doyle&amp;lt;/dc:creator&amp;gt;&lt;br /&gt;
      &amp;lt;dc:publisher&amp;gt;epubBooks (www.epubbooks.com)&amp;lt;/dc:publisher&amp;gt;&lt;br /&gt;
      &amp;lt;dc:date opf:event=&amp;quot;epub-publication&amp;quot;&amp;gt;2010-06-15&amp;lt;/dc:date&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Crime/Detective&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Short Stories&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:source&amp;gt;Project Gutenberg&amp;lt;/dc:source&amp;gt;&lt;br /&gt;
      &amp;lt;dc:rights&amp;gt;&lt;br /&gt;
            Provided for free by epubBooks.com. Not for commercial use.&lt;br /&gt;
            This EPUB eBook is released under a Creative Commons (BY-NC-ND/3.0) Licence.&lt;br /&gt;
            Source text and images are in the Public Domain.&lt;br /&gt;
      &amp;lt;/dc:rights&amp;gt;&lt;br /&gt;
      &amp;lt;dc:identifier id=&amp;quot;EPB-UUID&amp;quot;&amp;gt;urn:uuid:FF946905-6C08-1014-90EA-E81F8523F0DC&amp;lt;/dc:identifier&amp;gt;&lt;br /&gt;
      &amp;lt;dc:language&amp;gt;en-gb&amp;lt;/dc:language&amp;gt;&lt;br /&gt;
   &amp;lt;/metadata&amp;gt;&lt;br /&gt;
   &amp;lt;manifest&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/manifest&amp;gt;&lt;br /&gt;
   &amp;lt;spine&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/spine&amp;gt;&lt;br /&gt;
  &amp;lt;/package&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Importing=&lt;br /&gt;
&lt;br /&gt;
To import this record we need a fully featured import plug-in which is capable of handle both file and raw XML input, we are also going to use an XSLT plug-ins to make the process even easier. &lt;br /&gt;
&lt;br /&gt;
==The Files==&lt;br /&gt;
&lt;br /&gt;
We need the following:&lt;br /&gt;
&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Import/OPFXML.pm&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Import/XSLT/DC.xsl&lt;br /&gt;
&lt;br /&gt;
===OPFXML.pm===&lt;br /&gt;
&lt;br /&gt;
This will be our master import plug-in to handle the entire chunk of XML. We will then use the DC plug-in to map the metadata into an eprint we can use later. &lt;br /&gt;
&lt;br /&gt;
Since this is the master plug-in this requires quiet a sizeable amount of code:&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Import::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  # Declare Namespaces&lt;br /&gt;
  our $DC_NS = &amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;;&lt;br /&gt;
  our $DCTERMS_NS = &amp;quot;http://purl.org/dc/terms/&amp;quot;;&lt;br /&gt;
  our $OPF_NS = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # This is just a variant of the DefaultXML plug-in&lt;br /&gt;
  use EPrints::Plugin::Import::DefaultXML;&lt;br /&gt;
  &lt;br /&gt;
  our @ISA = qw/ EPrints::Plugin::Import::DefaultXML /;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;OPF Resource&amp;quot;;&lt;br /&gt;
        # Make it visible on the import menu and elsewhere&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{produce} = [ 'list/eprint', 'dataobj/eprint' ];&lt;br /&gt;
  &lt;br /&gt;
        # Functionality to recognise XML types on import by recognising the base namespace, works with the sword packaging format, dc:conformsTo or similar.&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $rc = EPrints::Utils::require_if_exists(&amp;quot;MIME::Types&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        unless( $rc )&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{visible} = &amp;quot;&amp;quot;;&lt;br /&gt;
                $self-&amp;gt;{error} = &amp;quot;Failed to load required module MIME::Types&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Input File Handle Method, for when files are uploaded&lt;br /&gt;
  sub input_fh&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $fh = $opts{&amp;quot;fh&amp;quot;};&lt;br /&gt;
  &lt;br /&gt;
        my $xml = join &amp;quot;&amp;quot;, &amp;lt;$fh&amp;gt;;&lt;br /&gt;
  &lt;br /&gt;
        my $list;&lt;br /&gt;
  &lt;br /&gt;
        if( $xml =~ /^&amp;lt;\?xml/ )&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_xml( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_list( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        $list ||= EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [] );&lt;br /&gt;
  &lt;br /&gt;
        return $list;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Handle direct XML input&lt;br /&gt;
  sub input_fh_xml&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $xml, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $doc = EPrints::XML::parse_xml_string( $xml );&lt;br /&gt;
  &lt;br /&gt;
        my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
        EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [defined($dataobj) ? $dataobj-&amp;gt;get_id : ()] );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Go grab input from a URL&lt;br /&gt;
  sub input_fh_list&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $url, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $url =~ s/\s+//g;&lt;br /&gt;
  &lt;br /&gt;
        my $tmpfile = File::Temp-&amp;gt;new;&lt;br /&gt;
  &lt;br /&gt;
        my $r = EPrints::Utils::wget( $plugin-&amp;gt;{session}, $url, $tmpfile );&lt;br /&gt;
        seek($tmpfile,0,0);&lt;br /&gt;
  &lt;br /&gt;
        if( $r-&amp;gt;is_error )&lt;br /&gt;
        {&lt;br /&gt;
                $plugin-&amp;gt;error( &amp;quot;Error reading resource from $url: &amp;quot;.$r-&amp;gt;code.&amp;quot; &amp;quot;.$r-&amp;gt;message );&lt;br /&gt;
                return;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        my @ids;&lt;br /&gt;
  &lt;br /&gt;
        while(my $url = &amp;lt;$tmpfile&amp;gt;)&lt;br /&gt;
        {&lt;br /&gt;
                $url =~ s/\s+//g;&lt;br /&gt;
                next unless $url =~ /^http/;&lt;br /&gt;
  &lt;br /&gt;
                my $doc;&lt;br /&gt;
                eval { $doc = EPrints::XML::parse_url( $url ) };&lt;br /&gt;
                if( $@ )&lt;br /&gt;
                {&lt;br /&gt;
                        $plugin-&amp;gt;warning( &amp;quot;Error parsing: $url\n&amp;quot; );&lt;br /&gt;
                }&lt;br /&gt;
  &lt;br /&gt;
                my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
                EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
                if( defined $dataobj )&lt;br /&gt;
                {&lt;br /&gt;
                        push @ids, $dataobj-&amp;gt;get_id;&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
          &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; \@ids );&lt;br /&gt;
  }&lt;br /&gt;
  # Translate this XML into an EPrint&lt;br /&gt;
  sub xml_to_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        # $xml is the PubmedArticle element&lt;br /&gt;
        my( $plugin, $dataset, $xml ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $session = $plugin-&amp;gt;{session};&lt;br /&gt;
  &lt;br /&gt;
        # Locate the metadata element&lt;br /&gt;
        my $metadata = $xml-&amp;gt;getElementsByTagNameNS( $OPF_NS, &amp;quot;metadata&amp;quot; )-&amp;gt;[0];&lt;br /&gt;
  &lt;br /&gt;
        # Load the DC plugin&lt;br /&gt;
        my $dc_plugin = $session-&amp;gt;plugin( &amp;quot;Import::XSLT::DC&amp;quot;,&lt;br /&gt;
                processor =&amp;gt; $plugin-&amp;gt;{processor},&lt;br /&gt;
                dataset =&amp;gt; $dataset,&lt;br /&gt;
        );&lt;br /&gt;
  &lt;br /&gt;
        $dc_plugin-&amp;gt;{Handler} = $plugin-&amp;gt;{Handler};&lt;br /&gt;
        $dc_plugin-&amp;gt;{parse_only} = $plugin-&amp;gt;{parse_only};&lt;br /&gt;
  &lt;br /&gt;
        # Spew the metadata element to a temp file&lt;br /&gt;
        my $tmpfile2 = File::Temp-&amp;gt;new;&lt;br /&gt;
        print $tmpfile2 $metadata-&amp;gt;toString();&lt;br /&gt;
        seek($tmpfile2,0,0);&lt;br /&gt;
  &lt;br /&gt;
        # Parse the file using the plug-in to get back a list of eprints&lt;br /&gt;
        my $list = $dc_plugin-&amp;gt;input_fh( fh =&amp;gt; $tmpfile2, dataset =&amp;gt; $dataset );&lt;br /&gt;
  &lt;br /&gt;
        my( $eprint ) = $list-&amp;gt;get_records( 0, 1 );&lt;br /&gt;
  &lt;br /&gt;
        return $eprint;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
===XSLT/DC.xsl===&lt;br /&gt;
&lt;br /&gt;
Using XSLT is really quiet a nice way of parsing data and well documented so I shouldn't have to say much about how this works here.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!-- DC Transformation --&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:stylesheet&lt;br /&gt;
        version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
        xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
        ept:name=&amp;quot;DC&amp;quot;&lt;br /&gt;
        ept:visible=&amp;quot;all&amp;quot;&lt;br /&gt;
        ept:advertise=&amp;quot;1&amp;quot;&lt;br /&gt;
        ept:sourceNamespace=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        ept:targetNamespace=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
        ept:produce=&amp;quot;list/eprint&amp;quot;&lt;br /&gt;
        xmlns:ept=&amp;quot;http://eprints.org/ep2/xslt/1.0&amp;quot;&lt;br /&gt;
        xmlns:oai_dc=&amp;quot;http://www.openarchives.org/OAI/2.0/oai_dc/&amp;quot;&lt;br /&gt;
        xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
        xmlns=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
  &amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; indent=&amp;quot;yes&amp;quot; encoding=&amp;quot;utf-8&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;eprints&amp;gt;&lt;br /&gt;
        &amp;lt;eprint&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;./*&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;eprint_status&amp;gt;inbox&amp;lt;/eprint_status&amp;gt;&lt;br /&gt;
        &amp;lt;creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:creator&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&amp;lt;name&amp;gt;&amp;lt;family/&amp;gt;&amp;lt;given&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot;/&amp;gt;&amp;lt;/given&amp;gt;&amp;lt;/name&amp;gt;&amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/creators&amp;gt;&lt;br /&gt;
        &amp;lt;corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:source&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&lt;br /&gt;
                        &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;keywords&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:subject&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;,&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/keywords&amp;gt;&lt;br /&gt;
        &amp;lt;/eprint&amp;gt;&lt;br /&gt;
        &amp;lt;/eprints&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:title&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:publisher&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;publisher&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/publisher&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:rights&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;copyright_holders&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/copyright_holders&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:date&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;date&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/date&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:identifier&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;id_number&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/id_number&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!--Ignored at this level--&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:language|dc:subject|dc:source|dc:creator&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
You can test your plug-ins by simply clicking on the &amp;quot;manage deposits&amp;quot; button in your toolbar and selecting &amp;quot;OPF Resource&amp;quot; from the drop down list of import plug-ins. If it doesn't appear restart you web server and check the error log!&lt;br /&gt;
&lt;br /&gt;
Reminder:&lt;br /&gt;
&lt;br /&gt;
  apache2ctl restart &amp;amp;&amp;amp; tail -f /var/log/apache2/error.log&lt;br /&gt;
&lt;br /&gt;
Once you have the import screen, copy and paste the XML from the top of this exercise into it and see if it creates you an EPrint (which you can see back at the manage deposits screen)&lt;br /&gt;
&lt;br /&gt;
=Exporting=&lt;br /&gt;
&lt;br /&gt;
So now we have imported our EPrint from this OPF format we need to be able to put it back into this format for exporting, this has the advantage that you can also export ALL other eprints in this format.&lt;br /&gt;
&lt;br /&gt;
We did most of the work on the importing so now it's your turn below is the basis of the Export plug-in which you can use to get started. To give you a clue this export plug-in needs to be located in cfg/plugins/EPrints/Plugin/Export/OPFXML.pm&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Export::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Export::XMLFile;&lt;br /&gt;
  @ISA = ( &amp;quot;EPrints::Plugin::Export::XMLFile&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %opts ) = @_;&lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new( %opts );&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;Open Packaging Format XML&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # This plug-in can only output a single eprint record, no lists or other types of objects&lt;br /&gt;
        $self-&amp;gt;{accept} = [ 'dataobj/eprint' ];&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Specify the mimetype so we can use an HTTP ACCEPT header to get this back.&lt;br /&gt;
        $self-&amp;gt;{mimetype} = &amp;quot;application/oebps-package+xml; charset=utf-8&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Again specify what we are exporting&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{schemaLocation} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Method which is called to output the eprint, we would have output_list if we could handle lists&lt;br /&gt;
  sub output_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $dataobj ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $xml = $plugin-&amp;gt;xml_dataobj( $dataobj );&lt;br /&gt;
  &lt;br /&gt;
        return &amp;quot;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&amp;quot; . EPrints::XML::to_string( $xml );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The method which actually does the work&lt;br /&gt;
  sub xml_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $eprint ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repo = $plugin-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $package = $repo-&amp;gt;make_element(&amp;quot;package&amp;quot;, xmlns=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;unique-identifier&amp;quot;=&amp;gt;&amp;quot;EPB-UUID&amp;quot;, version=&amp;gt;&amp;quot;2.0&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        my $metadata = $repo-&amp;gt;make_element(&amp;quot;metadata&amp;quot;, &amp;quot;xmlns:opf&amp;quot;=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;xmlns:dc&amp;quot;=&amp;gt;&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;);&lt;br /&gt;
        $package-&amp;gt;appendChild($metadata);&lt;br /&gt;
  &lt;br /&gt;
        my $title = $repo-&amp;gt;make_element(&amp;quot;dc:title&amp;quot;);&lt;br /&gt;
        $title-&amp;gt;appendText($eprint-&amp;gt;value(&amp;quot;title&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        $metadata-&amp;gt;appendChild($title);&lt;br /&gt;
  &lt;br /&gt;
        if( $eprint-&amp;gt;exists_and_set( &amp;quot;creators&amp;quot; ) )&lt;br /&gt;
        {&lt;br /&gt;
                foreach my $name ( @{ $eprint-&amp;gt;get_value( &amp;quot;creators&amp;quot; ) } )&lt;br /&gt;
                {&lt;br /&gt;
                        # given name first&lt;br /&gt;
                        my $creator = $repo-&amp;gt;make_element(&amp;quot;dc:creator&amp;quot;);&lt;br /&gt;
                        $creator-&amp;gt;appendText(EPrints::Utils::make_name_string( $name-&amp;gt;{name}, 1 ));&lt;br /&gt;
                        $metadata-&amp;gt;appendChild($creator);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
        return $package;&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
This is no where near as complete as the original input from above, can you make the 2 match?&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
This is an easy one. &lt;br /&gt;
* Find the eprint you imported&lt;br /&gt;
* Click the Actions Tab&lt;br /&gt;
* Locate the Export options at the bottom of this tab&lt;br /&gt;
* Find your export plug-in (by name) and click it&lt;br /&gt;
&lt;br /&gt;
=Wrap it as a package=&lt;br /&gt;
&lt;br /&gt;
Once again, now this is working you want to remove the files and package them up with a spec file and icon. Then remove the files from your local install and try doing an install via the Bazaar to see if it works.&lt;br /&gt;
&lt;br /&gt;
Why not see the export plug-in working via a GET request to the id url of the eprint http://archive.org/id/eprint/XXX with the ACCEPT header set to the mime-type of your desired export plug-in. This is quick proof that content negotiation works in EPrints and it's that easy to add a new exporter.&lt;br /&gt;
&lt;br /&gt;
=Extension Exercises=&lt;br /&gt;
&lt;br /&gt;
This whole exercise has been the beginning of importing the epub format into EPrints!&lt;br /&gt;
&lt;br /&gt;
If you are feeling keen see if you can scope out or develop this further to import more of the format, maybe some of the chapters etc. &lt;br /&gt;
&lt;br /&gt;
The full epub for this book is available @ http://www.epubbooks.com/book/378/adventures-of-sherlock-holmes and you have been importing a small section of the epb.opf file which is listed in the META-INF/container.xml&lt;br /&gt;
&lt;br /&gt;
epub is a format we are keen to see EPrints support and there may be a bounty available for the first person to develop a complete Bazaar Package to support them.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9914</id>
		<title>Import and Export Plug-ins</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9914"/>
		<updated>2011-07-20T13:47:16Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* The Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
Import and Export Plug-ins are all about taking an object, de-serialising it into an eprint (or other object in the EPrints system) and re-serialising it back into an object to be supported. &lt;br /&gt;
&lt;br /&gt;
We would typically advocate that every import plug-in should have a corresponding export plug-in and visa-versa.&lt;br /&gt;
&lt;br /&gt;
=Input Data=&lt;br /&gt;
&lt;br /&gt;
We are going to attempt to import the following XML record into our system. If you know the format of this record all the better else we'll leave it as a surprise for now.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;package xmlns=&amp;quot;http://www.idpf.org/2007/opf&amp;quot; unique-identifier=&amp;quot;EPB-UUID&amp;quot; version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;metadata xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
             xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;dc:title&amp;gt;The Adventures of Sherlock Holmes&amp;lt;/dc:title&amp;gt;&lt;br /&gt;
      &amp;lt;dc:creator opf:role=&amp;quot;aut&amp;quot; opf:file-as=&amp;quot;Doyle, Sir Arthur Conan&amp;quot;&amp;gt;Sir Arthur Conan Doyle&amp;lt;/dc:creator&amp;gt;&lt;br /&gt;
      &amp;lt;dc:publisher&amp;gt;epubBooks (www.epubbooks.com)&amp;lt;/dc:publisher&amp;gt;&lt;br /&gt;
      &amp;lt;dc:date opf:event=&amp;quot;epub-publication&amp;quot;&amp;gt;2010-06-15&amp;lt;/dc:date&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Crime/Detective&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Short Stories&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:source&amp;gt;Project Gutenberg&amp;lt;/dc:source&amp;gt;&lt;br /&gt;
      &amp;lt;dc:rights&amp;gt;&lt;br /&gt;
            Provided for free by epubBooks.com. Not for commercial use.&lt;br /&gt;
            This EPUB eBook is released under a Creative Commons (BY-NC-ND/3.0) Licence.&lt;br /&gt;
            Source text and images are in the Public Domain.&lt;br /&gt;
      &amp;lt;/dc:rights&amp;gt;&lt;br /&gt;
      &amp;lt;dc:identifier id=&amp;quot;EPB-UUID&amp;quot;&amp;gt;urn:uuid:FF946905-6C08-1014-90EA-E81F8523F0DC&amp;lt;/dc:identifier&amp;gt;&lt;br /&gt;
      &amp;lt;dc:language&amp;gt;en-gb&amp;lt;/dc:language&amp;gt;&lt;br /&gt;
   &amp;lt;/metadata&amp;gt;&lt;br /&gt;
   &amp;lt;manifest&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/manifest&amp;gt;&lt;br /&gt;
   &amp;lt;spine&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/spine&amp;gt;&lt;br /&gt;
  &amp;lt;/package&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Importing=&lt;br /&gt;
&lt;br /&gt;
To import this record we need a fully featured import plug-in which is capable of handle both file and raw XML input, we are also going to use an XSLT plug-ins to make the process even easier. &lt;br /&gt;
&lt;br /&gt;
==The Files==&lt;br /&gt;
&lt;br /&gt;
We need the following:&lt;br /&gt;
&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Import/OPFXML.pm&lt;br /&gt;
* lib/plugins/EPrints/Plugin/Import/XSLT/DC.xsl&lt;br /&gt;
&lt;br /&gt;
===OPFXML.pm===&lt;br /&gt;
&lt;br /&gt;
This will be our master import plug-in to handle the entire chunk of XML. We will then use the DC plug-in to map the metadata into an eprint we can use later. &lt;br /&gt;
&lt;br /&gt;
Since this is the master plug-in this requires quiet a sizeable amount of code:&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Import::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  # Declare Namespaces&lt;br /&gt;
  our $DC_NS = &amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;;&lt;br /&gt;
  our $DCTERMS_NS = &amp;quot;http://purl.org/dc/terms/&amp;quot;;&lt;br /&gt;
  our $OPF_NS = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # This is just a variant of the DefaultXML plug-in&lt;br /&gt;
  use EPrints::Plugin::Import::DefaultXML;&lt;br /&gt;
  &lt;br /&gt;
  our @ISA = qw/ EPrints::Plugin::Import::DefaultXML /;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;OPF Resource&amp;quot;;&lt;br /&gt;
        # Make it visible on the import menu and elsewhere&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{produce} = [ 'list/eprint', 'dataobj/eprint' ];&lt;br /&gt;
  &lt;br /&gt;
        # Functionality to recognise XML types on import by recognising the base namespace, works with the sword packaging format, dc:conformsTo or similar.&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $rc = EPrints::Utils::require_if_exists(&amp;quot;MIME::Types&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        unless( $rc )&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{visible} = &amp;quot;&amp;quot;;&lt;br /&gt;
                $self-&amp;gt;{error} = &amp;quot;Failed to load required module MIME::Types&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Input File Handle Method, for when files are uploaded&lt;br /&gt;
  sub input_fh&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $fh = $opts{&amp;quot;fh&amp;quot;};&lt;br /&gt;
  &lt;br /&gt;
        my $xml = join &amp;quot;&amp;quot;, &amp;lt;$fh&amp;gt;;&lt;br /&gt;
  &lt;br /&gt;
        my $list;&lt;br /&gt;
  &lt;br /&gt;
        if( $xml =~ /^&amp;lt;\?xml/ )&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_xml( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_list( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        $list ||= EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [] );&lt;br /&gt;
  &lt;br /&gt;
        return $list;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Handle direct XML input&lt;br /&gt;
  sub input_fh_xml&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $xml, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $doc = EPrints::XML::parse_xml_string( $xml );&lt;br /&gt;
  &lt;br /&gt;
        my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
        EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [defined($dataobj) ? $dataobj-&amp;gt;get_id : ()] );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Go grab input from a URL&lt;br /&gt;
  sub input_fh_list&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $url, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $url =~ s/\s+//g;&lt;br /&gt;
  &lt;br /&gt;
        my $tmpfile = File::Temp-&amp;gt;new;&lt;br /&gt;
  &lt;br /&gt;
        my $r = EPrints::Utils::wget( $plugin-&amp;gt;{session}, $url, $tmpfile );&lt;br /&gt;
        seek($tmpfile,0,0);&lt;br /&gt;
  &lt;br /&gt;
        if( $r-&amp;gt;is_error )&lt;br /&gt;
        {&lt;br /&gt;
                $plugin-&amp;gt;error( &amp;quot;Error reading resource from $url: &amp;quot;.$r-&amp;gt;code.&amp;quot; &amp;quot;.$r-&amp;gt;message );&lt;br /&gt;
                return;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        my @ids;&lt;br /&gt;
  &lt;br /&gt;
        while(my $url = &amp;lt;$tmpfile&amp;gt;)&lt;br /&gt;
        {&lt;br /&gt;
                $url =~ s/\s+//g;&lt;br /&gt;
                next unless $url =~ /^http/;&lt;br /&gt;
  &lt;br /&gt;
                my $doc;&lt;br /&gt;
                eval { $doc = EPrints::XML::parse_url( $url ) };&lt;br /&gt;
                if( $@ )&lt;br /&gt;
                {&lt;br /&gt;
                        $plugin-&amp;gt;warning( &amp;quot;Error parsing: $url\n&amp;quot; );&lt;br /&gt;
                }&lt;br /&gt;
  &lt;br /&gt;
                my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
                EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
                if( defined $dataobj )&lt;br /&gt;
                {&lt;br /&gt;
                        push @ids, $dataobj-&amp;gt;get_id;&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
          &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; \@ids );&lt;br /&gt;
  }&lt;br /&gt;
  # Translate this XML into an EPrint&lt;br /&gt;
  sub xml_to_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        # $xml is the PubmedArticle element&lt;br /&gt;
        my( $plugin, $dataset, $xml ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $session = $plugin-&amp;gt;{session};&lt;br /&gt;
  &lt;br /&gt;
        # Locate the metadata element&lt;br /&gt;
        my $metadata = $xml-&amp;gt;getElementsByTagNameNS( $OPF_NS, &amp;quot;metadata&amp;quot; )-&amp;gt;[0];&lt;br /&gt;
  &lt;br /&gt;
        # Load the DC plugin&lt;br /&gt;
        my $dc_plugin = $session-&amp;gt;plugin( &amp;quot;Import::XSLT::DC&amp;quot;,&lt;br /&gt;
                processor =&amp;gt; $plugin-&amp;gt;{processor},&lt;br /&gt;
                dataset =&amp;gt; $dataset,&lt;br /&gt;
        );&lt;br /&gt;
  &lt;br /&gt;
        $dc_plugin-&amp;gt;{Handler} = $plugin-&amp;gt;{Handler};&lt;br /&gt;
        $dc_plugin-&amp;gt;{parse_only} = $plugin-&amp;gt;{parse_only};&lt;br /&gt;
  &lt;br /&gt;
        # Spew the metadata element to a temp file&lt;br /&gt;
        my $tmpfile2 = File::Temp-&amp;gt;new;&lt;br /&gt;
        print $tmpfile2 $metadata-&amp;gt;toString();&lt;br /&gt;
        seek($tmpfile2,0,0);&lt;br /&gt;
  &lt;br /&gt;
        # Parse the file using the plug-in to get back a list of eprints&lt;br /&gt;
        my $list = $dc_plugin-&amp;gt;input_fh( fh =&amp;gt; $tmpfile2, dataset =&amp;gt; $dataset );&lt;br /&gt;
  &lt;br /&gt;
        my( $eprint ) = $list-&amp;gt;get_records( 0, 1 );&lt;br /&gt;
  &lt;br /&gt;
        return $eprint;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
===XSLT/DC.xsl===&lt;br /&gt;
&lt;br /&gt;
Using XSLT is really quiet a nice way of parsing data and well documented so I shouldn't have to say much about how this works here.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!-- DC Transformation --&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:stylesheet&lt;br /&gt;
        version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
        xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
        ept:name=&amp;quot;DC&amp;quot;&lt;br /&gt;
        ept:visible=&amp;quot;all&amp;quot;&lt;br /&gt;
        ept:advertise=&amp;quot;1&amp;quot;&lt;br /&gt;
        ept:sourceNamespace=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        ept:targetNamespace=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
        ept:produce=&amp;quot;list/eprint&amp;quot;&lt;br /&gt;
        xmlns:ept=&amp;quot;http://eprints.org/ep2/xslt/1.0&amp;quot;&lt;br /&gt;
        xmlns:oai_dc=&amp;quot;http://www.openarchives.org/OAI/2.0/oai_dc/&amp;quot;&lt;br /&gt;
        xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
        xmlns=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
  &amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; indent=&amp;quot;yes&amp;quot; encoding=&amp;quot;utf-8&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;eprints&amp;gt;&lt;br /&gt;
        &amp;lt;eprint&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;./*&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;eprint_status&amp;gt;inbox&amp;lt;/eprint_status&amp;gt;&lt;br /&gt;
        &amp;lt;creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:creator&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&amp;lt;name&amp;gt;&amp;lt;family/&amp;gt;&amp;lt;given&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot;/&amp;gt;&amp;lt;/given&amp;gt;&amp;lt;/name&amp;gt;&amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/creators&amp;gt;&lt;br /&gt;
        &amp;lt;corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:source&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&lt;br /&gt;
                        &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;keywords&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:subject&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;,&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/keywords&amp;gt;&lt;br /&gt;
        &amp;lt;/eprint&amp;gt;&lt;br /&gt;
        &amp;lt;/eprints&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:title&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:publisher&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;publisher&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/publisher&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:rights&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;copyright_holders&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/copyright_holders&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:date&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;date&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/date&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:identifier&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;id_number&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/id_number&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!--Ignored at this level--&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:language|dc:subject|dc:source|dc:creator&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
You can test your plug-ins by simply clicking on the &amp;quot;manage deposits&amp;quot; button in your toolbar and selecting &amp;quot;OPF Resource&amp;quot; from the drop down list of import plug-ins. If it doesn't appear restart you web server and check the error log!&lt;br /&gt;
&lt;br /&gt;
Reminder:&lt;br /&gt;
&lt;br /&gt;
  apache2ctl restart &amp;amp;&amp;amp; tail -f /var/log/apache2/error.log&lt;br /&gt;
&lt;br /&gt;
Once you have the import screen, copy and paste the XML from the top of this exercise into it and see if it creates you an EPrint (which you can see back at the manage deposits screen)&lt;br /&gt;
&lt;br /&gt;
=Exporting=&lt;br /&gt;
&lt;br /&gt;
So now we have imported our EPrint from this OPF format we need to be able to put it back into this format for exporting, this has the advantage that you can also export ALL other eprints in this format.&lt;br /&gt;
&lt;br /&gt;
We did most of the work on the importing so now it's your turn below is the basis of the Export plug-in which you can use to get started. To give you a clue this export plug-in needs to be located in cfg/plugins/EPrints/Plugin/Export/OPFXML.pm&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Export::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Export::XMLFile;&lt;br /&gt;
  @ISA = ( &amp;quot;EPrints::Plugin::Export::XMLFile&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %opts ) = @_;&lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new( %opts );&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;Open Packaging Format XML&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # This plug-in can only output a single eprint record, no lists or other types of objects&lt;br /&gt;
        $self-&amp;gt;{accept} = [ 'dataobj/eprint' ];&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Specify the mimetype so we can use an HTTP ACCEPT header to get this back.&lt;br /&gt;
        $self-&amp;gt;{mimetype} = &amp;quot;application/oebps-package+xml; charset=utf-8&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Again specify what we are exporting&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{schemaLocation} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Method which is called to output the eprint, we would have output_list if we could handle lists&lt;br /&gt;
  sub output_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $dataobj ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $xml = $plugin-&amp;gt;xml_dataobj( $dataobj );&lt;br /&gt;
  &lt;br /&gt;
        return &amp;quot;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&amp;quot; . EPrints::XML::to_string( $xml );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The method which actually does the work&lt;br /&gt;
  sub xml_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $eprint ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repo = $plugin-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $package = $repo-&amp;gt;make_element(&amp;quot;package&amp;quot;, xmlns=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;unique-identifier&amp;quot;=&amp;gt;&amp;quot;EPB-UUID&amp;quot;, version=&amp;gt;&amp;quot;2.0&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        my $metadata = $repo-&amp;gt;make_element(&amp;quot;metadata&amp;quot;, &amp;quot;xmlns:opf&amp;quot;=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;xmlns:dc&amp;quot;=&amp;gt;&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;);&lt;br /&gt;
        $package-&amp;gt;appendChild($metadata);&lt;br /&gt;
  &lt;br /&gt;
        my $title = $repo-&amp;gt;make_element(&amp;quot;dc:title&amp;quot;);&lt;br /&gt;
        $title-&amp;gt;appendText($eprint-&amp;gt;value(&amp;quot;title&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        $metadata-&amp;gt;appendChild($title);&lt;br /&gt;
  &lt;br /&gt;
        if( $eprint-&amp;gt;exists_and_set( &amp;quot;creators&amp;quot; ) )&lt;br /&gt;
        {&lt;br /&gt;
                foreach my $name ( @{ $eprint-&amp;gt;get_value( &amp;quot;creators&amp;quot; ) } )&lt;br /&gt;
                {&lt;br /&gt;
                        # given name first&lt;br /&gt;
                        my $creator = $repo-&amp;gt;make_element(&amp;quot;dc:creator&amp;quot;);&lt;br /&gt;
                        $creator-&amp;gt;appendText(EPrints::Utils::make_name_string( $name-&amp;gt;{name}, 1 ));&lt;br /&gt;
                        $metadata-&amp;gt;appendChild($creator);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
        return $package;&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
This is no where near as complete as the original input from above, can you make the 2 match?&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
This is an easy one. &lt;br /&gt;
* Find the eprint you imported&lt;br /&gt;
* Click the Actions Tab&lt;br /&gt;
* Locate the Export options at the bottom of this tab&lt;br /&gt;
* Find your export plug-in (by name) and click it&lt;br /&gt;
&lt;br /&gt;
=Wrap it as a package=&lt;br /&gt;
&lt;br /&gt;
Once again, now this is working you want to remove the files and package them up with a spec file and icon. Then remove the files from your local install and try doing an install via the Bazaar to see if it works.&lt;br /&gt;
&lt;br /&gt;
Why not see the export plug-in working via a GET request to the id url of the eprint http://archive.org/id/eprint/XXX with the ACCEPT header set to the mime-type of your desired export plug-in. This is quick proof that content negotiation works in EPrints and it's that easy to add a new exporter.&lt;br /&gt;
&lt;br /&gt;
=Extension Exercises=&lt;br /&gt;
&lt;br /&gt;
This whole exercise has been the beginning of importing the epub format into EPrints!&lt;br /&gt;
&lt;br /&gt;
If you are feeling keen see if you can scope out or develop this further to import more of the format, maybe some of the chapters etc. &lt;br /&gt;
&lt;br /&gt;
The full epub for this book is available @ http://www.epubbooks.com/book/378/adventures-of-sherlock-holmes and you have been importing a small section of the epb.opf file which is listed in the META-INF/container.xml&lt;br /&gt;
&lt;br /&gt;
epub is a format we are keen to see EPrints support and there may be a bounty available for the first person to develop a complete Bazaar Package to support them.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9913</id>
		<title>My First Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9913"/>
		<updated>2011-07-20T12:41:45Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will create a &amp;quot;Hello, World&amp;quot; Screen and package it as a Bazaar Package (.epm).&lt;br /&gt;
&lt;br /&gt;
=Requirements=&lt;br /&gt;
&lt;br /&gt;
You will need a working EPrints installation on which you have an administrator account. You will need to have access to the command line to create the files for the package.&lt;br /&gt;
&lt;br /&gt;
=Step 1 - Develop your package contents=&lt;br /&gt;
&lt;br /&gt;
You will need to be in the root directory of your EPrints installation (typically /opt/eprints3).&lt;br /&gt;
&lt;br /&gt;
''gedit'' is the Gnome Text editor but you can use any editor that is capable of creating text files.&lt;br /&gt;
&lt;br /&gt;
==Hello.pm==&lt;br /&gt;
&lt;br /&gt;
Create the directory to contain the ''Screen'' plugin you're going to package:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/plugins/EPrints/Plugin/Screen/&lt;br /&gt;
&lt;br /&gt;
Create the screen plugin using your preferred text editor and add the sample content below:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/plugins/EPrints/Plugin/Screen/Hello.pm&lt;br /&gt;
&lt;br /&gt;
 package EPrints::Plugin::Screen::Hello;&lt;br /&gt;
 &lt;br /&gt;
 @ISA = ( 'EPrints::Plugin::Screen' );&lt;br /&gt;
 &lt;br /&gt;
 use strict;&lt;br /&gt;
 # Make the plug-in&lt;br /&gt;
 sub new&lt;br /&gt;
 {&lt;br /&gt;
    my( $class, %params ) = @_;&lt;br /&gt;
 &lt;br /&gt;
    my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
 &lt;br /&gt;
    # Where the button to access the screen appears if anywhere, and what priority&lt;br /&gt;
    $self-&amp;gt;{appears} = [&lt;br /&gt;
       {&lt;br /&gt;
           place =&amp;gt; &amp;quot;admin_actions&amp;quot;,&lt;br /&gt;
           position =&amp;gt; 1247,&lt;br /&gt;
       },&lt;br /&gt;
    ];&lt;br /&gt;
 &lt;br /&gt;
    return $self;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # Anyone can see this screen&lt;br /&gt;
 sub can_be_viewed { 1 }&lt;br /&gt;
 &lt;br /&gt;
 # What to display&lt;br /&gt;
 sub render&lt;br /&gt;
 {&lt;br /&gt;
    my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
    # Get the current repository object (so we can access the users, eprints information about things in this repository)&lt;br /&gt;
  &lt;br /&gt;
    my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
    # Create an XML element to return to our screen&lt;br /&gt;
  &lt;br /&gt;
    my $frag = $repository-&amp;gt;xml-&amp;gt;create_document_fragment();&lt;br /&gt;
 &lt;br /&gt;
    # Fill the fragment with stuff&lt;br /&gt;
  &lt;br /&gt;
    $frag-&amp;gt;appendChild($repository-&amp;gt;xml-&amp;gt;create_text_node( &amp;quot;Hello, World!&amp;quot; ));&lt;br /&gt;
  &lt;br /&gt;
    return $frag;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 1;&lt;br /&gt;
&lt;br /&gt;
==hello_world.pl==&lt;br /&gt;
&lt;br /&gt;
Create the package directory that will contain the package's configuration file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/epm/hello_world/cfg/cfg.d&lt;br /&gt;
&lt;br /&gt;
Create a configuration file that enables the plugin - this file is copied into the repository when the package is enabled:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/epm/hello_world/cfg/cfg.d/hello_world.pl&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Screen::Hello&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
&lt;br /&gt;
=Step 2 - Add an Icon=&lt;br /&gt;
&lt;br /&gt;
Create an Icon, using the icon builder at http://bazaar.eprints.org&lt;br /&gt;
&lt;br /&gt;
OR&lt;br /&gt;
&lt;br /&gt;
Download the hello_world icon from http://bazaar.eprints.org/images/hello_world.png&lt;br /&gt;
&lt;br /&gt;
Once you have this icon, name it hello_world.png and move it into the lib/static/images/epms/ directory.&lt;br /&gt;
&lt;br /&gt;
=Step 3 - Create a blank package=&lt;br /&gt;
&lt;br /&gt;
In ''Admin'' &amp;amp;rarr; ''System Tools'' &amp;amp;rarr; ''EPrints Bazaar'', select the ''Developer Tools'' tab.&lt;br /&gt;
&lt;br /&gt;
At the bottom of this screen is a form to create a new EPM. Enter the name (without quotes) &amp;quot;hello_world&amp;quot; and click ''Create''.&lt;br /&gt;
&lt;br /&gt;
You can fill out the metadata if you wish but at this stage you are only required to have a ''version'', which defaults to &amp;quot;1.0.0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
At the bottom of the screen (the ''Files'' selector) you need to add the two files you created above:&lt;br /&gt;
&lt;br /&gt;
* epm/hello_world/cfg/cfg.d/hello_world.pl&lt;br /&gt;
* plugins/EPrints/Plugin/Screen/Hello.pm&lt;br /&gt;
* static/images/epm/hello_world.png&lt;br /&gt;
&lt;br /&gt;
Click ''Save and Return'' to return to the EPrints Bazaar screen.&lt;br /&gt;
&lt;br /&gt;
If you make a mistake you can click ''Edit'' on the ''Developer Tools'' tab to re-edit the package.&lt;br /&gt;
&lt;br /&gt;
=Step 4 - Enable and test the package=&lt;br /&gt;
&lt;br /&gt;
On the EPrints Bazaar ''Installed'' tab click ''Enable'' for the '''hello_world''' package. After a short time you should see a repository configuration reloaded message.&lt;br /&gt;
&lt;br /&gt;
In ''Admin'' &amp;amp;rarr; ''System Tools'' &amp;amp;rarr; ''Misc. Tools'' you should now a button-link to your plugin (although with a missing phrase).&lt;br /&gt;
&lt;br /&gt;
You can now use ''Uninstall'' to completely remove the package and the source files created. A copy of the package will be saved in '''var/cache/epm/hello_world-1.0.0.epm'''.&lt;br /&gt;
&lt;br /&gt;
=Step 5 - Adding the missing phrases=&lt;br /&gt;
&lt;br /&gt;
As EPrints is designed to be multi-language, phrases should be used instead of embedded text.&lt;br /&gt;
&lt;br /&gt;
In this section we add the phrase file to define a name a description for our screen.&lt;br /&gt;
&lt;br /&gt;
Create the English language directory that will contain the package's English language phrase file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/lang/en/phrases/&lt;br /&gt;
&lt;br /&gt;
Create a phrase file:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/lang/en/phrases/hello_world.xml&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;iso-8859-1&amp;quot; standalone=&amp;quot;no&amp;quot; ?&amp;gt;&lt;br /&gt;
  &amp;lt;!DOCTYPE phrases SYSTEM &amp;quot;entities.dtd&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;epp:phrases xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; xmlns:epp=&amp;quot;http://eprints.org/ep3/phrase&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:title&amp;quot;&amp;gt;Hello&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:description&amp;quot;&amp;gt;My First Bazaar Package&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:text&amp;quot;&amp;gt;Hello World - This is the my first bazaar package calling.&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  &amp;lt;/epp:phrases&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Don't worry too much about the wrapping here, the important thing are the phrases of which we have created 3. &lt;br /&gt;
&lt;br /&gt;
Note that 2 of these (the top 2) will get used instantly by our package however the 3rd needs to be added to the render method of our screen. &lt;br /&gt;
&lt;br /&gt;
In order to do this edit the Hello.pm screen created in Step 1 and add the following in the appropriate place in the render method.&lt;br /&gt;
&lt;br /&gt;
  $frag-&amp;gt;appendChild($repository-&amp;gt;xml-&amp;gt;create_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
  $frag-&amp;gt;appendChild($self-&amp;gt;html_phrase(&amp;quot;text&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
For some hints on loading and manipulating EPrints see [[Manipulating eprints in 3.2]].&lt;br /&gt;
&lt;br /&gt;
'''Don't Forget''' to add the phrase file to your bazaar package using the developer tools tab.&lt;br /&gt;
&lt;br /&gt;
[[Category:EPrints_Bazaar]]&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9912</id>
		<title>My First Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9912"/>
		<updated>2011-07-20T12:34:25Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will create a &amp;quot;Hello, World&amp;quot; Screen and package it as a Bazaar Package (.epm).&lt;br /&gt;
&lt;br /&gt;
=Requirements=&lt;br /&gt;
&lt;br /&gt;
You will need a working EPrints installation on which you have an administrator account. You will need to have access to the command line to create the files for the package.&lt;br /&gt;
&lt;br /&gt;
=Step 1 - Develop your package contents=&lt;br /&gt;
&lt;br /&gt;
You will need to be in the root directory of your EPrints installation (typically /opt/eprints3).&lt;br /&gt;
&lt;br /&gt;
''gedit'' is the Gnome Text editor but you can use any editor that is capable of creating text files.&lt;br /&gt;
&lt;br /&gt;
==Hello.pm==&lt;br /&gt;
&lt;br /&gt;
Create the directory to contain the ''Screen'' plugin you're going to package:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/plugins/EPrints/Plugin/Screen/&lt;br /&gt;
&lt;br /&gt;
Create the screen plugin using your preferred text editor and add the sample content below:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/plugins/EPrints/Plugin/Screen/Hello.pm&lt;br /&gt;
&lt;br /&gt;
 package EPrints::Plugin::Screen::Hello;&lt;br /&gt;
 &lt;br /&gt;
 @ISA = ( 'EPrints::Plugin::Screen' );&lt;br /&gt;
 &lt;br /&gt;
 use strict;&lt;br /&gt;
 # Make the plug-in&lt;br /&gt;
 sub new&lt;br /&gt;
 {&lt;br /&gt;
    my( $class, %params ) = @_;&lt;br /&gt;
 &lt;br /&gt;
    my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
 &lt;br /&gt;
    # Where the button to access the screen appears if anywhere, and what priority&lt;br /&gt;
    $self-&amp;gt;{appears} = [&lt;br /&gt;
       {&lt;br /&gt;
           place =&amp;gt; &amp;quot;admin_actions&amp;quot;,&lt;br /&gt;
           position =&amp;gt; 1247,&lt;br /&gt;
       },&lt;br /&gt;
    ];&lt;br /&gt;
 &lt;br /&gt;
    return $self;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # Anyone can see this screen&lt;br /&gt;
 sub can_be_viewed { 1 }&lt;br /&gt;
 &lt;br /&gt;
 # What to display&lt;br /&gt;
 sub render&lt;br /&gt;
 {&lt;br /&gt;
    my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
    # Get the current repository object (so we can access the users, eprints information about things in this repository)&lt;br /&gt;
  &lt;br /&gt;
    my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
    # Create an XML element to return to our screen&lt;br /&gt;
  &lt;br /&gt;
    my $frag = $repository-&amp;gt;xml-&amp;gt;create_document_fragment();&lt;br /&gt;
 &lt;br /&gt;
    # Fill the fragment with stuff&lt;br /&gt;
  &lt;br /&gt;
    $frag-&amp;gt;appendChild($repository-&amp;gt;xml-&amp;gt;create_text_node( &amp;quot;Hello, World!&amp;quot; ));&lt;br /&gt;
&lt;br /&gt;
    return $frag;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 1;&lt;br /&gt;
&lt;br /&gt;
==hello_world.pl==&lt;br /&gt;
&lt;br /&gt;
Create the package directory that will contain the package's configuration file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/epm/hello_world/cfg/cfg.d&lt;br /&gt;
&lt;br /&gt;
Create a configuration file that enables the plugin - this file is copied into the repository when the package is enabled:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/epm/hello_world/cfg/cfg.d/hello_world.pl&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Screen::Hello&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
&lt;br /&gt;
=Step 2 - Add an Icon=&lt;br /&gt;
&lt;br /&gt;
Create an Icon, using the icon builder at http://bazaar.eprints.org&lt;br /&gt;
&lt;br /&gt;
OR&lt;br /&gt;
&lt;br /&gt;
Download the hello_world icon from http://bazaar.eprints.org/images/hello_world.png&lt;br /&gt;
&lt;br /&gt;
Once you have this icon, name it hello_world.png and move it into the lib/static/images/epms/ directory.&lt;br /&gt;
&lt;br /&gt;
=Step 3 - Create a blank package=&lt;br /&gt;
&lt;br /&gt;
In ''Admin'' &amp;amp;rarr; ''System Tools'' &amp;amp;rarr; ''EPrints Bazaar'', select the ''Developer Tools'' tab.&lt;br /&gt;
&lt;br /&gt;
At the bottom of this screen is a form to create a new EPM. Enter the name (without quotes) &amp;quot;hello_world&amp;quot; and click ''Create''.&lt;br /&gt;
&lt;br /&gt;
You can fill out the metadata if you wish but at this stage you are only required to have a ''version'', which defaults to &amp;quot;1.0.0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
At the bottom of the screen (the ''Files'' selector) you need to add the two files you created above:&lt;br /&gt;
&lt;br /&gt;
* epm/hello_world/cfg/cfg.d/hello_world.pl&lt;br /&gt;
* plugins/EPrints/Plugin/Screen/Hello.pm&lt;br /&gt;
* static/images/epm/hello_world.png&lt;br /&gt;
&lt;br /&gt;
Click ''Save and Return'' to return to the EPrints Bazaar screen.&lt;br /&gt;
&lt;br /&gt;
If you make a mistake you can click ''Edit'' on the ''Developer Tools'' tab to re-edit the package.&lt;br /&gt;
&lt;br /&gt;
=Step 4 - Enable and test the package=&lt;br /&gt;
&lt;br /&gt;
On the EPrints Bazaar ''Installed'' tab click ''Enable'' for the '''hello_world''' package. After a short time you should see a repository configuration reloaded message.&lt;br /&gt;
&lt;br /&gt;
In ''Admin'' &amp;amp;rarr; ''System Tools'' &amp;amp;rarr; ''Misc. Tools'' you should now a button-link to your plugin (although with a missing phrase).&lt;br /&gt;
&lt;br /&gt;
You can now use ''Uninstall'' to completely remove the package and the source files created. A copy of the package will be saved in '''var/cache/epm/hello_world-1.0.0.epm'''.&lt;br /&gt;
&lt;br /&gt;
=Step 5 - Adding the missing phrases=&lt;br /&gt;
&lt;br /&gt;
As EPrints is designed to be multi-language, phrases should be used instead of embedded text.&lt;br /&gt;
&lt;br /&gt;
In this section we add the phrase file to define a name a description for our screen.&lt;br /&gt;
&lt;br /&gt;
Create the English language directory that will contain the package's English language phrase file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/lang/en/phrases/&lt;br /&gt;
&lt;br /&gt;
Create a phrase file:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/lang/en/phrases/hello_world.xml&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;iso-8859-1&amp;quot; standalone=&amp;quot;no&amp;quot; ?&amp;gt;&lt;br /&gt;
  &amp;lt;!DOCTYPE phrases SYSTEM &amp;quot;entities.dtd&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;epp:phrases xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; xmlns:epp=&amp;quot;http://eprints.org/ep3/phrase&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:title&amp;quot;&amp;gt;Hello&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:description&amp;quot;&amp;gt;My First Bazaar Package&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:text&amp;quot;&amp;gt;Hello World - This is the my first bazaar package calling.&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  &amp;lt;/epp:phrases&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Don't worry too much about the wrapping here, the important thing are the phrases of which we have created 3. &lt;br /&gt;
&lt;br /&gt;
Note that 2 of these (the top 2) will get used instantly by our package however the 3rd needs to be added to the render method of our screen. &lt;br /&gt;
&lt;br /&gt;
In order to do this edit the Hello.pm screen created in Step 1 and add the following in the appropriate place in the render method.&lt;br /&gt;
&lt;br /&gt;
  $frag-&amp;gt;appendChild($repository-&amp;gt;xml-&amp;gt;create_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
  $frag-&amp;gt;appendChild($self-&amp;gt;html_phrase(&amp;quot;text&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
For some hints on loading and manipulating EPrints see [[Manipulating eprints in 3.2]].&lt;br /&gt;
&lt;br /&gt;
'''Don't Forget''' to add the phrase file to your bazaar package using the developer tools tab.&lt;br /&gt;
&lt;br /&gt;
[[Category:EPrints_Bazaar]]&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9911</id>
		<title>Using the new API</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9911"/>
		<updated>2011-07-20T12:29:58Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints Bazaar]]&lt;br /&gt;
The new EPrints API is exposes the basic functionality of a repository in clean way. The aim of the API is to be simple to use but powerful. Some of the more complex things EPrints can do are deliberately not exposed. Our aim is that the EPrints API will remain consistent between versions of the software so your plugins wont break when you upgrade eprints.&lt;br /&gt;
&lt;br /&gt;
This exercise assumes that you have completed the [[My_First_Bazaar_Package]] exercise and will be expanding on the screen plug-in detailed in this exercise.&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to expand our screen to take a parameter and process it. We shall use the API to retrieve information from within EPrints an display it on screen.&lt;br /&gt;
&lt;br /&gt;
=Retrieving an object by ID=&lt;br /&gt;
&lt;br /&gt;
==Reading EPrint ID from Address Bar Parameter==&lt;br /&gt;
&lt;br /&gt;
In order to do this we are going to create some special action methods, these can perform operations when requested. &lt;br /&gt;
&lt;br /&gt;
Taking the screen plug-in developed in the [[My_First_Bazaar_Package]] exercise, firstly add a global screen variable which we can store an eprint object inside. &lt;br /&gt;
&lt;br /&gt;
  our $eprint = undef;&lt;br /&gt;
&lt;br /&gt;
This will be used later. &lt;br /&gt;
&lt;br /&gt;
Next we want to define a couple of new methods, the first of which reads a parameter &amp;quot;input_field&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
  my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
and then retrieves the eprint corresponding to the value set by the parameter:&lt;br /&gt;
&lt;br /&gt;
  $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
&lt;br /&gt;
In order to call these methods at the appropriate time lets add a whole method to our screen plug-in. Add the following near the top of the file:&lt;br /&gt;
&lt;br /&gt;
  sub action_process_input {&lt;br /&gt;
  &lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        ## DO SOME VALIDATION HERE MAYBE???&lt;br /&gt;
  &lt;br /&gt;
        $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
  &lt;br /&gt;
        if (!defined $eprint)&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{processor}-&amp;gt;add_message(&lt;br /&gt;
                                &amp;quot;error&amp;quot;,&lt;br /&gt;
                                $self-&amp;gt;{repository}-&amp;gt;make_text(&amp;quot;No EPrint found with ID: $eprint_id&amp;quot;)&lt;br /&gt;
                                );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point we can call this method from our existing render method to get a handle on the eprint object.&lt;br /&gt;
&lt;br /&gt;
To do this add the following to the bottom of the existing render method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;action_process_input();&lt;br /&gt;
&lt;br /&gt;
You could make the action_process_input method return the eprint rather than set it as a global, however the reason to not do this will become apparent later.&lt;br /&gt;
&lt;br /&gt;
Lastly, lets get the title of the EPrint an print it out.&lt;br /&gt;
&lt;br /&gt;
Again add the following to the bottom of our render method:&lt;br /&gt;
&lt;br /&gt;
  if (defined $eprint) {&lt;br /&gt;
                my $title = $eprint-&amp;gt;get_value(&amp;quot;title&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                my $h1 = $repository-&amp;gt;make_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
                $h1-&amp;gt;appendChild($repository-&amp;gt;make_text($title));&lt;br /&gt;
       &lt;br /&gt;
                $frag-&amp;gt;appendChild($h1);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to save and package your bazaar package (or just test it in line). &lt;br /&gt;
&lt;br /&gt;
To test it point your web browser at the screen plug-in (by clicking it in the interface) and add a &amp;amp;input_field=X parameter to the end of the URL in the address bar. CHANGE X to a number which might be the id number of an EPrint.&lt;br /&gt;
&lt;br /&gt;
==Reading EPrintID from input field==&lt;br /&gt;
&lt;br /&gt;
This is an extension of the previous exercise, it does not work without it. &lt;br /&gt;
&lt;br /&gt;
To do this we need to add an input form to our render method, this is a standard HTML input form. This needs to be added ABOVE the  call to action_process_input! &lt;br /&gt;
&lt;br /&gt;
Firstly lets make a form and append it to the output ($frag):&lt;br /&gt;
&lt;br /&gt;
  my $form = $repository-&amp;gt;render_form(&amp;quot;POST&amp;quot;);&lt;br /&gt;
  ....&lt;br /&gt;
  $frag-&amp;gt;appendChild( $form );&lt;br /&gt;
&lt;br /&gt;
Next lets add an input field to hold the value the user types in and append this to the form (between the lines above):&lt;br /&gt;
&lt;br /&gt;
  my $input_field = $repository-&amp;gt;make_element(&lt;br /&gt;
                      &amp;quot;input&amp;quot;,&lt;br /&gt;
                      name=&amp;gt; &amp;quot;input_field&amp;quot;,&lt;br /&gt;
                      type=&amp;gt; &amp;quot;text&amp;quot;&lt;br /&gt;
                      );&lt;br /&gt;
  $form-&amp;gt;appendChild($input_field);&lt;br /&gt;
  &lt;br /&gt;
Then append a button which the user can press, note that a button is tied to an action on a screen, thus you can redirect people around eprints in this way to perform quiet complex actions. &lt;br /&gt;
&lt;br /&gt;
  my $submit_button = $screen-&amp;gt;render_action_button(&lt;br /&gt;
                        {&lt;br /&gt;
                        action =&amp;gt; &amp;quot;process_input&amp;quot;,&lt;br /&gt;
                        screen =&amp;gt; $screen,&lt;br /&gt;
                        screen_id =&amp;gt; $screen_id,&lt;br /&gt;
                        } );&lt;br /&gt;
  $form-&amp;gt;appendChild($submit_button);&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
NOTE: This button requires the $screen and $screen_id parameters to be set. So somewhere earlier in the render method you need to add the following two lines:&lt;br /&gt;
&lt;br /&gt;
  my $screen_id = &amp;quot;Screen::&amp;quot;.$self-&amp;gt;{processor}-&amp;gt;{screenid};&lt;br /&gt;
  my $screen = $repository-&amp;gt;plugin( $screen_id, processor =&amp;gt; $self-&amp;gt;{processor} );&lt;br /&gt;
&lt;br /&gt;
Lastly in the render method we need to CHANGE the processing code added previously to handle both ways of handing the screen an eprint_id.&lt;br /&gt;
&lt;br /&gt;
To do this, find the previously added $self-&amp;gt;action_process_input() line and change this to the following:&lt;br /&gt;
&lt;br /&gt;
  my $input_value = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  if ((!defined $eprint) and (defined $input_value)) {&lt;br /&gt;
          $self-&amp;gt;action_process_input();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Doing this will cause the input_field box which is POSTED from our form to be the primary source of eprint_id. However if there is no POST value, the render method will attempt to get the value passed in the URL.&lt;br /&gt;
&lt;br /&gt;
Lastly we need to enable the action that the button is calling but registering it as an action on the screen. To do this add the following line to the Plug-ins new method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{actions} = [qw/ process_input /];&lt;br /&gt;
&lt;br /&gt;
Actions also hold permissions that define which types of user can perform this action, in this case we are going to let everyone perform the action within this screen. The following method (which needs to be added below the can_be_viewed method) handles this. It is required!&lt;br /&gt;
&lt;br /&gt;
  sub allow_process_input&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Rendering a citation and Making a new Citation=&lt;br /&gt;
&lt;br /&gt;
==Rendering a Citation==&lt;br /&gt;
&lt;br /&gt;
This is very simple, try changing the part in the render method where we fetch the title and append it to the following line only:&lt;br /&gt;
&lt;br /&gt;
  $frag-&amp;gt;appendChild($eprint-&amp;gt;render_citation(&amp;quot;default&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
This will append the default citation for this EPrint to the screen. &lt;br /&gt;
&lt;br /&gt;
==Making a New Citation (Optional)==&lt;br /&gt;
&lt;br /&gt;
EPrint citations are defined as XML and stored in the cfg/citations/eprint/ directory (from the archive_name directory).&lt;br /&gt;
&lt;br /&gt;
You can simple copy one of the provided ones and change it to include different fields or be in a different order, more on this soon.&lt;br /&gt;
&lt;br /&gt;
=Doing a search and mapping a list (Harder)=&lt;br /&gt;
&lt;br /&gt;
Taking our existing plug-in we now want to make our input box a search term &amp;quot;Observations&amp;quot; and print out a list of EPrints.&lt;br /&gt;
&lt;br /&gt;
To do this we need to modify our action_process_input method and the render method from before. &lt;br /&gt;
&lt;br /&gt;
==Searching==&lt;br /&gt;
&lt;br /&gt;
First things first we need a place to store a list of eprints rather than just one. Let's declare (or change the existing) global variable eprints:&lt;br /&gt;
&lt;br /&gt;
  our $eprints = undef;&lt;br /&gt;
&lt;br /&gt;
Next lets change the action_process_input method to perform a search, to do this find the line which reads the &amp;quot;input_field&amp;quot; parameter and change this:&lt;br /&gt;
&lt;br /&gt;
  my $input_value = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
As this no longer represents an EPrint ID we'll rename the parameter. &lt;br /&gt;
&lt;br /&gt;
You can delete all the lines after this in the action_process_input method as we are going to replace them all.&lt;br /&gt;
&lt;br /&gt;
Next lets get the eprint dataset so we can search it:&lt;br /&gt;
&lt;br /&gt;
  my $eprint_dataset = $repository-&amp;gt;dataset( &amp;quot;eprint&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Now we are going to search on TITLE so lets define the filter for the search. Here we are doing a fuzzy search (the match =&amp;gt; EX parameter is not used). &lt;br /&gt;
&lt;br /&gt;
  my @filters = (&lt;br /&gt;
                { meta_fields =&amp;gt; [qw( title )], value =&amp;gt; $input_value },&lt;br /&gt;
                );&lt;br /&gt;
&lt;br /&gt;
Now lets do the search and assign the output to our list of eprints:&lt;br /&gt;
&lt;br /&gt;
   $eprints = $eprint_dataset-&amp;gt;search(&lt;br /&gt;
                        filters =&amp;gt; \@filters,&lt;br /&gt;
                        custom_order=&amp;gt;&amp;quot;-datestamp&amp;quot;,&lt;br /&gt;
                        limit =&amp;gt; 10,&lt;br /&gt;
                        );&lt;br /&gt;
&lt;br /&gt;
Notice that we are setting an order (based upon age) for the eprints to be listed in. Also we are limiting the number returned to 10. &lt;br /&gt;
&lt;br /&gt;
Finally lets do some error handling if the list is empty and nothing was found. This is just a little more detailed than before. &lt;br /&gt;
&lt;br /&gt;
  if (!defined $eprints or $eprints-&amp;gt;count &amp;lt; 1)&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{processor}-&amp;gt;add_message(&lt;br /&gt;
                                &amp;quot;error&amp;quot;,&lt;br /&gt;
                                $self-&amp;gt;{repository}-&amp;gt;make_text(&amp;quot;No EPrints found to match search: $input_value&amp;quot;)&lt;br /&gt;
                                );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
==Rendering the output==&lt;br /&gt;
&lt;br /&gt;
Lastly to display all the items in our list we need to change the render method.&lt;br /&gt;
&lt;br /&gt;
To do this find the place where did the rendering before (it was inside an &amp;quot;if&amp;quot; statement). &lt;br /&gt;
&lt;br /&gt;
To perform a bit more error checking lets firstly change the &amp;quot;if&amp;quot; statement slightly:&lt;br /&gt;
&lt;br /&gt;
  if (defined $eprints and $eprints-&amp;gt;count &amp;gt; 0)&lt;br /&gt;
&lt;br /&gt;
This will check there is actually something in the list as well as it being defined. &lt;br /&gt;
&lt;br /&gt;
Next we need to iterate of the items in the list and print their citations.&lt;br /&gt;
&lt;br /&gt;
This can be done using the following map function:&lt;br /&gt;
&lt;br /&gt;
   $eprints-&amp;gt;map( sub {&lt;br /&gt;
             my( undef, undef, $eprint ) = @_;&lt;br /&gt;
   &lt;br /&gt;
             $frag-&amp;gt;appendChild($eprint-&amp;gt;render_citation(&amp;quot;default&amp;quot;));&lt;br /&gt;
             $frag-&amp;gt;appendChild($repository-&amp;gt;make_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
Here we can see that each item in the list is an eprint and we can simply render a citation for each followed by a newline.&lt;br /&gt;
&lt;br /&gt;
==Extension exercise==&lt;br /&gt;
&lt;br /&gt;
* Add a new parameter to allow the user to set a custom limit to the number of results which come back as a result of a search. &lt;br /&gt;
* Tidy up your style&lt;br /&gt;
* Define all the missing phrases&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9910</id>
		<title>My First Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9910"/>
		<updated>2011-07-20T12:23:29Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: Added back in the phrases section as an extension&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will create a &amp;quot;Hello, World&amp;quot; Screen and package it as a Bazaar Package (.epm).&lt;br /&gt;
&lt;br /&gt;
=Requirements=&lt;br /&gt;
&lt;br /&gt;
You will need a working EPrints installation on which you have an administrator account. You will need to have access to the command line to create the files for the package.&lt;br /&gt;
&lt;br /&gt;
=Step 1 - Develop your package contents=&lt;br /&gt;
&lt;br /&gt;
You will need to be in the root directory of your EPrints installation (typically /opt/eprints3).&lt;br /&gt;
&lt;br /&gt;
''gedit'' is the Gnome Text editor but you can use any editor that is capable of creating text files.&lt;br /&gt;
&lt;br /&gt;
==Hello.pm==&lt;br /&gt;
&lt;br /&gt;
Create the directory to contain the ''Screen'' plugin you're going to package:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/plugins/EPrints/Plugin/Screen/&lt;br /&gt;
&lt;br /&gt;
Create the screen plugin using your preferred text editor and add the sample content below:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/plugins/EPrints/Plugin/Screen/Hello.pm&lt;br /&gt;
&lt;br /&gt;
 package EPrints::Plugin::Screen::Hello;&lt;br /&gt;
 &lt;br /&gt;
 @ISA = ( 'EPrints::Plugin::Screen' );&lt;br /&gt;
 &lt;br /&gt;
 use strict;&lt;br /&gt;
 # Make the plug-in&lt;br /&gt;
 sub new&lt;br /&gt;
 {&lt;br /&gt;
    my( $class, %params ) = @_;&lt;br /&gt;
 &lt;br /&gt;
    my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
 &lt;br /&gt;
    # Where the button to access the screen appears if anywhere, and what priority&lt;br /&gt;
    $self-&amp;gt;{appears} = [&lt;br /&gt;
       {&lt;br /&gt;
           place =&amp;gt; &amp;quot;admin_actions&amp;quot;,&lt;br /&gt;
           position =&amp;gt; 1247,&lt;br /&gt;
       },&lt;br /&gt;
    ];&lt;br /&gt;
 &lt;br /&gt;
    return $self;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # Anyone can see this screen&lt;br /&gt;
 sub can_be_viewed { 1 }&lt;br /&gt;
 &lt;br /&gt;
 # What to display&lt;br /&gt;
 sub render&lt;br /&gt;
 {&lt;br /&gt;
    my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
    # Get the current repository object (so we can access the users, eprints information about things in this repository)&lt;br /&gt;
  &lt;br /&gt;
    my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
    # Create an XML element to return to our screen&lt;br /&gt;
  &lt;br /&gt;
    my $frag = $repository-&amp;gt;xml-&amp;gt;create_document_fragment();&lt;br /&gt;
 &lt;br /&gt;
    # Fill the fragment with stuff&lt;br /&gt;
  &lt;br /&gt;
    $frag-&amp;gt;appendChild($repository-&amp;gt;xml-&amp;gt;create_text_node( &amp;quot;Hello, World!&amp;quot; ));&lt;br /&gt;
&lt;br /&gt;
    return $frag;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 1;&lt;br /&gt;
&lt;br /&gt;
==hello_world.pl==&lt;br /&gt;
&lt;br /&gt;
Create the package directory that will contain the package's configuration file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/epm/hello_world/cfg/cfg.d&lt;br /&gt;
&lt;br /&gt;
Create a configuration file that enables the plugin - this file is copied into the repository when the package is enabled:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/epm/hello_world/cfg/cfg.d/hello_world.pl&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Screen::Hello&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
&lt;br /&gt;
=Step 2 - Add an Icon=&lt;br /&gt;
&lt;br /&gt;
Create an Icon, using the icon builder at http://bazaar.eprints.org&lt;br /&gt;
&lt;br /&gt;
OR&lt;br /&gt;
&lt;br /&gt;
Download the hello_world icon from http://bazaar.eprints.org/images/hello_world.png&lt;br /&gt;
&lt;br /&gt;
Once you have this icon, name it hello_world.png and move it into the lib/static/images/epms/ directory.&lt;br /&gt;
&lt;br /&gt;
=Step 3 - Create a blank package=&lt;br /&gt;
&lt;br /&gt;
In ''Admin'' &amp;amp;rarr; ''System Tools'' &amp;amp;rarr; ''EPrints Bazaar'', select the ''Developer Tools'' tab.&lt;br /&gt;
&lt;br /&gt;
At the bottom of this screen is a form to create a new EPM. Enter the name (without quotes) &amp;quot;hello_world&amp;quot; and click ''Create''.&lt;br /&gt;
&lt;br /&gt;
You can fill out the metadata if you wish but at this stage you are only required to have a ''version'', which defaults to &amp;quot;1.0.0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
At the bottom of the screen (the ''Files'' selector) you need to add the two files you created above:&lt;br /&gt;
&lt;br /&gt;
* epm/hello_world/cfg/cfg.d/hello_world.pl&lt;br /&gt;
* plugins/EPrints/Plugin/Screen/Hello.pm&lt;br /&gt;
* static/images/epm/hello_world.png&lt;br /&gt;
&lt;br /&gt;
Click ''Save and Return'' to return to the EPrints Bazaar screen.&lt;br /&gt;
&lt;br /&gt;
If you make a mistake you can click ''Edit'' on the ''Developer Tools'' tab to re-edit the package.&lt;br /&gt;
&lt;br /&gt;
=Step 4 - Enable and test the package=&lt;br /&gt;
&lt;br /&gt;
On the EPrints Bazaar ''Installed'' tab click ''Enable'' for the '''hello_world''' package. After a short time you should see a repository configuration reloaded message.&lt;br /&gt;
&lt;br /&gt;
In ''Admin'' &amp;amp;rarr; ''System Tools'' &amp;amp;rarr; ''Misc. Tools'' you should now a button-link to your plugin (although with a missing phrase).&lt;br /&gt;
&lt;br /&gt;
You can now use ''Uninstall'' to completely remove the package and the source files created. A copy of the package will be saved in '''var/cache/epm/hello_world-1.0.0.epm'''.&lt;br /&gt;
&lt;br /&gt;
=Step 5 - Adding the missing phrases=&lt;br /&gt;
&lt;br /&gt;
As EPrints is designed to be multi-language, phrases should be used instead of embedded text.&lt;br /&gt;
&lt;br /&gt;
In this section we add the phrase file to define a name a description for our screen.&lt;br /&gt;
&lt;br /&gt;
Create the English language directory that will contain the package's English language phrase file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/lang/en/phrases/&lt;br /&gt;
&lt;br /&gt;
Create a phrase file:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/lang/en/phrases/hello_world.xml&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;iso-8859-1&amp;quot; standalone=&amp;quot;no&amp;quot; ?&amp;gt;&lt;br /&gt;
  &amp;lt;!DOCTYPE phrases SYSTEM &amp;quot;entities.dtd&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;epp:phrases xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; xmlns:epp=&amp;quot;http://eprints.org/ep3/phrase&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:title&amp;quot;&amp;gt;Hello&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:description&amp;quot;&amp;gt;My First Bazaar Package&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:text&amp;quot;&amp;gt;Hello World - This is the my first bazaar package calling.&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  &amp;lt;/epp:phrases&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Don't worry too much about the wrapping here, the important thing are the phrases of which we have created 3. &lt;br /&gt;
&lt;br /&gt;
Note that 2 of these (the top 2) will get used instantly by our package however the 3rd needs to be added to the render method of our screen. &lt;br /&gt;
&lt;br /&gt;
In order to do this edit the Hello.pm screen created in Step 1 and add the following in the appropriate place in the render method.&lt;br /&gt;
&lt;br /&gt;
  $frag-&amp;gt;appendChild($self-&amp;gt;html_phrase(&amp;quot;text&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
For some hints on loading and manipulating EPrints see [[Manipulating eprints in 3.2]].&lt;br /&gt;
&lt;br /&gt;
'''Don't Forget''' to add the phrase file to your bazaar package using the developer tools tab.&lt;br /&gt;
&lt;br /&gt;
[[Category:EPrints_Bazaar]]&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9909</id>
		<title>My First Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9909"/>
		<updated>2011-07-20T12:21:38Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will create a &amp;quot;Hello, World&amp;quot; Screen and package it as a Bazaar Package (.epm).&lt;br /&gt;
&lt;br /&gt;
=Requirements=&lt;br /&gt;
&lt;br /&gt;
You will need a working EPrints installation on which you have an administrator account. You will need to have access to the command line to create the files for the package.&lt;br /&gt;
&lt;br /&gt;
=Step 1 - Develop your package contents=&lt;br /&gt;
&lt;br /&gt;
You will need to be in the root directory of your EPrints installation (typically /opt/eprints3).&lt;br /&gt;
&lt;br /&gt;
''gedit'' is the Gnome Text editor but you can use any editor that is capable of creating text files.&lt;br /&gt;
&lt;br /&gt;
==Hello.pm==&lt;br /&gt;
&lt;br /&gt;
Create the directory to contain the ''Screen'' plugin you're going to package:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/plugins/EPrints/Plugin/Screen/&lt;br /&gt;
&lt;br /&gt;
Create the screen plugin using your preferred text editor and add the sample content below:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/plugins/EPrints/Plugin/Screen/Hello.pm&lt;br /&gt;
&lt;br /&gt;
 package EPrints::Plugin::Screen::Hello;&lt;br /&gt;
 &lt;br /&gt;
 @ISA = ( 'EPrints::Plugin::Screen' );&lt;br /&gt;
 &lt;br /&gt;
 use strict;&lt;br /&gt;
 # Make the plug-in&lt;br /&gt;
 sub new&lt;br /&gt;
 {&lt;br /&gt;
    my( $class, %params ) = @_;&lt;br /&gt;
 &lt;br /&gt;
    my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
 &lt;br /&gt;
    # Where the button to access the screen appears if anywhere, and what priority&lt;br /&gt;
    $self-&amp;gt;{appears} = [&lt;br /&gt;
       {&lt;br /&gt;
           place =&amp;gt; &amp;quot;admin_actions&amp;quot;,&lt;br /&gt;
           position =&amp;gt; 1247,&lt;br /&gt;
       },&lt;br /&gt;
    ];&lt;br /&gt;
 &lt;br /&gt;
    return $self;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # Anyone can see this screen&lt;br /&gt;
 sub can_be_viewed { 1 }&lt;br /&gt;
 &lt;br /&gt;
 # What to display&lt;br /&gt;
 sub render&lt;br /&gt;
 {&lt;br /&gt;
    my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
    # Get the current repository object (so we can access the users, eprints information about things in this repository)&lt;br /&gt;
  &lt;br /&gt;
    my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
    # Create an XML element to return to our screen&lt;br /&gt;
  &lt;br /&gt;
    my $frag = $repository-&amp;gt;xml-&amp;gt;create_document_fragment();&lt;br /&gt;
 &lt;br /&gt;
    # Fill the fragment with stuff&lt;br /&gt;
  &lt;br /&gt;
    $frag-&amp;gt;appendChild($repository-&amp;gt;xml-&amp;gt;create_text_node( &amp;quot;Hello, World!&amp;quot; ));&lt;br /&gt;
&lt;br /&gt;
    return $frag;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 1;&lt;br /&gt;
&lt;br /&gt;
==hello_world.pl==&lt;br /&gt;
&lt;br /&gt;
Create the package directory that will contain the package's configuration file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/epm/hello_world/cfg/cfg.d&lt;br /&gt;
&lt;br /&gt;
Create a configuration file that enables the plugin - this file is copied into the repository when the package is enabled:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/epm/hello_world/cfg/cfg.d/hello_world.pl&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Screen::Hello&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
&lt;br /&gt;
=Step 2 - Add an Icon=&lt;br /&gt;
&lt;br /&gt;
Create an Icon, using the icon builder at http://bazaar.eprints.org&lt;br /&gt;
&lt;br /&gt;
OR&lt;br /&gt;
&lt;br /&gt;
Download the hello_world icon from http://bazaar.eprints.org/images/hello_world.png&lt;br /&gt;
&lt;br /&gt;
Once you have this icon, name it hello_world.png and move it into the lib/static/images/epms/ directory.&lt;br /&gt;
&lt;br /&gt;
=Step 3 - Create a blank package=&lt;br /&gt;
&lt;br /&gt;
In ''Admin'' &amp;amp;rarr; ''System Tools'' &amp;amp;rarr; ''EPrints Bazaar'', select the ''Developer Tools'' tab.&lt;br /&gt;
&lt;br /&gt;
At the bottom of this screen is a form to create a new EPM. Enter the name (without quotes) &amp;quot;hello_world&amp;quot; and click ''Create''.&lt;br /&gt;
&lt;br /&gt;
You can fill out the metadata if you wish but at this stage you are only required to have a ''version'', which defaults to &amp;quot;1.0.0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
At the bottom of the screen (the ''Files'' selector) you need to add the two files you created above:&lt;br /&gt;
&lt;br /&gt;
* epm/hello_world/cfg/cfg.d/hello_world.pl&lt;br /&gt;
* plugins/EPrints/Plugin/Screen/Hello.pm&lt;br /&gt;
* static/images/epm/hello_world.png&lt;br /&gt;
&lt;br /&gt;
Click ''Save and Return'' to return to the EPrints Bazaar screen.&lt;br /&gt;
&lt;br /&gt;
If you make a mistake you can click ''Edit'' on the ''Developer Tools'' tab to re-edit the package.&lt;br /&gt;
&lt;br /&gt;
=Step 4 - Enable and test the package=&lt;br /&gt;
&lt;br /&gt;
On the EPrints Bazaar ''Installed'' tab click ''Enable'' for the '''hello_world''' package. After a short time you should see a repository configuration reloaded message.&lt;br /&gt;
&lt;br /&gt;
In ''Admin'' &amp;amp;rarr; ''System Tools'' &amp;amp;rarr; ''Misc. Tools'' you should now a button-link to your plugin (although with a missing phrase).&lt;br /&gt;
&lt;br /&gt;
You can now use ''Uninstall'' to completely remove the package and the source files created. A copy of the package will be saved in '''var/cache/epm/hello_world-1.0.0.epm'''.&lt;br /&gt;
&lt;br /&gt;
=Step 5 - Adding the missing phrases=&lt;br /&gt;
&lt;br /&gt;
As EPrints is designed to be multi-language, phrases should be used instead of embedded text.&lt;br /&gt;
&lt;br /&gt;
In this section we add the phrase file to define a name a description for our screen.&lt;br /&gt;
&lt;br /&gt;
Create the English language directory that will contain the package's English language phrase file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/lang/en/phrases/&lt;br /&gt;
&lt;br /&gt;
Create a phrase file:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/lang/en/phrases/hello_world.xml&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;iso-8859-1&amp;quot; standalone=&amp;quot;no&amp;quot; ?&amp;gt;&lt;br /&gt;
  &amp;lt;!DOCTYPE phrases SYSTEM &amp;quot;entities.dtd&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;epp:phrases xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; xmlns:epp=&amp;quot;http://eprints.org/ep3/phrase&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:title&amp;quot;&amp;gt;Hello&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:description&amp;quot;&amp;gt;My First Bazaar Package&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
        &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Hello:text&amp;quot;&amp;gt;Hello World - This is the my first bazaar package calling.&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  &amp;lt;/epp:phrases&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Don't worry too much about the wrapping here, the important thing are the phrases of which we have created 3. &lt;br /&gt;
&lt;br /&gt;
Note that 2 of these (the top 2) will get used instantly by our package however the 3rd needs to be added to the render method of our screen. &lt;br /&gt;
&lt;br /&gt;
In order to do this edit the Hello.pm screen created in Step 1 and add the following in the appropriate place in the render method.&lt;br /&gt;
&lt;br /&gt;
  $frag-&amp;gt;appendChild($self-&amp;gt;html_phrase(&amp;quot;text&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
For some hints on loading and manipulating EPrints see [[Manipulating eprints in 3.2]].&lt;br /&gt;
&lt;br /&gt;
[[Category:EPrints_Bazaar]]&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9908</id>
		<title>My First Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9908"/>
		<updated>2011-07-20T12:02:35Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: Adding icon stage&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will create a &amp;quot;Hello, World&amp;quot; Screen and package it as a Bazaar Package (.epm).&lt;br /&gt;
&lt;br /&gt;
=Requirements=&lt;br /&gt;
&lt;br /&gt;
You will need a working EPrints installation on which you have an administrator account. You will need to have access to the command line to create the files for the package.&lt;br /&gt;
&lt;br /&gt;
=Step 1 - Develop your package contents=&lt;br /&gt;
&lt;br /&gt;
You will need to be in the root directory of your EPrints installation (typically /opt/eprints3).&lt;br /&gt;
&lt;br /&gt;
''gedit'' is the Gnome Text editor but you can use any editor that is capable of creating text files.&lt;br /&gt;
&lt;br /&gt;
==Hello.pm==&lt;br /&gt;
&lt;br /&gt;
Create the directory to contain the ''Screen'' plugin you're going to package:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/plugins/EPrints/Plugin/Screen/&lt;br /&gt;
&lt;br /&gt;
Create the screen plugin using your preferred text editor and add the sample content below:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/plugins/EPrints/Plugin/Screen/Hello.pm&lt;br /&gt;
&lt;br /&gt;
 package EPrints::Plugin::Screen::Hello;&lt;br /&gt;
 &lt;br /&gt;
 @ISA = ( 'EPrints::Plugin::Screen' );&lt;br /&gt;
 &lt;br /&gt;
 use strict;&lt;br /&gt;
 # Make the plug-in&lt;br /&gt;
 sub new&lt;br /&gt;
 {&lt;br /&gt;
    my( $class, %params ) = @_;&lt;br /&gt;
 &lt;br /&gt;
    my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
 &lt;br /&gt;
    # Where the button to access the screen appears if anywhere, and what priority&lt;br /&gt;
    $self-&amp;gt;{appears} = [&lt;br /&gt;
       {&lt;br /&gt;
           place =&amp;gt; &amp;quot;admin_actions&amp;quot;,&lt;br /&gt;
           position =&amp;gt; 1247,&lt;br /&gt;
       },&lt;br /&gt;
    ];&lt;br /&gt;
 &lt;br /&gt;
    return $self;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # Anyone can see this screen&lt;br /&gt;
 sub can_be_viewed { 1 }&lt;br /&gt;
 &lt;br /&gt;
 # What to display&lt;br /&gt;
 sub render&lt;br /&gt;
 {&lt;br /&gt;
    my( $self ) = @_;&lt;br /&gt;
 &lt;br /&gt;
    my $frag = $self-&amp;gt;{repository}-&amp;gt;xml-&amp;gt;create_text_node( &amp;quot;Hello, World!&amp;quot; );&lt;br /&gt;
 &lt;br /&gt;
    return $frag;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 1;&lt;br /&gt;
&lt;br /&gt;
==hello_world.pl==&lt;br /&gt;
&lt;br /&gt;
Create the package directory that will contain the package's configuration file:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p lib/epm/hello_world/cfg/cfg.d&lt;br /&gt;
&lt;br /&gt;
Create a configuration file that enables the plugin - this file is copied into the repository when the package is enabled:&lt;br /&gt;
&lt;br /&gt;
 $ gedit lib/epm/hello_world/cfg/cfg.d/hello_world.pl&lt;br /&gt;
&lt;br /&gt;
 $c-&amp;gt;{plugins}{&amp;quot;Screen::Hello&amp;quot;}{params}{disable} = 0;&lt;br /&gt;
&lt;br /&gt;
=Step 2 - Add an Icon=&lt;br /&gt;
&lt;br /&gt;
Create an Icon, using the icon builder at http://bazaar.eprints.org&lt;br /&gt;
&lt;br /&gt;
OR&lt;br /&gt;
&lt;br /&gt;
Download the hello_world icon from http://bazaar.eprints.org/images/hello_world.png&lt;br /&gt;
&lt;br /&gt;
Once you have this icon, name it hello_world.png and move it into the lib/static/images/epms/ directory.&lt;br /&gt;
&lt;br /&gt;
=Step 3 - Create a blank package=&lt;br /&gt;
&lt;br /&gt;
In ''Admin'' &amp;amp;rarr; ''System Tools'' &amp;amp;rarr; ''EPrints Bazaar'', select the ''Developer Tools'' tab.&lt;br /&gt;
&lt;br /&gt;
At the bottom of this screen is a form to create a new EPM. Enter the name (without quotes) &amp;quot;hello_world&amp;quot; and click ''Create''.&lt;br /&gt;
&lt;br /&gt;
You can fill out the metadata if you wish but at this stage you are only required to have a ''version'', which defaults to &amp;quot;1.0.0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
At the bottom of the screen (the ''Files'' selector) you need to add the two files you created above:&lt;br /&gt;
&lt;br /&gt;
* epm/hello_world/cfg/cfg.d/hello_world.pl&lt;br /&gt;
* plugins/EPrints/Plugin/Screen/Hello.pm&lt;br /&gt;
* static/images/epm/hello_world.png&lt;br /&gt;
&lt;br /&gt;
Click ''Save and Return'' to return to the EPrints Bazaar screen.&lt;br /&gt;
&lt;br /&gt;
If you make a mistake you can click ''Edit'' on the ''Developer Tools'' tab to re-edit the package.&lt;br /&gt;
&lt;br /&gt;
=Step 4 - Enable and test the package=&lt;br /&gt;
&lt;br /&gt;
On the EPrints Bazaar ''Installed'' tab click ''Enable'' for the '''hello_world''' package. After a short time you should see a repository configuration reloaded message.&lt;br /&gt;
&lt;br /&gt;
In ''Admin'' &amp;amp;rarr; ''System Tools'' &amp;amp;rarr; ''Misc. Tools'' you should now a button-link to your plugin (although with a missing phrase).&lt;br /&gt;
&lt;br /&gt;
You can now use ''Uninstall'' to completely remove the package and the source files created. A copy of the package will be saved in '''var/cache/epm/hello_world-1.0.0.epm'''.&lt;br /&gt;
&lt;br /&gt;
For some hints on loading and manipulating EPrints see [[Manipulating eprints in 3.2]].&lt;br /&gt;
&lt;br /&gt;
[[Category:EPrints_Bazaar]]&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package&amp;diff=9848</id>
		<title>XML manipulation of the EPrints Workflow using a Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package&amp;diff=9848"/>
		<updated>2011-03-31T12:35:44Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints_Bazaar]]&lt;br /&gt;
Manipulation of built in EPrint files, such as the Workflows, is currently performed using the postinst method which is run after the rest of package is installed. &lt;br /&gt;
&lt;br /&gt;
Likewise when the package is removed, the prerm method needs to call exactly the opposite set of operations to clean itself up before full removal.&lt;br /&gt;
&lt;br /&gt;
As we go along we'll see that if you don't cleanup behind you, you won't even be able to re-install your same package again as the installer will detect conflicting data already in existence.&lt;br /&gt;
&lt;br /&gt;
=Pre-Requisites=&lt;br /&gt;
&lt;br /&gt;
To edit EPrints XML we need an epm package containing a spec file which points to a plug-in where we are going to put out postinst and prerm methods. &lt;br /&gt;
&lt;br /&gt;
Below is a simple framework for your plug-in (it's a Screen plug-in so needs to go in the cfg/plugins/EPrints/Plugin/Screen/Admin directory). Remember to name it applicably and match this name with the one in the spec file. &lt;br /&gt;
&lt;br /&gt;
NOTE: The following line:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{package_name} = &amp;quot;package_name&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
If your package name is &amp;quot;my_package&amp;quot;, this line should read:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{package_name} = &amp;quot;my_package&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
This way you don't need to type your package name in anywhere else in the code, You can just use $self-&amp;gt;{package_name} which is the variable that contains the name.&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Screen::Admin::MYNAME;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = ( 'EPrints::Plugin::Screen' );&lt;br /&gt;
   &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{actions} = [qw/ postinst prerm /];&lt;br /&gt;
        &lt;br /&gt;
        $self-&amp;gt;{package_name} = &amp;quot;package_name&amp;quot;;  &lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  } &lt;br /&gt;
  &lt;br /&gt;
  # Can this screen be viewed?&lt;br /&gt;
  sub can_be_viewed&lt;br /&gt;
  {&lt;br /&gt;
        my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Do we have a prerm method which needs executing?&lt;br /&gt;
  sub allow_action_prerm&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Do we have a postinst method which needs executing?&lt;br /&gt;
  sub allow_action_postinst&lt;br /&gt;
  {&lt;br /&gt;
        my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The postinst routine&lt;br /&gt;
  sub action_postinst&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
        &lt;br /&gt;
        # Everthing went OK (why the hell did I code this the wrong way round?)&lt;br /&gt;
        return (0,undef);&lt;br /&gt;
        # Something went wrong&lt;br /&gt;
        # return (1,&amp;quot;MUPPET!!!&amp;quot;)&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The prerm routine&lt;br /&gt;
  sub action_prerm&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        return (0,undef);&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # A render method for the screen, which we don't need unless we allow this screen to be viewed.&lt;br /&gt;
  # If this screen is visible you return an html fragment, or redirect somewhere else, like a config file :)&lt;br /&gt;
  sub render &lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return undef;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
=Remember how to force remove a broken package=&lt;br /&gt;
&lt;br /&gt;
  perl bin/epm archive_name remove package_name --force&lt;br /&gt;
&lt;br /&gt;
=Exercise 1=&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to do some simple workflow editing exercises. These follow the standard EPrints training materials which teach you how to manually edit the workflow. Here we are going to do all the same stuff with API calls. &lt;br /&gt;
&lt;br /&gt;
=Adding a Divisions Stage to the Workflow=&lt;br /&gt;
&lt;br /&gt;
Basically we are simply editing XML so all we need to do is tell the repository which file to manipulate and then give it the stuff add to this file. &lt;br /&gt;
&lt;br /&gt;
So to the '''postinst''' routine we need to add the following lines. Note that you '''don't''' need to manually specify your package_name &lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # Gap for the stuff to be defined we need to add&lt;br /&gt;
  &lt;br /&gt;
  my $rc = EPrints::XML::add_to_xml( $filename, $xml, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At the same time then it is worth adding the equivalent remove lines to the '''prerm''' method. Again you need to specify your package name. &lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  EPrints::XML::remove_package_from_xml( $filename, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Note that the remove call does not return a state as it will be able to remove anything, but it won't error if there is nothing to remove. Thus all return states are OK (this may change if someone can think of an exception)&lt;br /&gt;
&lt;br /&gt;
Lastly we need to actually tell the postinst method the block of XML to add.&lt;br /&gt;
&lt;br /&gt;
  my $xml = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;flow&amp;gt;&lt;br /&gt;
                &amp;lt;stage ref=&amp;quot;divisions&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/flow&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;divisions&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;component type=&amp;quot;Field::Subject&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;field ref=&amp;quot;divisions&amp;quot; required=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/component&amp;gt;&lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
 &amp;lt;/workflow&amp;gt;&lt;br /&gt;
 ';&lt;br /&gt;
&lt;br /&gt;
Here you can see that we can simply specify the XML as a string. We can then either parse this string and send a dom object to the add method, or simply send the string and let the add_to_xml method do it for us. &lt;br /&gt;
&lt;br /&gt;
If you want to parse it yourself you will need the following code block:&lt;br /&gt;
&lt;br /&gt;
  my $xml = EPrints::XML::parse_string( undef, $string );&lt;br /&gt;
  &lt;br /&gt;
The XML represents the exact same tree as in the workflow XML file we are attempting to edit. You can view this by clicking the &amp;quot;View Configuration&amp;quot; button on the &amp;quot;Config. Tools&amp;quot; tab of the admin screen. Once here you will need to scroll down to find the file you specified (in this case /workflows/eprint/default.xml). Since it represents the same tree, only nodes which don't exist are added and marked as belonging to your package. This marker is how they are removed. &lt;br /&gt;
&lt;br /&gt;
Alternatively you can build an XML tree using the EPrints::XML methods like make_element(&amp;quot;flow&amp;quot;) etc. At this point (unless you added blank nodes) you won't need the remove line, but it doesn't hurt to leave it in there. &lt;br /&gt;
&lt;br /&gt;
Finally make sure you have all your variables like $rc (return code) defined and then this screen should be ready.&lt;br /&gt;
&lt;br /&gt;
==Divisions Phrases==&lt;br /&gt;
&lt;br /&gt;
For the divisions screen to work fully you will need to define a number of phrases.&lt;br /&gt;
&lt;br /&gt;
As usual you need a new file, basically take a copy of cfg/lang/en/phrases/zz_webcfg in cfg/lang/en/phrases/package_name. &lt;br /&gt;
&lt;br /&gt;
The clear all the defined phrases from this file and add the follow 2:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;epp:phrase id=&amp;quot;metapage_title_divisions&amp;quot;&amp;gt;Divisions&amp;lt;/epp:phrase&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;epp:phrase id=&amp;quot;Plugin/InputForm/Component/Field/Subject:divisions_search_bar&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;ep_subjectinput_searchbar&amp;quot;&amp;gt;Search for division: &amp;lt;epc:pin name=&amp;quot;input&amp;quot;/&amp;gt; &amp;lt;epc:pin name=&amp;quot;search_button&amp;quot;/&amp;gt; &amp;lt;epc:pin name=&amp;quot;clear_button&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/epp:phrase&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Package and Test=&lt;br /&gt;
&lt;br /&gt;
Finally, package all these files up and test in from the Bazaar. Note that in the spec file you need to set your configuration file to Admin::PackageName or whatever your screen is called. &lt;br /&gt;
&lt;br /&gt;
You can test this package by click the &amp;quot;manage deposits&amp;quot;  link in the admin toolbar and adding a new item. You should see a divisions tab.&lt;br /&gt;
&lt;br /&gt;
=Exercise 2=&lt;br /&gt;
&lt;br /&gt;
Change this package to add a conditional element somewhere, for example:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;epc:if test=&amp;quot;type = 'book'&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;field ref=&amp;quot;pres_type&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/epc:if&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Experiment with this and use the &amp;quot;view configuration&amp;quot; to see what your changes do to the workflow file each time.&lt;br /&gt;
&lt;br /&gt;
Clue: The correct place to put this code block is under the &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt; tag which is in the core stage &amp;lt;stage name=&amp;quot;core&amp;quot;&amp;gt;. You need to wrap the above code blog in both these tags.&lt;br /&gt;
&lt;br /&gt;
If you are using the same package as before you will need to updated your cached version and then restart apache to make it work. This is a known bug and applies the the XML manipulation code only.&lt;br /&gt;
&lt;br /&gt;
=Exercise 3=&lt;br /&gt;
&lt;br /&gt;
Here we are going to define a whole new type &amp;quot;map&amp;quot; and a different set of stages for it.&lt;br /&gt;
&lt;br /&gt;
This exercise is also one of manual customisation exercises we run. &lt;br /&gt;
&lt;br /&gt;
==Add a new depoist type==&lt;br /&gt;
&lt;br /&gt;
This stage involves the editing of the repository namedsets, specifically the eprints namedset. &lt;br /&gt;
&lt;br /&gt;
Again this used to be an entirely manual process however it can now be done with an API call via the postinst/prerm methods:&lt;br /&gt;
&lt;br /&gt;
In '''postinst''':&lt;br /&gt;
  &lt;br /&gt;
  # Load your namedset, in this case the eprint namedset&lt;br /&gt;
  my $namedset = EPrints::NamedSet-&amp;gt;new( &amp;quot;eprint&amp;quot;,repository =&amp;gt; $repository );&lt;br /&gt;
  &lt;br /&gt;
  # Add a new option (string type, package_name, offset from top) &lt;br /&gt;
  # Setting the offset to 0 will add the item at the top of list of eprint types in this case. &lt;br /&gt;
  $namedset-&amp;gt;add_option( &amp;quot;map&amp;quot;, $self-&amp;gt;{package_name}, 0 );&lt;br /&gt;
  &lt;br /&gt;
In '''prerm''' we need the corresponding remove calls! &lt;br /&gt;
&lt;br /&gt;
  my $namedset = EPrints::NamedSet-&amp;gt;new( &amp;quot;eprint&amp;quot;,repository =&amp;gt; $repository );&lt;br /&gt;
  &lt;br /&gt;
  $namedset-&amp;gt;remove_option( &amp;quot;map&amp;quot;, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Each namedset item also needs some phrase so in our phrase file we need to add phrases for &amp;quot;eprint_typename_map&amp;quot; and &amp;quot;eprint_optdetails_type_map&amp;quot;. Lets set these to &amp;quot;Map&amp;quot; and &amp;quot;A map or chart.&amp;quot; respectively.&lt;br /&gt;
&lt;br /&gt;
==Adding a new stage and simple map workflow==&lt;br /&gt;
&lt;br /&gt;
In this section we are going to define a whole new workflow for our &amp;quot;map&amp;quot; type, so if someone selects this as their EPrint type they won't see upload (files), subjects and divisions, just a new state we going to call &amp;quot;map_stage&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Of course in order to customise the workflow we need to handle if/else statements. Helpfully there is a clever API call that does it for you. &lt;br /&gt;
&lt;br /&gt;
All we have to define in the types we want to match and the stages that these types have. Everything that doesn't match thus goes in the else condition. &lt;br /&gt;
&lt;br /&gt;
So in our postinst lets now define some variables&lt;br /&gt;
&lt;br /&gt;
  #our matching types &lt;br /&gt;
  my @types = ( &amp;quot;map&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  #the stages&lt;br /&gt;
  my @stages = ( &amp;quot;map_stage&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Then we add these to our workflow with a similar API call to before.&lt;br /&gt;
&lt;br /&gt;
  $rc = EPrints::Workflow::add_workflow_flow( $repository, $filename, $self-&amp;gt;{package_name}, \@types, \@stages );&lt;br /&gt;
&lt;br /&gt;
We can then use the xml string which we defined before to add the new stage:&lt;br /&gt;
&lt;br /&gt;
  my $string = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;map_stage&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt;&lt;br /&gt;
                     &amp;lt;title&amp;gt;Publisher Details&amp;lt;/title&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;place_of_pub&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;publisher&amp;quot; required=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;date&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;date_type&amp;quot; /&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;&lt;br /&gt;
               &amp;lt;component&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;id_number&amp;quot; /&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;&lt;br /&gt;
               &amp;lt;component&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;official_url&amp;quot;/&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;      &lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
  &amp;lt;/workflow&amp;gt;&lt;br /&gt;
  ';&lt;br /&gt;
&lt;br /&gt;
=Package and Test=&lt;br /&gt;
&lt;br /&gt;
Finally, package all these files up and test in from the Bazaar. &lt;br /&gt;
&lt;br /&gt;
You can test this package by click the &amp;quot;manage deposits&amp;quot;  link in the admin toolbar and adding a new item. You should now have a new eprint type on the first screen called &amp;quot;map&amp;quot; and selecting this will give you a much shorter workflow containing only a few fields. &lt;br /&gt;
&lt;br /&gt;
Are all your phrases defined?&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9838</id>
		<title>Using the new API</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9838"/>
		<updated>2011-03-30T14:10:14Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Reading EPrintID from input field */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints Bazaar]]&lt;br /&gt;
The new EPrints API is exposes the basic functionality of a repository in clean way. The aim of the API is to be simple to use but powerful. Some of the more complex things EPrints can do are deliberately not exposed. Our aim is that the EPrints API will remain consistent between versions of the software so your plugins wont break when you upgrade eprints.&lt;br /&gt;
&lt;br /&gt;
This exercise assumes that you have completed the [[My_First_Bazaar_Package]] exercise and will be expanding on the screen plug-in detailed in this exercise.&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to expand our screen to take a parameter and process it. We shall use the API to retrieve information from within EPrints an display it on screen.&lt;br /&gt;
&lt;br /&gt;
=Retrieving an object by ID=&lt;br /&gt;
&lt;br /&gt;
==Reading EPrint ID from Address Bar Parameter==&lt;br /&gt;
&lt;br /&gt;
In order to do this we are going to create some special action methods, these can perform operations when requested. &lt;br /&gt;
&lt;br /&gt;
Taking the screen plug-in developed in the [[My_First_Bazaar_Package]] exercise, firstly add a global screen variable which we can store an eprint object inside. &lt;br /&gt;
&lt;br /&gt;
  our $eprint = undef;&lt;br /&gt;
&lt;br /&gt;
This will be used later. &lt;br /&gt;
&lt;br /&gt;
Next we want to define a couple of new methods, the first of which reads a parameter &amp;quot;input_field&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
  my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
and then retrieves the eprint corresponding to the value set by the parameter:&lt;br /&gt;
&lt;br /&gt;
  $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
&lt;br /&gt;
In order to call these methods at the appropriate time lets add a whole method to our screen plug-in. Add the following near the top of the file:&lt;br /&gt;
&lt;br /&gt;
  sub action_process_input {&lt;br /&gt;
  &lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        ## DO SOME VALIDATION HERE MAYBE???&lt;br /&gt;
  &lt;br /&gt;
        $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
  &lt;br /&gt;
        if (!defined $eprint)&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{processor}-&amp;gt;add_message(&lt;br /&gt;
                                &amp;quot;error&amp;quot;,&lt;br /&gt;
                                $self-&amp;gt;{repository}-&amp;gt;make_text(&amp;quot;No EPrint found with ID: $eprint_id&amp;quot;)&lt;br /&gt;
                                );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point we can call this method from our existing render method to get a handle on the eprint object.&lt;br /&gt;
&lt;br /&gt;
To do this add the following to the bottom of the existing render method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;action_process_input();&lt;br /&gt;
&lt;br /&gt;
You could make the action_process_input method return the eprint rather than set it as a global, however the reason to not do this will become apparent later.&lt;br /&gt;
&lt;br /&gt;
Lastly, lets get the title of the EPrint an print it out.&lt;br /&gt;
&lt;br /&gt;
Again add the following to the bottom of our render method:&lt;br /&gt;
&lt;br /&gt;
  if (defined $eprint) {&lt;br /&gt;
                my $title = $eprint-&amp;gt;get_value(&amp;quot;title&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                my $h1 = $repository-&amp;gt;make_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
                $h1-&amp;gt;appendChild($repository-&amp;gt;make_text($title));&lt;br /&gt;
       &lt;br /&gt;
                $ret-&amp;gt;appendChild($h1);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to save and package your bazaar package (or just test it in line). &lt;br /&gt;
&lt;br /&gt;
To test it point your web browser at the screen plug-in (by clicking it in the interface) and add a &amp;amp;input_field=X parameter to the end of the URL in the address bar. CHANGE X to a number which might be the id number of an EPrint.&lt;br /&gt;
&lt;br /&gt;
==Reading EPrintID from input field==&lt;br /&gt;
&lt;br /&gt;
This is an extension of the previous exercise, it does not work without it. &lt;br /&gt;
&lt;br /&gt;
To do this we need to add an input form to our render method, this is a standard HTML input form. This needs to be added ABOVE the  call to action_process_input! &lt;br /&gt;
&lt;br /&gt;
Firstly lets make a form and append it to the output ($ret):&lt;br /&gt;
&lt;br /&gt;
  my $form = $repository-&amp;gt;render_form(&amp;quot;POST&amp;quot;);&lt;br /&gt;
  ....&lt;br /&gt;
  $ret-&amp;gt;appendChild( $form );&lt;br /&gt;
&lt;br /&gt;
Next lets add an input field to hold the value the user types in and append this to the form (between the lines above):&lt;br /&gt;
&lt;br /&gt;
  my $input_field = $repository-&amp;gt;make_element(&lt;br /&gt;
                      &amp;quot;input&amp;quot;,&lt;br /&gt;
                      name=&amp;gt; &amp;quot;input_field&amp;quot;,&lt;br /&gt;
                      type=&amp;gt; &amp;quot;text&amp;quot;&lt;br /&gt;
                      );&lt;br /&gt;
  $form-&amp;gt;appendChild($input_field);&lt;br /&gt;
  &lt;br /&gt;
Then append a button which the user can press, note that a button is tied to an action on a screen, thus you can redirect people around eprints in this way to perform quiet complex actions. &lt;br /&gt;
&lt;br /&gt;
  my $submit_button = $screen-&amp;gt;render_action_button(&lt;br /&gt;
                        {&lt;br /&gt;
                        action =&amp;gt; &amp;quot;process_input&amp;quot;,&lt;br /&gt;
                        screen =&amp;gt; $screen,&lt;br /&gt;
                        screen_id =&amp;gt; $screen_id,&lt;br /&gt;
                        } );&lt;br /&gt;
  $form-&amp;gt;appendChild($submit_button);&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
NOTE: This button requires the $screen and $screen_id parameters to be set. So somewhere earlier in the render method you need to add the following two lines:&lt;br /&gt;
&lt;br /&gt;
  my $screen_id = &amp;quot;Screen::&amp;quot;.$self-&amp;gt;{processor}-&amp;gt;{screenid};&lt;br /&gt;
  my $screen = $repository-&amp;gt;plugin( $screen_id, processor =&amp;gt; $self-&amp;gt;{processor} );&lt;br /&gt;
&lt;br /&gt;
Lastly in the render method we need to CHANGE the processing code added previously to handle both ways of handing the screen an eprint_id.&lt;br /&gt;
&lt;br /&gt;
To do this, find the previously added $self-&amp;gt;action_process_input() line and change this to the following:&lt;br /&gt;
&lt;br /&gt;
  my $input_value = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  if ((!defined $eprint) and (defined $input_value)) {&lt;br /&gt;
          $self-&amp;gt;action_process_input();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Doing this will cause the input_field box which is POSTED from our form to be the primary source of eprint_id. However if there is no POST value, the render method will attempt to get the value passed in the URL.&lt;br /&gt;
&lt;br /&gt;
Lastly we need to enable the action that the button is calling but registering it as an action on the screen. To do this add the following line to the Plug-ins new method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{actions} = [qw/ process_input /];&lt;br /&gt;
&lt;br /&gt;
Actions also hold permissions that define which types of user can perform this action, in this case we are going to let everyone perform the action within this screen. The following method (which needs to be added below the can_be_viewed method) handles this. It is required!&lt;br /&gt;
&lt;br /&gt;
  sub allow_process_input&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Rendering a citation and Making a new Citation=&lt;br /&gt;
&lt;br /&gt;
==Rendering a Citation==&lt;br /&gt;
&lt;br /&gt;
This is very simple, try changing the part in the render method where we fetch the title and append it to the following line only:&lt;br /&gt;
&lt;br /&gt;
  $ret-&amp;gt;appendChild($eprint-&amp;gt;render_citation(&amp;quot;default&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
This will append the default citation for this EPrint to the screen. &lt;br /&gt;
&lt;br /&gt;
==Making a New Citation (Optional)==&lt;br /&gt;
&lt;br /&gt;
EPrint citations are defined as XML and stored in the cfg/citations/eprint/ directory (from the archive_name directory).&lt;br /&gt;
&lt;br /&gt;
You can simple copy one of the provided ones and change it to include different fields or be in a different order, more on this soon.&lt;br /&gt;
&lt;br /&gt;
=Doing a search and mapping a list (Harder)=&lt;br /&gt;
&lt;br /&gt;
Taking our existing plug-in we now want to make our input box a search term &amp;quot;Observations&amp;quot; and print out a list of EPrints.&lt;br /&gt;
&lt;br /&gt;
To do this we need to modify our action_process_input method and the render method from before. &lt;br /&gt;
&lt;br /&gt;
==Searching==&lt;br /&gt;
&lt;br /&gt;
First things first we need a place to store a list of eprints rather than just one. Let's declare (or change the existing) global variable eprints:&lt;br /&gt;
&lt;br /&gt;
  our $eprints = undef;&lt;br /&gt;
&lt;br /&gt;
Next lets change the action_process_input method to perform a search, to do this find the line which reads the &amp;quot;input_field&amp;quot; parameter and change this:&lt;br /&gt;
&lt;br /&gt;
  my $input_value = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
As this no longer represents an EPrint ID we'll rename the parameter. &lt;br /&gt;
&lt;br /&gt;
You can delete all the lines after this in the action_process_input method as we are going to replace them all.&lt;br /&gt;
&lt;br /&gt;
Next lets get the eprint dataset so we can search it:&lt;br /&gt;
&lt;br /&gt;
  my $eprint_dataset = $repository-&amp;gt;dataset( &amp;quot;eprint&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Now we are going to search on TITLE so lets define the filter for the search. Here we are doing a fuzzy search (the match =&amp;gt; EX parameter is not used). &lt;br /&gt;
&lt;br /&gt;
  my @filters = (&lt;br /&gt;
                { meta_fields =&amp;gt; [qw( title )], value =&amp;gt; $input_value },&lt;br /&gt;
                );&lt;br /&gt;
&lt;br /&gt;
Now lets do the search and assign the output to our list of eprints:&lt;br /&gt;
&lt;br /&gt;
   $eprints = $eprint_dataset-&amp;gt;search(&lt;br /&gt;
                        filters =&amp;gt; \@filters,&lt;br /&gt;
                        custom_order=&amp;gt;&amp;quot;-datestamp&amp;quot;,&lt;br /&gt;
                        limit =&amp;gt; 10,&lt;br /&gt;
                        );&lt;br /&gt;
&lt;br /&gt;
Notice that we are setting an order (based upon age) for the eprints to be listed in. Also we are limiting the number returned to 10. &lt;br /&gt;
&lt;br /&gt;
Finally lets do some error handling if the list is empty and nothing was found. This is just a little more detailed than before. &lt;br /&gt;
&lt;br /&gt;
  if (!defined $eprints or $eprints-&amp;gt;count &amp;lt; 1)&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{processor}-&amp;gt;add_message(&lt;br /&gt;
                                &amp;quot;error&amp;quot;,&lt;br /&gt;
                                $self-&amp;gt;{repository}-&amp;gt;make_text(&amp;quot;No EPrints found to match search: $input_value&amp;quot;)&lt;br /&gt;
                                );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
==Rendering the output==&lt;br /&gt;
&lt;br /&gt;
Lastly to display all the items in our list we need to change the render method.&lt;br /&gt;
&lt;br /&gt;
To do this find the place where did the rendering before (it was inside an &amp;quot;if&amp;quot; statement). &lt;br /&gt;
&lt;br /&gt;
To perform a bit more error checking lets firstly change the &amp;quot;if&amp;quot; statement slightly:&lt;br /&gt;
&lt;br /&gt;
  if (defined $eprints and $eprints-&amp;gt;count &amp;gt; 0)&lt;br /&gt;
&lt;br /&gt;
This will check there is actually something in the list as well as it being defined. &lt;br /&gt;
&lt;br /&gt;
Next we need to iterate of the items in the list and print their citations.&lt;br /&gt;
&lt;br /&gt;
This can be done using the following map function:&lt;br /&gt;
&lt;br /&gt;
   $eprints-&amp;gt;map( sub {&lt;br /&gt;
             my( undef, undef, $eprint ) = @_;&lt;br /&gt;
   &lt;br /&gt;
             $ret-&amp;gt;appendChild($eprint-&amp;gt;render_citation(&amp;quot;default&amp;quot;));&lt;br /&gt;
             $ret-&amp;gt;appendChild($repository-&amp;gt;make_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
Here we can see that each item in the list is an eprint and we can simply render a citation for each followed by a newline.&lt;br /&gt;
&lt;br /&gt;
==Extension exercise==&lt;br /&gt;
&lt;br /&gt;
* Add a new parameter to allow the user to set a custom limit to the number of results which come back as a result of a search. &lt;br /&gt;
* Tidy up your style&lt;br /&gt;
* Define all the missing phrases&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Bazaar_Glasgow_2011&amp;diff=9831</id>
		<title>Bazaar Glasgow 2011</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Bazaar_Glasgow_2011&amp;diff=9831"/>
		<updated>2011-03-29T16:04:32Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Day 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Category:EPrints_Bazaar]]&lt;br /&gt;
=Welcome to the Glasgow EPrints Bazaar Workshop=&lt;br /&gt;
&lt;br /&gt;
The aim of the workshop is to give advanced training on the [[:Category:API|EPrints API]] and introduce the [[:Category:EPrints_Bazaar|EPrints Bazaar]]. We will also be doing individual surgeries throughout the two days to help people with specific problems they may have. Also we are looking to improve specific parts of our documentation so any suggestions for wiki pages you would like written would be gratefully received.&lt;br /&gt;
&lt;br /&gt;
==Schedule==&lt;br /&gt;
===Day 1===&lt;br /&gt;
&lt;br /&gt;
10:00 - Introduction and welcome presentation.&lt;br /&gt;
&lt;br /&gt;
10:45 - [[My_First_Bazaar_Package]]. A gentle start looking at how to make an EPrints plugin and how to turn it into a bazaar package.&lt;br /&gt;
&lt;br /&gt;
* We shall be customising this package throughout the day to achieve many different tasks with the API. &lt;br /&gt;
* Once the days is over, this package will be a good stand alone reference for the API exercises. &lt;br /&gt;
&lt;br /&gt;
11:30 - [[Using_the_new_API]]. An introduction to the API and what you can do with it including building your own searches, and manipulating datasets&lt;br /&gt;
&lt;br /&gt;
13:00 - Lunch. This is a provisional time&lt;br /&gt;
&lt;br /&gt;
14:00 - [[XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package]] - The workflow API. How bazaar modules can manipulate EPrints workflows.&lt;br /&gt;
&lt;br /&gt;
16:00 - Summary of the day and discussion.&lt;br /&gt;
&lt;br /&gt;
Extra - [[Import_and_Export_Plug-ins]] - An excercise on export and import plugins. For anyone who is particularly keen we have some extra training material&lt;br /&gt;
&lt;br /&gt;
===Day 2===&lt;br /&gt;
&lt;br /&gt;
10:00 - Adding Datasets and Triggers. A heavy duty look at how to build a Dark Archive for your repository using the API.&lt;br /&gt;
&lt;br /&gt;
1:00 - Lunch. Again timing is provisional&lt;br /&gt;
&lt;br /&gt;
2:00 - Box plugins. Find out about a simple portable way to add content to an summary page.&lt;br /&gt;
&lt;br /&gt;
3:00 - Themes. How to take you existing styles and make them portable.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Bazaar_Glasgow_2011&amp;diff=9830</id>
		<title>Bazaar Glasgow 2011</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Bazaar_Glasgow_2011&amp;diff=9830"/>
		<updated>2011-03-29T16:03:50Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Day 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Category:EPrints_Bazaar]]&lt;br /&gt;
=Welcome to the Glasgow EPrints Bazaar Workshop=&lt;br /&gt;
&lt;br /&gt;
The aim of the workshop is to give advanced training on the [[:Category:API|EPrints API]] and introduce the [[:Category:EPrints_Bazaar|EPrints Bazaar]]. We will also be doing individual surgeries throughout the two days to help people with specific problems they may have. Also we are looking to improve specific parts of our documentation so any suggestions for wiki pages you would like written would be gratefully received.&lt;br /&gt;
&lt;br /&gt;
==Schedule==&lt;br /&gt;
===Day 1===&lt;br /&gt;
&lt;br /&gt;
10:00 - Introduction and welcome presentation.&lt;br /&gt;
&lt;br /&gt;
10:45 - [[My_First_Bazaar_Package]]. A gentle start looking at how to make an EPrints plugin and how to turn it into a bazaar package.&lt;br /&gt;
&lt;br /&gt;
* We shall be customising this package throughout the day to achieve many different tasks with the API. &lt;br /&gt;
* Once the days is over, this package will be a good stand alone reference for the API exercises. &lt;br /&gt;
&lt;br /&gt;
11:30 - [[Using_the_new_API]]. An introduction to the API and what you can do with it including building your own searches, and manipulating datasets&lt;br /&gt;
&lt;br /&gt;
13:00 - Lunch. This is a provisional time&lt;br /&gt;
&lt;br /&gt;
14:00 - [[XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package]] - The workflow API. How bazaar modules can manipulate EPrints workflows.&lt;br /&gt;
&lt;br /&gt;
Extra - [[Import_and_Export_Plug-ins]] - An excercise on export and import plugins. For anyone who is particularly keen we have some extra training material&lt;br /&gt;
&lt;br /&gt;
===Day 2===&lt;br /&gt;
&lt;br /&gt;
10:00 - Adding Datasets and Triggers. A heavy duty look at how to build a Dark Archive for your repository using the API.&lt;br /&gt;
&lt;br /&gt;
1:00 - Lunch. Again timing is provisional&lt;br /&gt;
&lt;br /&gt;
2:00 - Box plugins. Find out about a simple portable way to add content to an summary page.&lt;br /&gt;
&lt;br /&gt;
3:00 - Themes. How to take you existing styles and make them portable.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9829</id>
		<title>Using the new API</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9829"/>
		<updated>2011-03-29T15:44:22Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Doing a search and mapping a list */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints Bazaar]]&lt;br /&gt;
The new EPrints API is exposes the basic functionality of a repository in clean way. The aim of the API is to be simple to use but powerful. Some of the more complex things EPrints can do are deliberately not exposed. Our aim is that the EPrints API will remain consistent between versions of the software so your plugins wont break when you upgrade eprints.&lt;br /&gt;
&lt;br /&gt;
This exercise assumes that you have completed the [[My_First_Bazaar_Package]] exercise and will be expanding on the screen plug-in detailed in this exercise.&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to expand our screen to take a parameter and process it. We shall use the API to retrieve information from within EPrints an display it on screen.&lt;br /&gt;
&lt;br /&gt;
=Retrieving an object by ID=&lt;br /&gt;
&lt;br /&gt;
==Reading EPrint ID from Address Bar Parameter==&lt;br /&gt;
&lt;br /&gt;
In order to do this we are going to create some special action methods, these can perform operations when requested. &lt;br /&gt;
&lt;br /&gt;
Taking the screen plug-in developed in the [[My_First_Bazaar_Package]] exercise, firstly add a global screen variable which we can store an eprint object inside. &lt;br /&gt;
&lt;br /&gt;
  our $eprint = undef;&lt;br /&gt;
&lt;br /&gt;
This will be used later. &lt;br /&gt;
&lt;br /&gt;
Next we want to define a couple of new methods, the first of which reads a parameter &amp;quot;input_field&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
  my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
and then retrieves the eprint corresponding to the value set by the parameter:&lt;br /&gt;
&lt;br /&gt;
  $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
&lt;br /&gt;
In order to call these methods at the appropriate time lets add a whole method to our screen plug-in. Add the following near the top of the file:&lt;br /&gt;
&lt;br /&gt;
  sub action_process_input {&lt;br /&gt;
  &lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        ## DO SOME VALIDATION HERE MAYBE???&lt;br /&gt;
  &lt;br /&gt;
        $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
  &lt;br /&gt;
        if (!defined $eprint)&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{processor}-&amp;gt;add_message(&lt;br /&gt;
                                &amp;quot;error&amp;quot;,&lt;br /&gt;
                                $self-&amp;gt;{repository}-&amp;gt;make_text(&amp;quot;No EPrint found with ID: $input_value&amp;quot;)&lt;br /&gt;
                                );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point we can call this method from our existing render method to get a handle on the eprint object.&lt;br /&gt;
&lt;br /&gt;
To do this add the following to the bottom of the existing render method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;action_process_input();&lt;br /&gt;
&lt;br /&gt;
You could make the action_process_input method return the eprint rather than set it as a global, however the reason to not do this will become apparent later.&lt;br /&gt;
&lt;br /&gt;
Lastly, lets get the title of the EPrint an print it out.&lt;br /&gt;
&lt;br /&gt;
Again add the following to the bottom of our render method:&lt;br /&gt;
&lt;br /&gt;
  if (defined $eprint) {&lt;br /&gt;
                my $title = $eprint-&amp;gt;get_value(&amp;quot;title&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                my $h1 = $repository-&amp;gt;make_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
                $h1-&amp;gt;appendChild($repository-&amp;gt;make_text($title));&lt;br /&gt;
       &lt;br /&gt;
                $ret-&amp;gt;appendChild($h1);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to save and package your bazaar package (or just test it in line). &lt;br /&gt;
&lt;br /&gt;
To test it point your web browser at the screen plug-in (by clicking it in the interface) and add a &amp;amp;input_field=X parameter to the end of the URL in the address bar. CHANGE X to a number which might be the id number of an EPrint. &lt;br /&gt;
&lt;br /&gt;
==Reading EPrintID from input field==&lt;br /&gt;
&lt;br /&gt;
This is an extension of the previous exercise, it does not work without it. &lt;br /&gt;
&lt;br /&gt;
To do this we need to add an input form to our render method, this is a standard HTML input form. This needs to be added ABOVE the  call to action_process_eprint! &lt;br /&gt;
&lt;br /&gt;
Firstly lets make a form and append it to the output ($ret):&lt;br /&gt;
&lt;br /&gt;
  my $form = $repository-&amp;gt;render_form(&amp;quot;POST&amp;quot;);&lt;br /&gt;
  $ret-&amp;gt;appendChild( $form );&lt;br /&gt;
&lt;br /&gt;
Next lets add an input field to hold the value the user types in and append this to the form:&lt;br /&gt;
&lt;br /&gt;
  my $input_field = $repository-&amp;gt;make_element(&lt;br /&gt;
                      &amp;quot;input&amp;quot;,&lt;br /&gt;
                      name=&amp;gt; &amp;quot;input_field&amp;quot;,&lt;br /&gt;
                      type=&amp;gt; &amp;quot;text&amp;quot;&lt;br /&gt;
                      );&lt;br /&gt;
  $form-&amp;gt;appendChild($input_field);&lt;br /&gt;
  &lt;br /&gt;
Then append a button which the user can press, note that a button is tied to an action on a screen, thus you can redirect people around eprints in this way to perform quiet complex actions. &lt;br /&gt;
&lt;br /&gt;
  my $submit_button = $screen-&amp;gt;render_action_button(&lt;br /&gt;
                        {&lt;br /&gt;
                        action =&amp;gt; &amp;quot;process_input&amp;quot;,&lt;br /&gt;
                        screen =&amp;gt; $screen,&lt;br /&gt;
                        screen_id =&amp;gt; $screen_id,&lt;br /&gt;
                        } );&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
NOTE: This button requires the $screen and $screen_id parameters to be set. So somewhere earlier in the render method you need to add the following two lines:&lt;br /&gt;
&lt;br /&gt;
  my $screen_id = &amp;quot;Screen::&amp;quot;.$self-&amp;gt;{processor}-&amp;gt;{screenid};&lt;br /&gt;
  my $screen = $repository-&amp;gt;plugin( $screen_id, processor =&amp;gt; $self-&amp;gt;{processor} );&lt;br /&gt;
&lt;br /&gt;
Lastly in the render method we need to CHANGE the processing code added previously to handle both ways of handing the screen an eprint_id.&lt;br /&gt;
&lt;br /&gt;
To do this, find the previously added $self-&amp;gt;action_process_input() line and change this to the following:&lt;br /&gt;
&lt;br /&gt;
  my $input_value = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  if ((!defined $eprint) and (defined $input_value)) {&lt;br /&gt;
          $self-&amp;gt;action_process_input();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Doing this will cause the input_field box which is POSTED from our form to be the primary source of eprint_id. However if there is no POST value, the render method will attempt to get the value passed in the URL.&lt;br /&gt;
&lt;br /&gt;
Lastly we need to enable the action that the button is calling but registering it as an action on the screen. To do this add the following line to the Plug-ins new method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{actions} = [qw/ process_input /];&lt;br /&gt;
&lt;br /&gt;
Actions also hold permissions that define which types of user can perform this action, in this case we are going to let everyone perform the action within this screen. The following method (which needs to be added below the can_be_viewed method) handles this. It is required!&lt;br /&gt;
&lt;br /&gt;
  sub allow_process_input&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Rendering a citation and Making a new Citation=&lt;br /&gt;
&lt;br /&gt;
==Rendering a Citation==&lt;br /&gt;
&lt;br /&gt;
This is very simple, try changing the part in the render method where we fetch the title and append it to the following line only:&lt;br /&gt;
&lt;br /&gt;
  $ret-&amp;gt;appendChild($eprint-&amp;gt;render_citation(&amp;quot;default&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
This will append the default citation for this EPrint to the screen. &lt;br /&gt;
&lt;br /&gt;
==Making a New Citation (Optional)==&lt;br /&gt;
&lt;br /&gt;
EPrint citations are defined as XML and stored in the cfg/citations/eprint/ directory (from the archive_name directory).&lt;br /&gt;
&lt;br /&gt;
You can simple copy one of the provided ones and change it to include different fields or be in a different order, more on this soon.&lt;br /&gt;
&lt;br /&gt;
=Doing a search and mapping a list (Harder)=&lt;br /&gt;
&lt;br /&gt;
Taking our existing plug-in we now want to make our input box a search term &amp;quot;Observations&amp;quot; and print out a list of EPrints.&lt;br /&gt;
&lt;br /&gt;
To do this we need to modify our action_process_input method and the render method from before. &lt;br /&gt;
&lt;br /&gt;
==Searching==&lt;br /&gt;
&lt;br /&gt;
First things first we need a place to store a list of eprints rather than just one. Let's declare (or change the existing) global variable eprints:&lt;br /&gt;
&lt;br /&gt;
  our $eprints = undef;&lt;br /&gt;
&lt;br /&gt;
Next lets change the action_process_input method to perform a search, to do this find the line which reads the &amp;quot;input_field&amp;quot; parameter and change this:&lt;br /&gt;
&lt;br /&gt;
  my $input_value = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
As this no longer represents an EPrint ID we'll rename the parameter. &lt;br /&gt;
&lt;br /&gt;
You can delete all the lines after this in the action_process_input method as we are going to replace them all.&lt;br /&gt;
&lt;br /&gt;
Next lets get the eprint dataset so we can search it:&lt;br /&gt;
&lt;br /&gt;
  my $eprint_dataset = $repository-&amp;gt;dataset( &amp;quot;eprint&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Now we are going to search on TITLE so lets define the filter for the search. Here we are doing a fuzzy search (the match =&amp;gt; EX parameter is not used). &lt;br /&gt;
&lt;br /&gt;
  my @filters = (&lt;br /&gt;
                { meta_fields =&amp;gt; [qw( title )], value =&amp;gt; $input_value },&lt;br /&gt;
                );&lt;br /&gt;
&lt;br /&gt;
Now lets do the search and assign the output to our list of eprints:&lt;br /&gt;
&lt;br /&gt;
   $eprints = $eprint_dataset-&amp;gt;search(&lt;br /&gt;
                        filters =&amp;gt; \@filters,&lt;br /&gt;
                        custom_order=&amp;gt;&amp;quot;-datestamp&amp;quot;,&lt;br /&gt;
                        limit =&amp;gt; 10,&lt;br /&gt;
                        );&lt;br /&gt;
&lt;br /&gt;
Notice that we are setting an order (based upon age) for the eprints to be listed in. Also we are limiting the number returned to 10. &lt;br /&gt;
&lt;br /&gt;
Finally lets do some error handling if the list is empty and nothing was found. This is just a little more detailed than before. &lt;br /&gt;
&lt;br /&gt;
  if (!defined $eprints or $eprints-&amp;gt;count &amp;lt; 1)&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{processor}-&amp;gt;add_message(&lt;br /&gt;
                                &amp;quot;error&amp;quot;,&lt;br /&gt;
                                $self-&amp;gt;{repository}-&amp;gt;make_text(&amp;quot;No EPrints found to match search: $input_value&amp;quot;)&lt;br /&gt;
                                );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
==Rendering the output==&lt;br /&gt;
&lt;br /&gt;
Lastly to display all the items in our list we need to change the render method.&lt;br /&gt;
&lt;br /&gt;
To do this find the place where did the rendering before (it was inside an &amp;quot;if&amp;quot; statement). &lt;br /&gt;
&lt;br /&gt;
To perform a bit more error checking lets firstly change the &amp;quot;if&amp;quot; statement slightly:&lt;br /&gt;
&lt;br /&gt;
  if (defined $eprints and $eprints-&amp;gt;count &amp;gt; 0)&lt;br /&gt;
&lt;br /&gt;
This will check there is actually something in the list as well as it being defined. &lt;br /&gt;
&lt;br /&gt;
Next we need to iterate of the items in the list and print their citations.&lt;br /&gt;
&lt;br /&gt;
This can be done using the following map function:&lt;br /&gt;
&lt;br /&gt;
   $eprints-&amp;gt;map( sub {&lt;br /&gt;
             my( undef, undef, $eprint ) = @_;&lt;br /&gt;
   &lt;br /&gt;
             $ret-&amp;gt;appendChild($eprint-&amp;gt;render_citation(&amp;quot;default&amp;quot;));&lt;br /&gt;
             $ret-&amp;gt;appendChild($repository-&amp;gt;make_element(&amp;quot;br&amp;quot;));&lt;br /&gt;
   });&lt;br /&gt;
&lt;br /&gt;
Here we can see that each item in the list is an eprint and we can simply render a citation for each followed by a newline.&lt;br /&gt;
&lt;br /&gt;
==Extension exercise==&lt;br /&gt;
&lt;br /&gt;
* Add a new parameter to allow the user to set a custom limit to the number of results which come back as a result of a search. &lt;br /&gt;
* Tidy up your style&lt;br /&gt;
* Define all the missing phrases&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9828</id>
		<title>Using the new API</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9828"/>
		<updated>2011-03-29T15:13:48Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Making a citation (optional) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints Bazaar]]&lt;br /&gt;
The new EPrints API is exposes the basic functionality of a repository in clean way. The aim of the API is to be simple to use but powerful. Some of the more complex things EPrints can do are deliberately not exposed. Our aim is that the EPrints API will remain consistent between versions of the software so your plugins wont break when you upgrade eprints.&lt;br /&gt;
&lt;br /&gt;
This exercise assumes that you have completed the [[My_First_Bazaar_Package]] exercise and will be expanding on the screen plug-in detailed in this exercise.&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to expand our screen to take a parameter and process it. We shall use the API to retrieve information from within EPrints an display it on screen.&lt;br /&gt;
&lt;br /&gt;
=Retrieving an object by ID=&lt;br /&gt;
&lt;br /&gt;
==Reading EPrint ID from Address Bar Parameter==&lt;br /&gt;
&lt;br /&gt;
In order to do this we are going to create some special action methods, these can perform operations when requested. &lt;br /&gt;
&lt;br /&gt;
Taking the screen plug-in developed in the [[My_First_Bazaar_Package]] exercise, firstly add a global screen variable which we can store an eprint object inside. &lt;br /&gt;
&lt;br /&gt;
  our $eprint = undef;&lt;br /&gt;
&lt;br /&gt;
This will be used later. &lt;br /&gt;
&lt;br /&gt;
Next we want to define a couple of new methods, the first of which reads a parameter &amp;quot;input_field&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
  my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
and then retrieves the eprint corresponding to the value set by the parameter:&lt;br /&gt;
&lt;br /&gt;
  $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
&lt;br /&gt;
In order to call these methods at the appropriate time lets add a whole method to our screen plug-in. Add the following near the top of the file:&lt;br /&gt;
&lt;br /&gt;
  sub action_process_input {&lt;br /&gt;
  &lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        ## DO SOME VALIDATION HERE MAYBE???&lt;br /&gt;
  &lt;br /&gt;
        $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
  &lt;br /&gt;
        if (!defined $eprint)&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{processor}-&amp;gt;add_message(&lt;br /&gt;
                                &amp;quot;error&amp;quot;,&lt;br /&gt;
                                $self-&amp;gt;{repository}-&amp;gt;make_text(&amp;quot;No EPrint found with ID: $input_value&amp;quot;)&lt;br /&gt;
                                );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point we can call this method from our existing render method to get a handle on the eprint object.&lt;br /&gt;
&lt;br /&gt;
To do this add the following to the bottom of the existing render method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;action_process_input();&lt;br /&gt;
&lt;br /&gt;
You could make the action_process_input method return the eprint rather than set it as a global, however the reason to not do this will become apparent later.&lt;br /&gt;
&lt;br /&gt;
Lastly, lets get the title of the EPrint an print it out.&lt;br /&gt;
&lt;br /&gt;
Again add the following to the bottom of our render method:&lt;br /&gt;
&lt;br /&gt;
  if (defined $eprint) {&lt;br /&gt;
                my $title = $eprint-&amp;gt;get_value(&amp;quot;title&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                my $h1 = $repository-&amp;gt;make_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
                $h1-&amp;gt;appendChild($repository-&amp;gt;make_text($title));&lt;br /&gt;
       &lt;br /&gt;
                $ret-&amp;gt;appendChild($h1);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to save and package your bazaar package (or just test it in line). &lt;br /&gt;
&lt;br /&gt;
To test it point your web browser at the screen plug-in (by clicking it in the interface) and add a &amp;amp;input_field=X parameter to the end of the URL in the address bar. CHANGE X to a number which might be the id number of an EPrint. &lt;br /&gt;
&lt;br /&gt;
==Reading EPrintID from input field==&lt;br /&gt;
&lt;br /&gt;
This is an extension of the previous exercise, it does not work without it. &lt;br /&gt;
&lt;br /&gt;
To do this we need to add an input form to our render method, this is a standard HTML input form. This needs to be added ABOVE the  call to action_process_eprint! &lt;br /&gt;
&lt;br /&gt;
Firstly lets make a form and append it to the output ($ret):&lt;br /&gt;
&lt;br /&gt;
  my $form = $repository-&amp;gt;render_form(&amp;quot;POST&amp;quot;);&lt;br /&gt;
  $ret-&amp;gt;appendChild( $form );&lt;br /&gt;
&lt;br /&gt;
Next lets add an input field to hold the value the user types in and append this to the form:&lt;br /&gt;
&lt;br /&gt;
  my $input_field = $repository-&amp;gt;make_element(&lt;br /&gt;
                      &amp;quot;input&amp;quot;,&lt;br /&gt;
                      name=&amp;gt; &amp;quot;input_field&amp;quot;,&lt;br /&gt;
                      type=&amp;gt; &amp;quot;text&amp;quot;&lt;br /&gt;
                      );&lt;br /&gt;
  $form-&amp;gt;appendChild($input_field);&lt;br /&gt;
  &lt;br /&gt;
Then append a button which the user can press, note that a button is tied to an action on a screen, thus you can redirect people around eprints in this way to perform quiet complex actions. &lt;br /&gt;
&lt;br /&gt;
  my $submit_button = $screen-&amp;gt;render_action_button(&lt;br /&gt;
                        {&lt;br /&gt;
                        action =&amp;gt; &amp;quot;process_input&amp;quot;,&lt;br /&gt;
                        screen =&amp;gt; $screen,&lt;br /&gt;
                        screen_id =&amp;gt; $screen_id,&lt;br /&gt;
                        } );&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
NOTE: This button requires the $screen and $screen_id parameters to be set. So somewhere earlier in the render method you need to add the following two lines:&lt;br /&gt;
&lt;br /&gt;
  my $screen_id = &amp;quot;Screen::&amp;quot;.$self-&amp;gt;{processor}-&amp;gt;{screenid};&lt;br /&gt;
  my $screen = $repository-&amp;gt;plugin( $screen_id, processor =&amp;gt; $self-&amp;gt;{processor} );&lt;br /&gt;
&lt;br /&gt;
Lastly in the render method we need to CHANGE the processing code added previously to handle both ways of handing the screen an eprint_id.&lt;br /&gt;
&lt;br /&gt;
To do this, find the previously added $self-&amp;gt;action_process_input() line and change this to the following:&lt;br /&gt;
&lt;br /&gt;
  my $input_value = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  if ((!defined $eprint) and (defined $input_value)) {&lt;br /&gt;
          $self-&amp;gt;action_process_input();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Doing this will cause the input_field box which is POSTED from our form to be the primary source of eprint_id. However if there is no POST value, the render method will attempt to get the value passed in the URL.&lt;br /&gt;
&lt;br /&gt;
Lastly we need to enable the action that the button is calling but registering it as an action on the screen. To do this add the following line to the Plug-ins new method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{actions} = [qw/ process_input /];&lt;br /&gt;
&lt;br /&gt;
Actions also hold permissions that define which types of user can perform this action, in this case we are going to let everyone perform the action within this screen. The following method (which needs to be added below the can_be_viewed method) handles this. It is required!&lt;br /&gt;
&lt;br /&gt;
  sub allow_process_input&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Rendering a citation and Making a new Citation=&lt;br /&gt;
&lt;br /&gt;
==Rendering a Citation==&lt;br /&gt;
&lt;br /&gt;
This is very simple, try changing the part in the render method where we fetch the title and append it to the following line only:&lt;br /&gt;
&lt;br /&gt;
  $ret-&amp;gt;appendChild($eprint-&amp;gt;render_citation(&amp;quot;default&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
This will append the default citation for this EPrint to the screen. &lt;br /&gt;
&lt;br /&gt;
==Making a New Citation (Optional)==&lt;br /&gt;
&lt;br /&gt;
EPrint citations are defined as XML and stored in the cfg/citations/eprint/ directory (from the archive_name directory).&lt;br /&gt;
&lt;br /&gt;
You can simple copy one of the provided ones and change it to include different fields or be in a different order, more on this soon.&lt;br /&gt;
&lt;br /&gt;
=Doing a search and mapping a list=&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9827</id>
		<title>Using the new API</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9827"/>
		<updated>2011-03-29T15:05:35Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Reading EPrintID from input field */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints Bazaar]]&lt;br /&gt;
The new EPrints API is exposes the basic functionality of a repository in clean way. The aim of the API is to be simple to use but powerful. Some of the more complex things EPrints can do are deliberately not exposed. Our aim is that the EPrints API will remain consistent between versions of the software so your plugins wont break when you upgrade eprints.&lt;br /&gt;
&lt;br /&gt;
This exercise assumes that you have completed the [[My_First_Bazaar_Package]] exercise and will be expanding on the screen plug-in detailed in this exercise.&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to expand our screen to take a parameter and process it. We shall use the API to retrieve information from within EPrints an display it on screen.&lt;br /&gt;
&lt;br /&gt;
=Retrieving an object by ID=&lt;br /&gt;
&lt;br /&gt;
==Reading EPrint ID from Address Bar Parameter==&lt;br /&gt;
&lt;br /&gt;
In order to do this we are going to create some special action methods, these can perform operations when requested. &lt;br /&gt;
&lt;br /&gt;
Taking the screen plug-in developed in the [[My_First_Bazaar_Package]] exercise, firstly add a global screen variable which we can store an eprint object inside. &lt;br /&gt;
&lt;br /&gt;
  our $eprint = undef;&lt;br /&gt;
&lt;br /&gt;
This will be used later. &lt;br /&gt;
&lt;br /&gt;
Next we want to define a couple of new methods, the first of which reads a parameter &amp;quot;input_field&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
  my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
and then retrieves the eprint corresponding to the value set by the parameter:&lt;br /&gt;
&lt;br /&gt;
  $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
&lt;br /&gt;
In order to call these methods at the appropriate time lets add a whole method to our screen plug-in. Add the following near the top of the file:&lt;br /&gt;
&lt;br /&gt;
  sub action_process_input {&lt;br /&gt;
  &lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        ## DO SOME VALIDATION HERE MAYBE???&lt;br /&gt;
  &lt;br /&gt;
        $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
  &lt;br /&gt;
        if (!defined $eprint)&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{processor}-&amp;gt;add_message(&lt;br /&gt;
                                &amp;quot;error&amp;quot;,&lt;br /&gt;
                                $self-&amp;gt;{repository}-&amp;gt;make_text(&amp;quot;No EPrint found with ID: $input_value&amp;quot;)&lt;br /&gt;
                                );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point we can call this method from our existing render method to get a handle on the eprint object.&lt;br /&gt;
&lt;br /&gt;
To do this add the following to the bottom of the existing render method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;action_process_input();&lt;br /&gt;
&lt;br /&gt;
You could make the action_process_input method return the eprint rather than set it as a global, however the reason to not do this will become apparent later.&lt;br /&gt;
&lt;br /&gt;
Lastly, lets get the title of the EPrint an print it out.&lt;br /&gt;
&lt;br /&gt;
Again add the following to the bottom of our render method:&lt;br /&gt;
&lt;br /&gt;
  if (defined $eprint) {&lt;br /&gt;
                my $title = $eprint-&amp;gt;get_value(&amp;quot;title&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                my $h1 = $repository-&amp;gt;make_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
                $h1-&amp;gt;appendChild($repository-&amp;gt;make_text($title));&lt;br /&gt;
       &lt;br /&gt;
                $ret-&amp;gt;appendChild($h1);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to save and package your bazaar package (or just test it in line). &lt;br /&gt;
&lt;br /&gt;
To test it point your web browser at the screen plug-in (by clicking it in the interface) and add a &amp;amp;input_field=X parameter to the end of the URL in the address bar. CHANGE X to a number which might be the id number of an EPrint. &lt;br /&gt;
&lt;br /&gt;
==Reading EPrintID from input field==&lt;br /&gt;
&lt;br /&gt;
This is an extension of the previous exercise, it does not work without it. &lt;br /&gt;
&lt;br /&gt;
To do this we need to add an input form to our render method, this is a standard HTML input form. This needs to be added ABOVE the  call to action_process_eprint! &lt;br /&gt;
&lt;br /&gt;
Firstly lets make a form and append it to the output ($ret):&lt;br /&gt;
&lt;br /&gt;
  my $form = $repository-&amp;gt;render_form(&amp;quot;POST&amp;quot;);&lt;br /&gt;
  $ret-&amp;gt;appendChild( $form );&lt;br /&gt;
&lt;br /&gt;
Next lets add an input field to hold the value the user types in and append this to the form:&lt;br /&gt;
&lt;br /&gt;
  my $input_field = $repository-&amp;gt;make_element(&lt;br /&gt;
                      &amp;quot;input&amp;quot;,&lt;br /&gt;
                      name=&amp;gt; &amp;quot;input_field&amp;quot;,&lt;br /&gt;
                      type=&amp;gt; &amp;quot;text&amp;quot;&lt;br /&gt;
                      );&lt;br /&gt;
  $form-&amp;gt;appendChild($input_field);&lt;br /&gt;
  &lt;br /&gt;
Then append a button which the user can press, note that a button is tied to an action on a screen, thus you can redirect people around eprints in this way to perform quiet complex actions. &lt;br /&gt;
&lt;br /&gt;
  my $submit_button = $screen-&amp;gt;render_action_button(&lt;br /&gt;
                        {&lt;br /&gt;
                        action =&amp;gt; &amp;quot;process_input&amp;quot;,&lt;br /&gt;
                        screen =&amp;gt; $screen,&lt;br /&gt;
                        screen_id =&amp;gt; $screen_id,&lt;br /&gt;
                        } );&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
NOTE: This button requires the $screen and $screen_id parameters to be set. So somewhere earlier in the render method you need to add the following two lines:&lt;br /&gt;
&lt;br /&gt;
  my $screen_id = &amp;quot;Screen::&amp;quot;.$self-&amp;gt;{processor}-&amp;gt;{screenid};&lt;br /&gt;
  my $screen = $repository-&amp;gt;plugin( $screen_id, processor =&amp;gt; $self-&amp;gt;{processor} );&lt;br /&gt;
&lt;br /&gt;
Lastly in the render method we need to CHANGE the processing code added previously to handle both ways of handing the screen an eprint_id.&lt;br /&gt;
&lt;br /&gt;
To do this, find the previously added $self-&amp;gt;action_process_input() line and change this to the following:&lt;br /&gt;
&lt;br /&gt;
  my $input_value = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  if ((!defined $eprint) and (defined $input_value)) {&lt;br /&gt;
          $self-&amp;gt;action_process_input();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Doing this will cause the input_field box which is POSTED from our form to be the primary source of eprint_id. However if there is no POST value, the render method will attempt to get the value passed in the URL.&lt;br /&gt;
&lt;br /&gt;
Lastly we need to enable the action that the button is calling but registering it as an action on the screen. To do this add the following line to the Plug-ins new method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{actions} = [qw/ process_input /];&lt;br /&gt;
&lt;br /&gt;
Actions also hold permissions that define which types of user can perform this action, in this case we are going to let everyone perform the action within this screen. The following method (which needs to be added below the can_be_viewed method) handles this. It is required!&lt;br /&gt;
&lt;br /&gt;
  sub allow_process_input&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Making a citation (optional)=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Doing a search and mapping a list=&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9826</id>
		<title>Using the new API</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9826"/>
		<updated>2011-03-29T15:05:08Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints Bazaar]]&lt;br /&gt;
The new EPrints API is exposes the basic functionality of a repository in clean way. The aim of the API is to be simple to use but powerful. Some of the more complex things EPrints can do are deliberately not exposed. Our aim is that the EPrints API will remain consistent between versions of the software so your plugins wont break when you upgrade eprints.&lt;br /&gt;
&lt;br /&gt;
This exercise assumes that you have completed the [[My_First_Bazaar_Package]] exercise and will be expanding on the screen plug-in detailed in this exercise.&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to expand our screen to take a parameter and process it. We shall use the API to retrieve information from within EPrints an display it on screen.&lt;br /&gt;
&lt;br /&gt;
=Retrieving an object by ID=&lt;br /&gt;
&lt;br /&gt;
==Reading EPrint ID from Address Bar Parameter==&lt;br /&gt;
&lt;br /&gt;
In order to do this we are going to create some special action methods, these can perform operations when requested. &lt;br /&gt;
&lt;br /&gt;
Taking the screen plug-in developed in the [[My_First_Bazaar_Package]] exercise, firstly add a global screen variable which we can store an eprint object inside. &lt;br /&gt;
&lt;br /&gt;
  our $eprint = undef;&lt;br /&gt;
&lt;br /&gt;
This will be used later. &lt;br /&gt;
&lt;br /&gt;
Next we want to define a couple of new methods, the first of which reads a parameter &amp;quot;input_field&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
  my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
and then retrieves the eprint corresponding to the value set by the parameter:&lt;br /&gt;
&lt;br /&gt;
  $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
&lt;br /&gt;
In order to call these methods at the appropriate time lets add a whole method to our screen plug-in. Add the following near the top of the file:&lt;br /&gt;
&lt;br /&gt;
  sub action_process_input {&lt;br /&gt;
  &lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        ## DO SOME VALIDATION HERE MAYBE???&lt;br /&gt;
  &lt;br /&gt;
        $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
  &lt;br /&gt;
        if (!defined $eprint)&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{processor}-&amp;gt;add_message(&lt;br /&gt;
                                &amp;quot;error&amp;quot;,&lt;br /&gt;
                                $self-&amp;gt;{repository}-&amp;gt;make_text(&amp;quot;No EPrint found with ID: $input_value&amp;quot;)&lt;br /&gt;
                                );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point we can call this method from our existing render method to get a handle on the eprint object.&lt;br /&gt;
&lt;br /&gt;
To do this add the following to the bottom of the existing render method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;action_process_input();&lt;br /&gt;
&lt;br /&gt;
You could make the action_process_input method return the eprint rather than set it as a global, however the reason to not do this will become apparent later.&lt;br /&gt;
&lt;br /&gt;
Lastly, lets get the title of the EPrint an print it out.&lt;br /&gt;
&lt;br /&gt;
Again add the following to the bottom of our render method:&lt;br /&gt;
&lt;br /&gt;
  if (defined $eprint) {&lt;br /&gt;
                my $title = $eprint-&amp;gt;get_value(&amp;quot;title&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                my $h1 = $repository-&amp;gt;make_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
                $h1-&amp;gt;appendChild($repository-&amp;gt;make_text($title));&lt;br /&gt;
       &lt;br /&gt;
                $ret-&amp;gt;appendChild($h1);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to save and package your bazaar package (or just test it in line). &lt;br /&gt;
&lt;br /&gt;
To test it point your web browser at the screen plug-in (by clicking it in the interface) and add a &amp;amp;input_field=X parameter to the end of the URL in the address bar. CHANGE X to a number which might be the id number of an EPrint. &lt;br /&gt;
&lt;br /&gt;
==Reading EPrintID from input field==&lt;br /&gt;
&lt;br /&gt;
This is an extension of the previous exercise, it does not work without it. &lt;br /&gt;
&lt;br /&gt;
To do this we need to add an input form to our render method, this is a standard HTML input form. This needs to be added ABOVE the  call to action_process_eprint! &lt;br /&gt;
&lt;br /&gt;
Firstly lets make a form and append it to the output ($ret):&lt;br /&gt;
&lt;br /&gt;
  my $form = $repository-&amp;gt;render_form(&amp;quot;POST&amp;quot;);&lt;br /&gt;
  $ret-&amp;gt;appendChild( $form );&lt;br /&gt;
&lt;br /&gt;
Next lets add an input field to hold the value the user types in and append this to the form:&lt;br /&gt;
&lt;br /&gt;
  my $input_field = $repository-&amp;gt;make_element(&lt;br /&gt;
                      &amp;quot;input&amp;quot;,&lt;br /&gt;
                      name=&amp;gt; &amp;quot;input_field&amp;quot;,&lt;br /&gt;
                      type=&amp;gt; &amp;quot;text&amp;quot;&lt;br /&gt;
                      );&lt;br /&gt;
  $form-&amp;gt;appendChild($input_field);&lt;br /&gt;
  &lt;br /&gt;
Then append a button which the user can press, note that a button is tied to an action on a screen, thus you can redirect people around eprints in this way to perform quiet complex actions. &lt;br /&gt;
&lt;br /&gt;
  my $submit_button = $screen-&amp;gt;render_action_button(&lt;br /&gt;
                        {&lt;br /&gt;
                        action =&amp;gt; &amp;quot;process_input&amp;quot;,&lt;br /&gt;
                        screen =&amp;gt; $screen,&lt;br /&gt;
                        screen_id =&amp;gt; $screen_id,&lt;br /&gt;
                        } );&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
NOTE: This button requires the $screen and $screen_id parameters to be set. So somewhere earlier in the render method you need to add the following two lines:&lt;br /&gt;
&lt;br /&gt;
  my $screen_id = &amp;quot;Screen::&amp;quot;.$self-&amp;gt;{processor}-&amp;gt;{screenid};&lt;br /&gt;
  my $screen = $repository-&amp;gt;plugin( $screen_id, processor =&amp;gt; $self-&amp;gt;{processor} );&lt;br /&gt;
&lt;br /&gt;
Lastly in the render method we need to CHANGE the processing code added previously to handle both ways of handing the screen an eprint_id.&lt;br /&gt;
&lt;br /&gt;
To do this, find the previously added $self-&amp;gt;action_process_input() line and change this to the following:&lt;br /&gt;
&lt;br /&gt;
  my $input_value = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  if ((!defined $eprint) and (defined $input_value)) {&lt;br /&gt;
          $self-&amp;gt;action_process_input();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Doing this will cause the input_field box which is POSTED from our form to be the primary source of eprint_id. However if there is no POST value, the render method will attempt to get the value passed in the URL.&lt;br /&gt;
&lt;br /&gt;
Lastly we need to enable the action that the button is calling but registering it as an action on the screen. To do this add the following line to the Plug-ins new method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;{actions} = [qw/ process_input /];&lt;br /&gt;
&lt;br /&gt;
Actions also hold permissions which defines which types of user can perform this action, in this case we are going to let everyone perform the action within this screen. The following method (which needs to be added below the can_be_viewed method) handles this. It is required!&lt;br /&gt;
&lt;br /&gt;
  sub allow_process_input&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Making a citation (optional)=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Doing a search and mapping a list=&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9825</id>
		<title>Using the new API</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Using_the_new_API&amp;diff=9825"/>
		<updated>2011-03-29T14:45:56Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:EPrints Bazaar]]&lt;br /&gt;
The new EPrints API is exposes the basic functionality of a repository in clean way. The aim of the API is to be simple to use but powerful. Some of the more complex things EPrints can do are deliberately not exposed. Our aim is that the EPrints API will remain consistent between versions of the software so your plugins wont break when you upgrade eprints.&lt;br /&gt;
&lt;br /&gt;
This exercise assumes that you have completed the [[My_First_Bazaar_Package]] exercise and will be expanding on the screen plug-in detailed in this exercise.&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to expand our screen to take a parameter and process it. We shall use the API to retrieve information from within EPrints an display it on screen.&lt;br /&gt;
&lt;br /&gt;
=Retrieving an object by ID=&lt;br /&gt;
&lt;br /&gt;
==Reading EPrint ID from Address Bar Parameter==&lt;br /&gt;
&lt;br /&gt;
In order to do this we are going to create some special action methods, these can perform operations when requested. &lt;br /&gt;
&lt;br /&gt;
Taking the screen plug-in developed in the [[My_First_Bazaar_Package]] exercise, firstly add a global screen variable which we can store an eprint object inside. &lt;br /&gt;
&lt;br /&gt;
  our $eprint = undef;&lt;br /&gt;
&lt;br /&gt;
This will be used later. &lt;br /&gt;
&lt;br /&gt;
Next we want to define a couple of new methods, the first of which reads a parameter &amp;quot;input_field&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
  my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
and then retrieves the eprint corresponding to the value set by the parameter:&lt;br /&gt;
&lt;br /&gt;
  $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
&lt;br /&gt;
In order to call these methods at the appropriate time lets add a whole method to our screen plug-in. Add the following near the top of the file:&lt;br /&gt;
&lt;br /&gt;
  sub action_process_input {&lt;br /&gt;
  &lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $eprint_id = $repository-&amp;gt;param( &amp;quot;input_field&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
        ## DO SOME VALIDATION HERE MAYBE???&lt;br /&gt;
  &lt;br /&gt;
        $eprint = $repository-&amp;gt;eprint( $eprint_id );&lt;br /&gt;
  &lt;br /&gt;
        if (!defined $eprint)&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{processor}-&amp;gt;add_message(&lt;br /&gt;
                                &amp;quot;error&amp;quot;,&lt;br /&gt;
                                $self-&amp;gt;{repository}-&amp;gt;make_text(&amp;quot;No EPrint found with ID: $input_value&amp;quot;)&lt;br /&gt;
                                );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point we can call this method from our existing render method to get a handle on the eprint object.&lt;br /&gt;
&lt;br /&gt;
To do this add the following to the bottom of the existing render method:&lt;br /&gt;
&lt;br /&gt;
  $self-&amp;gt;action_process_input();&lt;br /&gt;
&lt;br /&gt;
You could make the action_process_input method return the eprint rather than set it as a global, however the reason to not do this will become apparent later.&lt;br /&gt;
&lt;br /&gt;
Lastly, lets get the title of the EPrint an print it out.&lt;br /&gt;
&lt;br /&gt;
Again add the following to the bottom of our render method:&lt;br /&gt;
&lt;br /&gt;
  if (defined $eprint) {&lt;br /&gt;
                my $title = $eprint-&amp;gt;get_value(&amp;quot;title&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                my $h1 = $repository-&amp;gt;make_element(&amp;quot;h1&amp;quot;);&lt;br /&gt;
                $h1-&amp;gt;appendChild($repository-&amp;gt;make_text($title));&lt;br /&gt;
       &lt;br /&gt;
                $ret-&amp;gt;appendChild($h1);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to save and package your bazaar package (or just test it in line). &lt;br /&gt;
&lt;br /&gt;
To test it point your web browser at the screen plug-in (by clicking it in the interface) and add a &amp;amp;input_field=X parameter to the end of the URL in the address bar. CHANGE X to a number which might be the id number of an EPrint. &lt;br /&gt;
&lt;br /&gt;
==Reading EPrintID from input field==&lt;br /&gt;
&lt;br /&gt;
This is an extension of the previous exercise, it does not work without it. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Making a citation (optional)=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Doing a search and mapping a list=&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Bazaar_Glasgow_2011&amp;diff=9816</id>
		<title>Bazaar Glasgow 2011</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Bazaar_Glasgow_2011&amp;diff=9816"/>
		<updated>2011-03-29T10:52:40Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Day 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Category:EPrints_Bazaar]]&lt;br /&gt;
=Welcome to the Glasgow EPrints Bazaar Workshop=&lt;br /&gt;
&lt;br /&gt;
The aim of the workshop is to give advanced training on the [[:Category:API|EPrints API]] and introduce the [[:Category:EPrints_Bazaar|EPrints Bazaar]]. We will also be doing individual surgeries throughout the two days to help people with specific problems they may have. Also we are looking to improve specific parts of our documentation so any suggestions for wiki pages you would like written would be gratefully received.&lt;br /&gt;
&lt;br /&gt;
==Schedule==&lt;br /&gt;
===Day 1===&lt;br /&gt;
&lt;br /&gt;
10:00 - My first bazaar plugin. A gentle start looking at how to make an EPrints plugin and how to turn it into a bazaar package.&lt;br /&gt;
&lt;br /&gt;
* We shall be customising this package throughout the day to achieve many different tasks with the API. &lt;br /&gt;
* Once the days is over, this package will be a good stand alone reference for the API exercises. &lt;br /&gt;
&lt;br /&gt;
11:00 - The EPrints API. An introduction to the API and what you can do with it including building your own searches, and manipulating datasets&lt;br /&gt;
&lt;br /&gt;
13:00 - Lunch. This is a provisional time&lt;br /&gt;
&lt;br /&gt;
14:00 - The workflow API. How bazaar modules can manipulate EPrints workflows.&lt;br /&gt;
&lt;br /&gt;
Extra - An excercise on export and import plugins. For anyone who is particularly keen we have some extra training material&lt;br /&gt;
&lt;br /&gt;
===Day 2===&lt;br /&gt;
&lt;br /&gt;
10:00 - Adding Datasets and Triggers. A heavy duty look at how to build a Dark Archive for your repository using the API.&lt;br /&gt;
&lt;br /&gt;
1:00 - Lunch. Again timing is provisional&lt;br /&gt;
&lt;br /&gt;
2:00 - Box plugins. Find out about a simple portable way to add content to an summary page.&lt;br /&gt;
&lt;br /&gt;
3:00 - Themes. How to take you existing styles and make them portable.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Bazaar_Glasgow_2011&amp;diff=9815</id>
		<title>Bazaar Glasgow 2011</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Bazaar_Glasgow_2011&amp;diff=9815"/>
		<updated>2011-03-29T10:52:32Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Category:EPrints_Bazaar]]&lt;br /&gt;
=Welcome to the Glasgow EPrints Bazaar Workshop=&lt;br /&gt;
&lt;br /&gt;
The aim of the workshop is to give advanced training on the [[:Category:API|EPrints API]] and introduce the [[:Category:EPrints_Bazaar|EPrints Bazaar]]. We will also be doing individual surgeries throughout the two days to help people with specific problems they may have. Also we are looking to improve specific parts of our documentation so any suggestions for wiki pages you would like written would be gratefully received.&lt;br /&gt;
&lt;br /&gt;
==Schedule==&lt;br /&gt;
===Day 1===&lt;br /&gt;
&lt;br /&gt;
10:00 - My first bazaar plugin. A gentle start looking at how to make an EPrints plugin and how to turn it into a bazaar package.&lt;br /&gt;
&lt;br /&gt;
** We shall be customising this package throughout the day to achieve many different tasks with the API. &lt;br /&gt;
** Once the days is over, this package will be a good stand alone reference for the API exercises. &lt;br /&gt;
&lt;br /&gt;
11:00 - The EPrints API. An introduction to the API and what you can do with it including building your own searches, and manipulating datasets&lt;br /&gt;
&lt;br /&gt;
13:00 - Lunch. This is a provisional time&lt;br /&gt;
&lt;br /&gt;
14:00 - The workflow API. How bazaar modules can manipulate EPrints workflows.&lt;br /&gt;
&lt;br /&gt;
Extra - An excercise on export and import plugins. For anyone who is particularly keen we have some extra training material&lt;br /&gt;
&lt;br /&gt;
===Day 2===&lt;br /&gt;
&lt;br /&gt;
10:00 - Adding Datasets and Triggers. A heavy duty look at how to build a Dark Archive for your repository using the API.&lt;br /&gt;
&lt;br /&gt;
1:00 - Lunch. Again timing is provisional&lt;br /&gt;
&lt;br /&gt;
2:00 - Box plugins. Find out about a simple portable way to add content to an summary page.&lt;br /&gt;
&lt;br /&gt;
3:00 - Themes. How to take you existing styles and make them portable.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package&amp;diff=9786</id>
		<title>XML manipulation of the EPrints Workflow using a Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package&amp;diff=9786"/>
		<updated>2011-03-24T18:29:05Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Manipulation of built in EPrint files, such as the Workflows, is currently performed using the postinst method which is run after the rest of package is installed. &lt;br /&gt;
&lt;br /&gt;
Likewise when the package is removed, the prerm method needs to call exactly the opposite set of operations to clean itself up before full removal.&lt;br /&gt;
&lt;br /&gt;
As we go along we'll see that if you don't cleanup behind you, you won't even be able to re-install your same package again as the installer will detect conflicting data already in existence.&lt;br /&gt;
&lt;br /&gt;
=Pre-Requisites=&lt;br /&gt;
&lt;br /&gt;
To edit EPrints XML we need an epm package containing a spec file which points to a plug-in where we are going to put out postinst and prerm methods. &lt;br /&gt;
&lt;br /&gt;
Below is a simple framework for your plug-in (it's a Screen plug-in so needs to go in the cfg/plugins/EPrints/Plugin/Screen/Admin directory). Remember to name it applicably and match this name with the one in the spec file. &lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Screen::Admin::MYNAME;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = ( 'EPrints::Plugin::Screen' );&lt;br /&gt;
   &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{actions} = [qw/ postinst prerm /];&lt;br /&gt;
        &lt;br /&gt;
        $self-&amp;gt;{package_name} = &amp;quot;package_name&amp;quot;;  &lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  } &lt;br /&gt;
  &lt;br /&gt;
  # Can this screen be viewed?&lt;br /&gt;
  sub can_be_viewed&lt;br /&gt;
  {&lt;br /&gt;
        my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Do we have a prerm method which needs executing?&lt;br /&gt;
  sub allow_action_prerm&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Do we have a postinst method which needs executing?&lt;br /&gt;
  sub allow_action_postinst&lt;br /&gt;
  {&lt;br /&gt;
        my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The postinst routine&lt;br /&gt;
  sub action_postinst&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository}-&amp;gt;get_repository();&lt;br /&gt;
        &lt;br /&gt;
        # Everthing went OK (why the hell did I code this the wrong way round?)&lt;br /&gt;
        return (0,undef);&lt;br /&gt;
        # Something went wrong&lt;br /&gt;
        # return (1,&amp;quot;MUPPET!!!&amp;quot;)&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The prerm routine&lt;br /&gt;
  sub action_prerm&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository}-&amp;gt;get_repository();&lt;br /&gt;
  &lt;br /&gt;
        return (0,undef);&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # A render method for the screen, which we don't need unless we allow this screen to be viewed.&lt;br /&gt;
  # If this screen is visible you return an html fragment, or redirect somewhere else, like a config file :)&lt;br /&gt;
  sub render &lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return undef;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
=Remember how to force remove a broken package=&lt;br /&gt;
&lt;br /&gt;
  perl bin/epm archive_name remove package_name --force&lt;br /&gt;
&lt;br /&gt;
=Exercise 1=&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to do some simple workflow editing exercises. These follow the standard EPrints training materials which teach you how to manually edit the workflow. Here we are going to do all the same stuff with API calls. &lt;br /&gt;
&lt;br /&gt;
=Adding a Divisions Stage to the Workflow=&lt;br /&gt;
&lt;br /&gt;
Basically we are simply editing XML so all we need to do is tell the repository which file to manipulate and then give it the stuff add to this file. &lt;br /&gt;
&lt;br /&gt;
So to the '''postinst''' routine we need to add the following lines. Note that you '''don't''' need to manually specify your package_name &lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # Gap for the stuff to be defined we need to add&lt;br /&gt;
  &lt;br /&gt;
  my $rc = EPrints::XML::add_to_xml( $filename, $xml, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At the same time then it is worth adding the equivalent remove lines to the '''prerm''' method. Again you need to specify your package name. &lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  EPrints::XML::remove_package_from_xml( $filename, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Note that the remove call does not return a state as it will be able to remove anything, but it won't error if there is nothing to remove. Thus all return states are OK (this may change if someone can think of an exception)&lt;br /&gt;
&lt;br /&gt;
Lastly we need to actually tell the postinst method the block of XML to add.&lt;br /&gt;
&lt;br /&gt;
  my $string = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;flow&amp;gt;&lt;br /&gt;
                &amp;lt;stage ref=&amp;quot;divisions&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/flow&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;divisions&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;component type=&amp;quot;Field::Subject&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;field ref=&amp;quot;divisions&amp;quot; required=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/component&amp;gt;&lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
 &amp;lt;/workflow&amp;gt;&lt;br /&gt;
 ';&lt;br /&gt;
  &lt;br /&gt;
  my $xml = EPrints::XML::parse_string( undef, $string );&lt;br /&gt;
  $xml = EPrints::XML::_remove_blank_nodes($xml);&lt;br /&gt;
  my $node = $xml-&amp;gt;getFirstChild();&lt;br /&gt;
&lt;br /&gt;
Here you can see that we can simply specify the XML as a string. We can then either parse this string and send a dom object to the add method, or simply send the string and let the add_to_xml method do it for us. &lt;br /&gt;
&lt;br /&gt;
If you want to parse it yourself you will need the following code block:&lt;br /&gt;
&lt;br /&gt;
  my $xml = EPrints::XML::parse_string( undef, $string );&lt;br /&gt;
  &lt;br /&gt;
The XML represents the exact same tree as in the workflow XML file we are attempting to edit. You can view this by clicking the &amp;quot;View Configuration&amp;quot; button on the &amp;quot;Config. Tools&amp;quot; tab of the admin screen. Once here you will need to scroll down to find the file you specified (in this case /workflows/eprint/default.xml). Since it represents the same tree, only nodes which don't exist are added and marked as belonging to your package. This marker is how they are removed. &lt;br /&gt;
&lt;br /&gt;
Alternatively you can build an XML tree using the EPrints::XML methods like make_element(&amp;quot;flow&amp;quot;) etc. At this point (unless you added blank nodes) you won't need the remove line, but it doesn't hurt to leave it in there. &lt;br /&gt;
&lt;br /&gt;
Finally make sure you have all your variables like $rc (return code) defined and then this screen should be ready.&lt;br /&gt;
&lt;br /&gt;
==Divisions Phrases==&lt;br /&gt;
&lt;br /&gt;
For the divisions screen to work fully you will need to define a number of phrases.&lt;br /&gt;
&lt;br /&gt;
As usual you need a new file, basically take a copy of cfg/lang/en/phrases/zz_webcfg in cfg/lang/en/phrases/package_name. &lt;br /&gt;
&lt;br /&gt;
The clear all the defined phrases from this file and add the follow 2:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;epp:phrase id=&amp;quot;metapage_title_divisions&amp;quot;&amp;gt;Divisions&amp;lt;/epp:phrase&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;epp:phrase id=&amp;quot;Plugin/InputForm/Component/Field/Subject:divisions_search_bar&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;ep_subjectinput_searchbar&amp;quot;&amp;gt;Search for division: &amp;lt;epc:pin name=&amp;quot;input&amp;quot;/&amp;gt; &amp;lt;epc:pin name=&amp;quot;search_button&amp;quot;/&amp;gt; &amp;lt;epc:pin name=&amp;quot;clear_button&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/epp:phrase&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Package and Test=&lt;br /&gt;
&lt;br /&gt;
Finally, package all these files up and test in from the Bazaar. Note that in the spec file you need to set your configuration file to Admin::PackageName or whatever your screen is called. &lt;br /&gt;
&lt;br /&gt;
You can test this package by click the &amp;quot;manage deposits&amp;quot;  link in the admin toolbar and adding a new item. You should see a divisions tab.&lt;br /&gt;
&lt;br /&gt;
=Exercise 2=&lt;br /&gt;
&lt;br /&gt;
Change this package to add a conditional element somewhere, for example:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;epc:if test=&amp;quot;type = 'book'&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;field ref=&amp;quot;pres_type&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/epc:if&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Experiment with this and use the &amp;quot;view configuration&amp;quot; to see what your changes do to the workflow file each time.&lt;br /&gt;
&lt;br /&gt;
Clue: The correct place to put this code block is under the &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt; tag which is in the core stage &amp;lt;stage name=&amp;quot;core&amp;quot;&amp;gt;. You need to wrap the above code blog in both these tags.&lt;br /&gt;
&lt;br /&gt;
If you are using the same package as before you will need to updated your cached version and then restart apache to make it work. This is a known bug and applies the the XML manipulation code only.&lt;br /&gt;
&lt;br /&gt;
=Exercise 3=&lt;br /&gt;
&lt;br /&gt;
Here we are going to define a whole new type &amp;quot;map&amp;quot; and a different set of stages for it.&lt;br /&gt;
&lt;br /&gt;
This exercise is also one of manual customisation exercises we run. &lt;br /&gt;
&lt;br /&gt;
==Add a new depoist type==&lt;br /&gt;
&lt;br /&gt;
This stage involves the editing of the repository namedsets, specifically the eprints namedset. &lt;br /&gt;
&lt;br /&gt;
Again this used to be an entirely manual process however it can now be done with an API call via the postinst/prerm methods:&lt;br /&gt;
&lt;br /&gt;
In '''postinst''':&lt;br /&gt;
  &lt;br /&gt;
  # Load your namedset, in this case the eprint namedset&lt;br /&gt;
  my $namedset = EPrints::NamedSet-&amp;gt;new( &amp;quot;eprint&amp;quot;,repository =&amp;gt; $repository );&lt;br /&gt;
  &lt;br /&gt;
  # Add a new option (string type, package_name, offset from top) &lt;br /&gt;
  # Setting the offset to 0 will add the item at the top of list of eprint types in this case. &lt;br /&gt;
  $namedset-&amp;gt;add_option( &amp;quot;map&amp;quot;, $self-&amp;gt;{package_name}, 0 );&lt;br /&gt;
  &lt;br /&gt;
In '''prerm''' we need the corresponding remove calls! &lt;br /&gt;
&lt;br /&gt;
  my $namedset = EPrints::NamedSet-&amp;gt;new( &amp;quot;eprint&amp;quot;,repository =&amp;gt; $repository );&lt;br /&gt;
  &lt;br /&gt;
  $namedset-&amp;gt;remove_option( &amp;quot;map&amp;quot;, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Each namedset item also needs some phrase so in our phrase file we need to add phrases for &amp;quot;eprint_typename_map&amp;quot; and &amp;quot;eprint_optdetails_type_map&amp;quot;. Lets set these to &amp;quot;Map&amp;quot; and &amp;quot;A map or chart.&amp;quot; respectively.&lt;br /&gt;
&lt;br /&gt;
==Adding a new stage and simple map workflow==&lt;br /&gt;
&lt;br /&gt;
In this section we are going to define a whole new workflow for our &amp;quot;map&amp;quot; type, so if someone selects this as their EPrint type they won't see upload (files), subjects and divisions, just a new state we going to call &amp;quot;map_stage&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Of course in order to customise the workflow we need to handle if/else statements. Helpfully there is a clever API call that does it for you. &lt;br /&gt;
&lt;br /&gt;
All we have to define in the types we want to match and the stages that these types have. Everything that doesn't match thus goes in the else condition. &lt;br /&gt;
&lt;br /&gt;
So in our postinst lets now define some variables&lt;br /&gt;
&lt;br /&gt;
  #our matching types &lt;br /&gt;
  my @types = ( &amp;quot;map&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  #the stages&lt;br /&gt;
  my @stages = ( &amp;quot;map_stage&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Then we add these to our workflow with a similar API call to before.&lt;br /&gt;
&lt;br /&gt;
  $rc = EPrints::Workflow::add_workflow_flow( $repository, $filename, $self-&amp;gt;{package_name}, \@types, \@stages );&lt;br /&gt;
&lt;br /&gt;
We can then use the xml string which we defined before to add the new stage:&lt;br /&gt;
&lt;br /&gt;
  my $string = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;map_stage&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt;&lt;br /&gt;
                     &amp;lt;title&amp;gt;Publisher Details&amp;lt;/title&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;place_of_pub&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;publisher&amp;quot; required=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;date&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;date_type&amp;quot; /&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;&lt;br /&gt;
               &amp;lt;component&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;id_number&amp;quot; /&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;&lt;br /&gt;
               &amp;lt;component&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;official_url&amp;quot;/&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;      &lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
  &amp;lt;/workflow&amp;gt;&lt;br /&gt;
  ';&lt;br /&gt;
&lt;br /&gt;
=Package and Test=&lt;br /&gt;
&lt;br /&gt;
Finally, package all these files up and test in from the Bazaar. &lt;br /&gt;
&lt;br /&gt;
You can test this package by click the &amp;quot;manage deposits&amp;quot;  link in the admin toolbar and adding a new item. You should now have a new eprint type on the first screen called &amp;quot;map&amp;quot; and selecting this will give you a much shorter workflow containing only a few fields. &lt;br /&gt;
&lt;br /&gt;
Are all your phrases defined?&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9785</id>
		<title>Import and Export Plug-ins</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9785"/>
		<updated>2011-03-24T18:16:45Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Import and Export Plug-ins are all about taking an object, de-serialising it into an eprint (or other object in the EPrints system) and re-serialising it back into an object to be supported. &lt;br /&gt;
&lt;br /&gt;
We would typically advocate that every import plug-in should have a corresponding export plug-in and visa-versa.&lt;br /&gt;
&lt;br /&gt;
=Input Data=&lt;br /&gt;
&lt;br /&gt;
We are going to attempt to import the following XML record into our system. If you know the format of this record all the better else we'll leave it as a surprise for now.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;package xmlns=&amp;quot;http://www.idpf.org/2007/opf&amp;quot; unique-identifier=&amp;quot;EPB-UUID&amp;quot; version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;metadata xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
             xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;dc:title&amp;gt;The Adventures of Sherlock Holmes&amp;lt;/dc:title&amp;gt;&lt;br /&gt;
      &amp;lt;dc:creator opf:role=&amp;quot;aut&amp;quot; opf:file-as=&amp;quot;Doyle, Sir Arthur Conan&amp;quot;&amp;gt;Sir Arthur Conan Doyle&amp;lt;/dc:creator&amp;gt;&lt;br /&gt;
      &amp;lt;dc:publisher&amp;gt;epubBooks (www.epubbooks.com)&amp;lt;/dc:publisher&amp;gt;&lt;br /&gt;
      &amp;lt;dc:date opf:event=&amp;quot;epub-publication&amp;quot;&amp;gt;2010-06-15&amp;lt;/dc:date&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Crime/Detective&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Short Stories&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:source&amp;gt;Project Gutenberg&amp;lt;/dc:source&amp;gt;&lt;br /&gt;
      &amp;lt;dc:rights&amp;gt;&lt;br /&gt;
            Provided for free by epubBooks.com. Not for commercial use.&lt;br /&gt;
            This EPUB eBook is released under a Creative Commons (BY-NC-ND/3.0) Licence.&lt;br /&gt;
            Source text and images are in the Public Domain.&lt;br /&gt;
      &amp;lt;/dc:rights&amp;gt;&lt;br /&gt;
      &amp;lt;dc:identifier id=&amp;quot;EPB-UUID&amp;quot;&amp;gt;urn:uuid:FF946905-6C08-1014-90EA-E81F8523F0DC&amp;lt;/dc:identifier&amp;gt;&lt;br /&gt;
      &amp;lt;dc:language&amp;gt;en-gb&amp;lt;/dc:language&amp;gt;&lt;br /&gt;
   &amp;lt;/metadata&amp;gt;&lt;br /&gt;
   &amp;lt;manifest&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/manifest&amp;gt;&lt;br /&gt;
   &amp;lt;spine&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/spine&amp;gt;&lt;br /&gt;
  &amp;lt;/package&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Importing=&lt;br /&gt;
&lt;br /&gt;
To import this record we need a fully featured import plug-in which is capable of handle both file and raw XML input, we are also going to use an XSLT plug-ins to make the process even easier. &lt;br /&gt;
&lt;br /&gt;
==The Files==&lt;br /&gt;
&lt;br /&gt;
We need the following:&lt;br /&gt;
&lt;br /&gt;
* cfg/plugins/EPrints/Plugin/Import/OPFXML.pm&lt;br /&gt;
* cfg/plugins/EPrints/Plugin/Import/XSLT/DC.xsl&lt;br /&gt;
&lt;br /&gt;
===OPFXML.pm===&lt;br /&gt;
&lt;br /&gt;
This will be our master import plug-in to handle the entire chunk of XML. We will then use the DC plug-in to map the metadata into an eprint we can use later. &lt;br /&gt;
&lt;br /&gt;
Since this is the master plug-in this requires quiet a sizeable amount of code:&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Import::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  # Declare Namespaces&lt;br /&gt;
  our $DC_NS = &amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;;&lt;br /&gt;
  our $DCTERMS_NS = &amp;quot;http://purl.org/dc/terms/&amp;quot;;&lt;br /&gt;
  our $OPF_NS = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # This is just a variant of the DefaultXML plug-in&lt;br /&gt;
  use EPrints::Plugin::Import::DefaultXML;&lt;br /&gt;
  &lt;br /&gt;
  our @ISA = qw/ EPrints::Plugin::Import::DefaultXML /;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;OPF Resource&amp;quot;;&lt;br /&gt;
        # Make it visible on the import menu and elsewhere&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{produce} = [ 'list/eprint', 'dataobj/eprint' ];&lt;br /&gt;
  &lt;br /&gt;
        # Functionality to recognise XML types on import by recognising the base namespace, works with the sword packaging format, dc:conformsTo or similar.&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $rc = EPrints::Utils::require_if_exists(&amp;quot;MIME::Types&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        unless( $rc )&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{visible} = &amp;quot;&amp;quot;;&lt;br /&gt;
                $self-&amp;gt;{error} = &amp;quot;Failed to load required module MIME::Types&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Input File Handle Method, for when files are uploaded&lt;br /&gt;
  sub input_fh&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $fh = $opts{&amp;quot;fh&amp;quot;};&lt;br /&gt;
  &lt;br /&gt;
        my $xml = join &amp;quot;&amp;quot;, &amp;lt;$fh&amp;gt;;&lt;br /&gt;
  &lt;br /&gt;
        my $list;&lt;br /&gt;
  &lt;br /&gt;
        if( $xml =~ /^&amp;lt;\?xml/ )&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_xml( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_list( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        $list ||= EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [] );&lt;br /&gt;
  &lt;br /&gt;
        return $list;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Handle direct XML input&lt;br /&gt;
  sub input_fh_xml&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $xml, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $doc = EPrints::XML::parse_xml_string( $xml );&lt;br /&gt;
  &lt;br /&gt;
        my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
        EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [defined($dataobj) ? $dataobj-&amp;gt;get_id : ()] );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Go grab input from a URL&lt;br /&gt;
  sub input_fh_list&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $url, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $url =~ s/\s+//g;&lt;br /&gt;
  &lt;br /&gt;
        my $tmpfile = File::Temp-&amp;gt;new;&lt;br /&gt;
  &lt;br /&gt;
        my $r = EPrints::Utils::wget( $plugin-&amp;gt;{session}, $url, $tmpfile );&lt;br /&gt;
        seek($tmpfile,0,0);&lt;br /&gt;
  &lt;br /&gt;
        if( $r-&amp;gt;is_error )&lt;br /&gt;
        {&lt;br /&gt;
                $plugin-&amp;gt;error( &amp;quot;Error reading resource from $url: &amp;quot;.$r-&amp;gt;code.&amp;quot; &amp;quot;.$r-&amp;gt;message );&lt;br /&gt;
                return;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        my @ids;&lt;br /&gt;
  &lt;br /&gt;
        while(my $url = &amp;lt;$tmpfile&amp;gt;)&lt;br /&gt;
        {&lt;br /&gt;
                $url =~ s/\s+//g;&lt;br /&gt;
                next unless $url =~ /^http/;&lt;br /&gt;
  &lt;br /&gt;
                my $doc;&lt;br /&gt;
                eval { $doc = EPrints::XML::parse_url( $url ) };&lt;br /&gt;
                if( $@ )&lt;br /&gt;
                {&lt;br /&gt;
                        $plugin-&amp;gt;warning( &amp;quot;Error parsing: $url\n&amp;quot; );&lt;br /&gt;
                }&lt;br /&gt;
  &lt;br /&gt;
                my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
                EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
                if( defined $dataobj )&lt;br /&gt;
                {&lt;br /&gt;
                        push @ids, $dataobj-&amp;gt;get_id;&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
          &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; \@ids );&lt;br /&gt;
  }&lt;br /&gt;
  # Translate this XML into an EPrint&lt;br /&gt;
  sub xml_to_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        # $xml is the PubmedArticle element&lt;br /&gt;
        my( $plugin, $dataset, $xml ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $session = $plugin-&amp;gt;{session};&lt;br /&gt;
  &lt;br /&gt;
        # Locate the metadata element&lt;br /&gt;
        my $metadata = $xml-&amp;gt;getElementsByTagNameNS( $OPF_NS, &amp;quot;metadata&amp;quot; )-&amp;gt;[0];&lt;br /&gt;
  &lt;br /&gt;
        # Load the DC plugin&lt;br /&gt;
        my $dc_plugin = $session-&amp;gt;plugin( &amp;quot;Import::XSLT::DC&amp;quot;,&lt;br /&gt;
                processor =&amp;gt; $plugin-&amp;gt;{processor},&lt;br /&gt;
                dataset =&amp;gt; $dataset,&lt;br /&gt;
        );&lt;br /&gt;
  &lt;br /&gt;
        $dc_plugin-&amp;gt;{Handler} = $plugin-&amp;gt;{Handler};&lt;br /&gt;
        $dc_plugin-&amp;gt;{parse_only} = $plugin-&amp;gt;{parse_only};&lt;br /&gt;
  &lt;br /&gt;
        # Spew the metadata element to a temp file&lt;br /&gt;
        my $tmpfile2 = File::Temp-&amp;gt;new;&lt;br /&gt;
        print $tmpfile2 $metadata-&amp;gt;toString();&lt;br /&gt;
        seek($tmpfile2,0,0);&lt;br /&gt;
  &lt;br /&gt;
        # Parse the file using the plug-in to get back a list of eprints&lt;br /&gt;
        my $list = $dc_plugin-&amp;gt;input_fh( fh =&amp;gt; $tmpfile2, dataset =&amp;gt; $dataset );&lt;br /&gt;
  &lt;br /&gt;
        my( $eprint ) = $list-&amp;gt;get_records( 0, 1 );&lt;br /&gt;
  &lt;br /&gt;
        return $eprint;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
===XSLT/DC.xsl===&lt;br /&gt;
&lt;br /&gt;
Using XSLT is really quiet a nice way of parsing data and well documented so I shouldn't have to say much about how this works here.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!-- DC Transformation --&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:stylesheet&lt;br /&gt;
        version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
        xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
        ept:name=&amp;quot;DC&amp;quot;&lt;br /&gt;
        ept:visible=&amp;quot;all&amp;quot;&lt;br /&gt;
        ept:advertise=&amp;quot;1&amp;quot;&lt;br /&gt;
        ept:sourceNamespace=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        ept:targetNamespace=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
        ept:produce=&amp;quot;list/eprint&amp;quot;&lt;br /&gt;
        xmlns:ept=&amp;quot;http://eprints.org/ep2/xslt/1.0&amp;quot;&lt;br /&gt;
        xmlns:oai_dc=&amp;quot;http://www.openarchives.org/OAI/2.0/oai_dc/&amp;quot;&lt;br /&gt;
        xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
        xmlns=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
  &amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; indent=&amp;quot;yes&amp;quot; encoding=&amp;quot;utf-8&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;eprints&amp;gt;&lt;br /&gt;
        &amp;lt;eprint&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;./*&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;eprint_status&amp;gt;inbox&amp;lt;/eprint_status&amp;gt;&lt;br /&gt;
        &amp;lt;creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:creator&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&amp;lt;name&amp;gt;&amp;lt;family/&amp;gt;&amp;lt;given&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot;/&amp;gt;&amp;lt;/given&amp;gt;&amp;lt;/name&amp;gt;&amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/creators&amp;gt;&lt;br /&gt;
        &amp;lt;corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:source&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&lt;br /&gt;
                        &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;keywords&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:subject&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;,&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/keywords&amp;gt;&lt;br /&gt;
        &amp;lt;/eprint&amp;gt;&lt;br /&gt;
        &amp;lt;/eprints&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:title&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:publisher&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;publisher&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/publisher&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:rights&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;copyright_holders&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/copyright_holders&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:date&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;date&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/date&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:identifier&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;id_number&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/id_number&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!--Ignored at this level--&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:language|dc:subject|dc:source|dc:creator&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
You can test your plug-ins by simply clicking on the &amp;quot;manage deposits&amp;quot; button in your toolbar and selecting &amp;quot;OPF Resource&amp;quot; from the drop down list of import plug-ins. If it doesn't appear restart you web server and check the error log!&lt;br /&gt;
&lt;br /&gt;
Reminder:&lt;br /&gt;
&lt;br /&gt;
  apache2ctl restart &amp;amp;&amp;amp; tail -f /var/log/apache2/error.log&lt;br /&gt;
&lt;br /&gt;
Once you have the import screen, copy and paste the XML from the top of this exercise into it and see if it creates you an EPrint (which you can see back at the manage deposits screen)&lt;br /&gt;
&lt;br /&gt;
=Exporting=&lt;br /&gt;
&lt;br /&gt;
So now we have imported our EPrint from this OPF format we need to be able to put it back into this format for exporting, this has the advantage that you can also export ALL other eprints in this format.&lt;br /&gt;
&lt;br /&gt;
We did most of the work on the importing so now it's your turn below is the basis of the Export plug-in which you can use to get started. To give you a clue this export plug-in needs to be located in cfg/plugins/EPrints/Plugin/Export/OPFXML.pm&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Export::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Export::XMLFile;&lt;br /&gt;
  @ISA = ( &amp;quot;EPrints::Plugin::Export::XMLFile&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %opts ) = @_;&lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new( %opts );&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;Open Packaging Format XML&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # This plug-in can only output a single eprint record, no lists or other types of objects&lt;br /&gt;
        $self-&amp;gt;{accept} = [ 'dataobj/eprint' ];&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Specify the mimetype so we can use an HTTP ACCEPT header to get this back.&lt;br /&gt;
        $self-&amp;gt;{mimetype} = &amp;quot;application/oebps-package+xml; charset=utf-8&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Again specify what we are exporting&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{schemaLocation} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Method which is called to output the eprint, we would have output_list if we could handle lists&lt;br /&gt;
  sub output_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $dataobj ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $xml = $plugin-&amp;gt;xml_dataobj( $dataobj );&lt;br /&gt;
  &lt;br /&gt;
        return &amp;quot;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&amp;quot; . EPrints::XML::to_string( $xml );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The method which actually does the work&lt;br /&gt;
  sub xml_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $eprint ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repo = $plugin-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $package = $repo-&amp;gt;make_element(&amp;quot;package&amp;quot;, xmlns=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;unique-identifier&amp;quot;=&amp;gt;&amp;quot;EPB-UUID&amp;quot;, version=&amp;gt;&amp;quot;2.0&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        my $metadata = $repo-&amp;gt;make_element(&amp;quot;metadata&amp;quot;, &amp;quot;xmlns:opf&amp;quot;=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;xmlns:dc&amp;quot;=&amp;gt;&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;);&lt;br /&gt;
        $package-&amp;gt;appendChild($metadata);&lt;br /&gt;
  &lt;br /&gt;
        my $title = $repo-&amp;gt;make_element(&amp;quot;dc:title&amp;quot;);&lt;br /&gt;
        $title-&amp;gt;appendText($eprint-&amp;gt;value(&amp;quot;title&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        $metadata-&amp;gt;appendChild($title);&lt;br /&gt;
  &lt;br /&gt;
        if( $eprint-&amp;gt;exists_and_set( &amp;quot;creators&amp;quot; ) )&lt;br /&gt;
        {&lt;br /&gt;
                foreach my $name ( @{ $eprint-&amp;gt;get_value( &amp;quot;creators&amp;quot; ) } )&lt;br /&gt;
                {&lt;br /&gt;
                        # given name first&lt;br /&gt;
                        my $creator = $repo-&amp;gt;make_element(&amp;quot;dc:creator&amp;quot;);&lt;br /&gt;
                        $creator-&amp;gt;appendText(EPrints::Utils::make_name_string( $name-&amp;gt;{name}, 1 ));&lt;br /&gt;
                        $metadata-&amp;gt;appendChild($creator);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
        return $package;&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
This is no where near as complete as the original input from above, can you make the 2 match?&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
This is an easy one. &lt;br /&gt;
* Find the eprint you imported&lt;br /&gt;
* Click the Actions Tab&lt;br /&gt;
* Locate the Export options at the bottom of this tab&lt;br /&gt;
* Find your export plug-in (by name) and click it&lt;br /&gt;
&lt;br /&gt;
=Wrap it as a package=&lt;br /&gt;
&lt;br /&gt;
Once again, now this is working you want to remove the files and package them up with a spec file and icon. Then remove the files from your local install and try doing an install via the Bazaar to see if it works.&lt;br /&gt;
&lt;br /&gt;
Why not see the export plug-in working via a GET request to the id url of the eprint http://archive.org/id/eprint/XXX with the ACCEPT header set to the mime-type of your desired export plug-in. This is quick proof that content negotiation works in EPrints and it's that easy to add a new exporter.&lt;br /&gt;
&lt;br /&gt;
=Extension Exercises=&lt;br /&gt;
&lt;br /&gt;
This whole exercise has been the beginning of importing the epub format into EPrints!&lt;br /&gt;
&lt;br /&gt;
If you are feeling keen see if you can scope out or develop this further to import more of the format, maybe some of the chapters etc. &lt;br /&gt;
&lt;br /&gt;
The full epub for this book is available @ http://www.epubbooks.com/book/378/adventures-of-sherlock-holmes and you have been importing a small section of the epb.opf file which is listed in the META-INF/container.xml&lt;br /&gt;
&lt;br /&gt;
epub is a format we are keen to see EPrints support and there may be a bounty available for the first person to develop a complete Bazaar Package to support them.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9784</id>
		<title>Import and Export Plug-ins</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Import_and_Export_Plug-ins&amp;diff=9784"/>
		<updated>2011-03-24T18:15:34Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Import and Export Plug-ins are all about taking an object, de-serialising it into an eprint (or other object in the EPrints system) and re-serialising it back into an object to be supported. &lt;br /&gt;
&lt;br /&gt;
We would typically advocate that every import plug-in should have a corresponding export plug-in and visa-versa.&lt;br /&gt;
&lt;br /&gt;
=Input Data=&lt;br /&gt;
&lt;br /&gt;
We are going to attempt to import the following XML record into our system. If you know the format of this record all the better else we'll leave it as a surprise for now.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;package xmlns=&amp;quot;http://www.idpf.org/2007/opf&amp;quot; unique-identifier=&amp;quot;EPB-UUID&amp;quot; version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;metadata xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
             xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;dc:title&amp;gt;The Adventures of Sherlock Holmes&amp;lt;/dc:title&amp;gt;&lt;br /&gt;
      &amp;lt;dc:creator opf:role=&amp;quot;aut&amp;quot; opf:file-as=&amp;quot;Doyle, Sir Arthur Conan&amp;quot;&amp;gt;Sir Arthur Conan Doyle&amp;lt;/dc:creator&amp;gt;&lt;br /&gt;
      &amp;lt;dc:publisher&amp;gt;epubBooks (www.epubbooks.com)&amp;lt;/dc:publisher&amp;gt;&lt;br /&gt;
      &amp;lt;dc:date opf:event=&amp;quot;epub-publication&amp;quot;&amp;gt;2010-06-15&amp;lt;/dc:date&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Crime/Detective&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:subject&amp;gt;Short Stories&amp;lt;/dc:subject&amp;gt;&lt;br /&gt;
      &amp;lt;dc:source&amp;gt;Project Gutenberg&amp;lt;/dc:source&amp;gt;&lt;br /&gt;
      &amp;lt;dc:rights&amp;gt;&lt;br /&gt;
            Provided for free by epubBooks.com. Not for commercial use.&lt;br /&gt;
            This EPUB eBook is released under a Creative Commons (BY-NC-ND/3.0) Licence.&lt;br /&gt;
            Source text and images are in the Public Domain.&lt;br /&gt;
      &amp;lt;/dc:rights&amp;gt;&lt;br /&gt;
      &amp;lt;dc:identifier id=&amp;quot;EPB-UUID&amp;quot;&amp;gt;urn:uuid:FF946905-6C08-1014-90EA-E81F8523F0DC&amp;lt;/dc:identifier&amp;gt;&lt;br /&gt;
      &amp;lt;dc:language&amp;gt;en-gb&amp;lt;/dc:language&amp;gt;&lt;br /&gt;
   &amp;lt;/metadata&amp;gt;&lt;br /&gt;
   &amp;lt;manifest&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/manifest&amp;gt;&lt;br /&gt;
   &amp;lt;spine&amp;gt;&lt;br /&gt;
      &amp;lt;!-- Data not included --&amp;gt;&lt;br /&gt;
   &amp;lt;/spine&amp;gt;&lt;br /&gt;
  &amp;lt;/package&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Importing=&lt;br /&gt;
&lt;br /&gt;
To import this record we need a fully featured import plug-in which is capable of handle both file and raw XML input, we are also going to use an XSLT plug-ins to make the process even easier. &lt;br /&gt;
&lt;br /&gt;
==The Files==&lt;br /&gt;
&lt;br /&gt;
We need the following:&lt;br /&gt;
&lt;br /&gt;
* cfg/plugins/EPrints/Plugin/Import/OPFXML.pm&lt;br /&gt;
* cfg/plugins/EPrints/Plugin/Import/XSLT/DC.xsl&lt;br /&gt;
&lt;br /&gt;
===OPFXML.pm===&lt;br /&gt;
&lt;br /&gt;
This will be our master import plug-in to handle the entire chunk of XML. We will then use the DC plug-in to map the metadata into an eprint we can use later. &lt;br /&gt;
&lt;br /&gt;
Since this is the master plug-in this requires quiet a sizeable amount of code:&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Import::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  # Declare Namespaces&lt;br /&gt;
  our $DC_NS = &amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;;&lt;br /&gt;
  our $DCTERMS_NS = &amp;quot;http://purl.org/dc/terms/&amp;quot;;&lt;br /&gt;
  our $OPF_NS = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # This is just a variant of the DefaultXML plug-in&lt;br /&gt;
  use EPrints::Plugin::Import::DefaultXML;&lt;br /&gt;
  &lt;br /&gt;
  our @ISA = qw/ EPrints::Plugin::Import::DefaultXML /;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;OPF Resource&amp;quot;;&lt;br /&gt;
        # Make it visible on the import menu and elsewhere&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{produce} = [ 'list/eprint', 'dataobj/eprint' ];&lt;br /&gt;
  &lt;br /&gt;
        # Functionality to recognise XML types on import by recognising the base namespace, works with the sword packaging format, dc:conformsTo or similar.&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $rc = EPrints::Utils::require_if_exists(&amp;quot;MIME::Types&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        unless( $rc )&lt;br /&gt;
        {&lt;br /&gt;
                $self-&amp;gt;{visible} = &amp;quot;&amp;quot;;&lt;br /&gt;
                $self-&amp;gt;{error} = &amp;quot;Failed to load required module MIME::Types&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Input File Handle Method, for when files are uploaded&lt;br /&gt;
  sub input_fh&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $fh = $opts{&amp;quot;fh&amp;quot;};&lt;br /&gt;
  &lt;br /&gt;
        my $xml = join &amp;quot;&amp;quot;, &amp;lt;$fh&amp;gt;;&lt;br /&gt;
  &lt;br /&gt;
        my $list;&lt;br /&gt;
  &lt;br /&gt;
        if( $xml =~ /^&amp;lt;\?xml/ )&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_xml( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
                $list = $plugin-&amp;gt;input_fh_list( $xml, %opts );&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        $list ||= EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [] );&lt;br /&gt;
  &lt;br /&gt;
        return $list;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Handle direct XML input&lt;br /&gt;
  sub input_fh_xml&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $xml, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $doc = EPrints::XML::parse_xml_string( $xml );&lt;br /&gt;
  &lt;br /&gt;
        my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
        EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; [defined($dataobj) ? $dataobj-&amp;gt;get_id : ()] );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Go grab input from a URL&lt;br /&gt;
  sub input_fh_list&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $url, %opts ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        $url =~ s/\s+//g;&lt;br /&gt;
  &lt;br /&gt;
        my $tmpfile = File::Temp-&amp;gt;new;&lt;br /&gt;
  &lt;br /&gt;
        my $r = EPrints::Utils::wget( $plugin-&amp;gt;{session}, $url, $tmpfile );&lt;br /&gt;
        seek($tmpfile,0,0);&lt;br /&gt;
  &lt;br /&gt;
        if( $r-&amp;gt;is_error )&lt;br /&gt;
        {&lt;br /&gt;
                $plugin-&amp;gt;error( &amp;quot;Error reading resource from $url: &amp;quot;.$r-&amp;gt;code.&amp;quot; &amp;quot;.$r-&amp;gt;message );&lt;br /&gt;
                return;&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
        my @ids;&lt;br /&gt;
  &lt;br /&gt;
        while(my $url = &amp;lt;$tmpfile&amp;gt;)&lt;br /&gt;
        {&lt;br /&gt;
                $url =~ s/\s+//g;&lt;br /&gt;
                next unless $url =~ /^http/;&lt;br /&gt;
  &lt;br /&gt;
                my $doc;&lt;br /&gt;
                eval { $doc = EPrints::XML::parse_url( $url ) };&lt;br /&gt;
                if( $@ )&lt;br /&gt;
                {&lt;br /&gt;
                        $plugin-&amp;gt;warning( &amp;quot;Error parsing: $url\n&amp;quot; );&lt;br /&gt;
                }&lt;br /&gt;
  &lt;br /&gt;
                my $dataobj = $plugin-&amp;gt;xml_to_dataobj( $opts{dataset}, $doc-&amp;gt;documentElement );&lt;br /&gt;
  &lt;br /&gt;
                EPrints::XML::dispose( $doc );&lt;br /&gt;
  &lt;br /&gt;
                if( defined $dataobj )&lt;br /&gt;
                {&lt;br /&gt;
                        push @ids, $dataobj-&amp;gt;get_id;&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
          &lt;br /&gt;
        return EPrints::List-&amp;gt;new(&lt;br /&gt;
                        dataset =&amp;gt; $opts{dataset},&lt;br /&gt;
                        session =&amp;gt; $plugin-&amp;gt;{session},&lt;br /&gt;
                        ids =&amp;gt; \@ids );&lt;br /&gt;
  }&lt;br /&gt;
  # Translate this XML into an EPrint&lt;br /&gt;
  sub xml_to_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        # $xml is the PubmedArticle element&lt;br /&gt;
        my( $plugin, $dataset, $xml ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $session = $plugin-&amp;gt;{session};&lt;br /&gt;
  &lt;br /&gt;
        # Locate the metadata element&lt;br /&gt;
        my $metadata = $xml-&amp;gt;getElementsByTagNameNS( $OPF_NS, &amp;quot;metadata&amp;quot; )-&amp;gt;[0];&lt;br /&gt;
  &lt;br /&gt;
        # Load the DC plugin&lt;br /&gt;
        my $dc_plugin = $session-&amp;gt;plugin( &amp;quot;Import::XSLT::DC&amp;quot;,&lt;br /&gt;
                processor =&amp;gt; $plugin-&amp;gt;{processor},&lt;br /&gt;
                dataset =&amp;gt; $dataset,&lt;br /&gt;
        );&lt;br /&gt;
  &lt;br /&gt;
        $dc_plugin-&amp;gt;{Handler} = $plugin-&amp;gt;{Handler};&lt;br /&gt;
        $dc_plugin-&amp;gt;{parse_only} = $plugin-&amp;gt;{parse_only};&lt;br /&gt;
  &lt;br /&gt;
        # Spew the metadata element to a temp file&lt;br /&gt;
        my $tmpfile2 = File::Temp-&amp;gt;new;&lt;br /&gt;
        print $tmpfile2 $metadata-&amp;gt;toString();&lt;br /&gt;
        seek($tmpfile2,0,0);&lt;br /&gt;
  &lt;br /&gt;
        # Parse the file using the plug-in to get back a list of eprints&lt;br /&gt;
        my $list = $dc_plugin-&amp;gt;input_fh( fh =&amp;gt; $tmpfile2, dataset =&amp;gt; $dataset );&lt;br /&gt;
  &lt;br /&gt;
        my( $eprint ) = $list-&amp;gt;get_records( 0, 1 );&lt;br /&gt;
  &lt;br /&gt;
        return $eprint;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
===XSLT/DC.xsl===&lt;br /&gt;
&lt;br /&gt;
Using XSLT is really quiet a nice way of parsing data and well documented so I shouldn't have to say much about how this works here.&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!-- DC Transformation --&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:stylesheet&lt;br /&gt;
        version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
        xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
        ept:name=&amp;quot;DC&amp;quot;&lt;br /&gt;
        ept:visible=&amp;quot;all&amp;quot;&lt;br /&gt;
        ept:advertise=&amp;quot;1&amp;quot;&lt;br /&gt;
        ept:sourceNamespace=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        ept:targetNamespace=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
        ept:produce=&amp;quot;list/eprint&amp;quot;&lt;br /&gt;
        xmlns:ept=&amp;quot;http://eprints.org/ep2/xslt/1.0&amp;quot;&lt;br /&gt;
        xmlns:oai_dc=&amp;quot;http://www.openarchives.org/OAI/2.0/oai_dc/&amp;quot;&lt;br /&gt;
        xmlns:dc=&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;&lt;br /&gt;
        xmlns:opf=&amp;quot;http://www.idpf.org/2007/opf&amp;quot;&lt;br /&gt;
        xmlns=&amp;quot;http://eprints.org/ep2/data/2.0&amp;quot;&lt;br /&gt;
  &amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; indent=&amp;quot;yes&amp;quot; encoding=&amp;quot;utf-8&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;eprints&amp;gt;&lt;br /&gt;
        &amp;lt;eprint&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;./*&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;eprint_status&amp;gt;inbox&amp;lt;/eprint_status&amp;gt;&lt;br /&gt;
        &amp;lt;creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:creator&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&amp;lt;name&amp;gt;&amp;lt;family/&amp;gt;&amp;lt;given&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot;/&amp;gt;&amp;lt;/given&amp;gt;&amp;lt;/name&amp;gt;&amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/creators&amp;gt;&lt;br /&gt;
        &amp;lt;corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:source&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;item&amp;gt;&lt;br /&gt;
                        &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/item&amp;gt;&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/corp_creators&amp;gt;&lt;br /&gt;
        &amp;lt;keywords&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:for-each select=&amp;quot;//dc:subject&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;,&lt;br /&gt;
        &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/keywords&amp;gt;&lt;br /&gt;
        &amp;lt;/eprint&amp;gt;&lt;br /&gt;
        &amp;lt;/eprints&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:title&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;title&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:publisher&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;publisher&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/publisher&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:rights&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;copyright_holders&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/copyright_holders&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:date&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;date&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/date&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:identifier&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;id_number&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;.&amp;quot; /&amp;gt;&amp;lt;/id_number&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!--Ignored at this level--&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;dc:language|dc:subject|dc:source|dc:creator&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
You can test your plug-ins by simply clicking on the &amp;quot;manage deposits&amp;quot; button in your toolbar and selecting &amp;quot;OPF Resource&amp;quot; from the drop down list of import plug-ins. If it doesn't appear restart you web server and check the error log!&lt;br /&gt;
&lt;br /&gt;
Reminder:&lt;br /&gt;
&lt;br /&gt;
  apache2ctl restart &amp;amp;&amp;amp; tail -f /var/log/apache2/error.log&lt;br /&gt;
&lt;br /&gt;
Once you have the import screen, copy and paste the XML from the top of this exercise into it and see if it creates you an EPrint (which you can see back at the manage deposits screen)&lt;br /&gt;
&lt;br /&gt;
=Exporting=&lt;br /&gt;
&lt;br /&gt;
So now we have imported our EPrint from this OPF format we need to be able to put it back into this format for exporting, this has the advantage that you can also export ALL other eprints in this format.&lt;br /&gt;
&lt;br /&gt;
We did most of the work on the importing so now it's your turn below is the basis of the Export plug-in which you can use to get started. To give you a clue this export plug-in needs to be located in cfg/plugins/EPrints/Plugin/Export/OPFXML.pm&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Export::OPFXML;&lt;br /&gt;
  &lt;br /&gt;
  use EPrints::Plugin::Export::XMLFile;&lt;br /&gt;
  @ISA = ( &amp;quot;EPrints::Plugin::Export::XMLFile&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %opts ) = @_;&lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new( %opts );&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{name} = &amp;quot;Open Packaging Format XML&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # This plug-in can only output a single eprint record, no lists or other types of objects&lt;br /&gt;
        $self-&amp;gt;{accept} = [ 'dataobj/eprint' ];&lt;br /&gt;
        $self-&amp;gt;{visible} = &amp;quot;all&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Specify the mimetype so we can use an HTTP ACCEPT header to get this back.&lt;br /&gt;
        $self-&amp;gt;{mimetype} = &amp;quot;application/oebps-package+xml; charset=utf-8&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Again specify what we are exporting&lt;br /&gt;
        $self-&amp;gt;{xmlns} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
        $self-&amp;gt;{schemaLocation} = &amp;quot;http://www.idpf.org/2007/opf&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Method which is called to output the eprint, we would have output_list if we could handle lists&lt;br /&gt;
  sub output_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $dataobj ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $xml = $plugin-&amp;gt;xml_dataobj( $dataobj );&lt;br /&gt;
  &lt;br /&gt;
        return &amp;quot;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&amp;quot; . EPrints::XML::to_string( $xml );&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The method which actually does the work&lt;br /&gt;
  sub xml_dataobj&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin, $eprint ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repo = $plugin-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $package = $repo-&amp;gt;make_element(&amp;quot;package&amp;quot;, xmlns=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;unique-identifier&amp;quot;=&amp;gt;&amp;quot;EPB-UUID&amp;quot;, version=&amp;gt;&amp;quot;2.0&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        my $metadata = $repo-&amp;gt;make_element(&amp;quot;metadata&amp;quot;, &amp;quot;xmlns:opf&amp;quot;=&amp;gt;&amp;quot;http://www.idpf.org/2007/opf&amp;quot;, &amp;quot;xmlns:dc&amp;quot;=&amp;gt;&amp;quot;http://purl.org/dc/elements/1.1/&amp;quot;);&lt;br /&gt;
        $package-&amp;gt;appendChild($metadata);&lt;br /&gt;
  &lt;br /&gt;
        my $title = $repo-&amp;gt;make_element(&amp;quot;dc:title&amp;quot;);&lt;br /&gt;
        $title-&amp;gt;appendText($eprint-&amp;gt;value(&amp;quot;title&amp;quot;));&lt;br /&gt;
  &lt;br /&gt;
        $metadata-&amp;gt;appendChild($title);&lt;br /&gt;
  &lt;br /&gt;
        if( $eprint-&amp;gt;exists_and_set( &amp;quot;creators&amp;quot; ) )&lt;br /&gt;
        {&lt;br /&gt;
                foreach my $name ( @{ $eprint-&amp;gt;get_value( &amp;quot;creators&amp;quot; ) } )&lt;br /&gt;
                {&lt;br /&gt;
                        # given name first&lt;br /&gt;
                        my $creator = $repo-&amp;gt;make_element(&amp;quot;dc:creator&amp;quot;);&lt;br /&gt;
                        $creator-&amp;gt;appendText(EPrints::Utils::make_name_string( $name-&amp;gt;{name}, 1 ));&lt;br /&gt;
                        $metadata-&amp;gt;appendChild($creator);&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
        return $package;&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
This is no where near as complete as the original input from above, can you make the 2 match?&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
This is an easy one. &lt;br /&gt;
* Find the eprint you imported&lt;br /&gt;
* Click the Export Tab&lt;br /&gt;
* Find your export plug-in (by name) and click it&lt;br /&gt;
&lt;br /&gt;
=Wrap it as a package=&lt;br /&gt;
&lt;br /&gt;
Once again, now this is working you want to remove the files and package them up with a spec file and icon. Then remove the files from your local install and try doing an install via the Bazaar to see if it works.&lt;br /&gt;
&lt;br /&gt;
Why not see the export plug-in working via a GET request to the id url of the eprint http://archive.org/id/eprint/XXX with the ACCEPT header set to the mime-type of your desired export plug-in. This is quick proof that content negotiation works in EPrints and it's that easy to add a new exporter.&lt;br /&gt;
&lt;br /&gt;
=Extension Exercises=&lt;br /&gt;
&lt;br /&gt;
This whole exercise has been the beginning of importing the epub format into EPrints!&lt;br /&gt;
&lt;br /&gt;
If you are feeling keen see if you can scope out or develop this further to import more of the format, maybe some of the chapters etc. &lt;br /&gt;
&lt;br /&gt;
The full epub for this book is available @ http://www.epubbooks.com/book/378/adventures-of-sherlock-holmes and you have been importing a small section of the epb.opf file which is listed in the META-INF/container.xml&lt;br /&gt;
&lt;br /&gt;
epub is a format we are keen to see EPrints support and there may be a bounty available for the first person to develop a complete Bazaar Package to support them.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=EPM_Specification&amp;diff=9783</id>
		<title>EPM Specification</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=EPM_Specification&amp;diff=9783"/>
		<updated>2011-03-24T18:06:43Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=The EPM Specification=&lt;br /&gt;
&lt;br /&gt;
The EPrints Package/Plug-in Manager (EPM) is designed to install EPM (EPrints Modules) in the EPM format. &lt;br /&gt;
&lt;br /&gt;
EPM is a simple format consisting of a directory structure which is dropped into the ARCHIVE_ID directory.&lt;br /&gt;
&lt;br /&gt;
In order to make an EPM you also require a specification file and an icon to represent the EPM in the EPM repository. &lt;br /&gt;
&lt;br /&gt;
For more details on the Package Manager see [[EPrints_Package_Manager]].&lt;br /&gt;
&lt;br /&gt;
==The EPM Spec File==&lt;br /&gt;
&lt;br /&gt;
The EPM Spec file contains a series of &amp;quot;:&amp;quot; separated keypairs, each on it's own line. Unless otherwise specified, ALL the fields detailed here are required. If a package wishes to add it's own configuration variables these should be added to the package's own configuration file and not the EPM spec.&lt;br /&gt;
&lt;br /&gt;
The spec file should be called package_name (&amp;quot;package&amp;quot;) in the spec file, e.g. (test_package.spec).&lt;br /&gt;
&lt;br /&gt;
Example Spec file:&lt;br /&gt;
  package: test_package&lt;br /&gt;
  version: 0.0.1&lt;br /&gt;
  title: Test Package&lt;br /&gt;
  description: This is a simple test screen plugin&lt;br /&gt;
  creator: Dave Tarrant &amp;lt;davetaz@foo.bar.org&amp;gt;&lt;br /&gt;
  creator: Creator 2 &amp;lt;c2@foo.bar.org&amp;gt;&lt;br /&gt;
  configuration_file: Admin::TestScreen&lt;br /&gt;
  icon: icon.png&lt;br /&gt;
  license: GPLv2&lt;br /&gt;
  category: example&lt;br /&gt;
  category: input_output&lt;br /&gt;
  optional_key: key value&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
===package===&lt;br /&gt;
* A globally unique package identifier, used for management of the package versions, upgrades and local over rides.&lt;br /&gt;
* The main EPM repository will be files.eprints.org and this can be searched to find if your package_name exists. Alternatively files should tell you when you try and submit the package. &lt;br /&gt;
&lt;br /&gt;
===package_url (optional)===&lt;br /&gt;
* An official url for the package.&lt;br /&gt;
&lt;br /&gt;
===version===&lt;br /&gt;
* A semantic version complient version number (major release . minor release . bugfix release)&lt;br /&gt;
* See http://semver.org/ for more details&lt;br /&gt;
&lt;br /&gt;
===title===&lt;br /&gt;
* The title/name of the package. &lt;br /&gt;
* A pretty string. &lt;br /&gt;
&lt;br /&gt;
===description===&lt;br /&gt;
* Description of the package.&lt;br /&gt;
* A pretty string. &lt;br /&gt;
&lt;br /&gt;
===creator===&lt;br /&gt;
* A creator listed as follows:&lt;br /&gt;
  Dave Tarrant &amp;lt;foo@bar.com&amp;gt;&lt;br /&gt;
* More than one creator can be specified by adding additional creator lines.&lt;br /&gt;
&lt;br /&gt;
===icon===&lt;br /&gt;
* The icon file which should be within the root directory of the package&lt;br /&gt;
&lt;br /&gt;
===category===&lt;br /&gt;
* The category of the plug-in, again multiple categories can be specified. &lt;br /&gt;
* More can be found on these at http://bazaar.eprints.org (or via the store into which the package is being submitted). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===configuration_file (not required)===&lt;br /&gt;
* A Screen or Config File in cfg/cfg.d.&lt;br /&gt;
If a cfg/cfg.d config file is listed (e.g. cfg/cfg.d/myscreen.pl), then the EPM Manager will re-direct the user to the built in editor for editing this config file. If a screen is specified (as per the example above) then the user will be re-directed to this screen when they press the configure button against the installed package.&lt;br /&gt;
&lt;br /&gt;
=The EPM Package Structure=&lt;br /&gt;
&lt;br /&gt;
The following shows the package structure for the package &amp;quot;test_package&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
  - test_package.spec&lt;br /&gt;
  - icon.png&lt;br /&gt;
  - cfg/cfg.d/test_package.cfg&lt;br /&gt;
  - cfg/plugins/EPrints/Plugin/Screen/Admin/TestScreen.pm&lt;br /&gt;
&lt;br /&gt;
In this only test_package.spec and icon.png are required, all the rest of the files are installed if possible.&lt;br /&gt;
&lt;br /&gt;
=Bundling an EPM=&lt;br /&gt;
&lt;br /&gt;
* Compress the directory structure shown above into a zip file&lt;br /&gt;
* Change the extenstion on this zip file to .epm&lt;br /&gt;
&lt;br /&gt;
=Submitting an EPM=&lt;br /&gt;
&lt;br /&gt;
This can either be done via the web interface of your chosen EPM repository, or via the submit to EPM repository button which can be accessed on the &amp;quot;Local Packages&amp;quot; tab of the EPrints Bazaar admin GUI. &lt;br /&gt;
&lt;br /&gt;
If you have filled in all the metadata then there is no need to fill this in again via the web interface as it will be extracted from the spec file automatically.&lt;br /&gt;
&lt;br /&gt;
=TODO=&lt;br /&gt;
* Finalise the specification for an EPM repository.&lt;br /&gt;
* Get sword working for submission of EPMs&lt;br /&gt;
* Write an upload handler for EPM files which extracts the metadata and icon. If invalid or data missing this should throw an error back to the client, both in the interface and via sword.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9782</id>
		<title>My First Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=My_First_Bazaar_Package&amp;diff=9782"/>
		<updated>2011-03-24T18:04:05Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Step 1 - Decide a Package Name */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
In this tutorial we look at how to create a simple Bazaar Package (epm) ready for distribution via the EPrints Bazaar Store.&lt;br /&gt;
&lt;br /&gt;
We are going to create this example simple and create a simple screen plug-in which will simply say hello to the user. &lt;br /&gt;
&lt;br /&gt;
It will read from a config file a variable which it will repeat back to the user. &lt;br /&gt;
&lt;br /&gt;
=Remember the steps to create an epm=&lt;br /&gt;
&lt;br /&gt;
* Make it work first locally&lt;br /&gt;
* Package up a working version with a spec file and icon.&lt;br /&gt;
* Install from the &amp;quot;Local Packages&amp;quot; tab in the bazaar to test it.&lt;br /&gt;
&lt;br /&gt;
=Exercise=&lt;br /&gt;
&lt;br /&gt;
By this point you should have an EPrints Bazaar capable version of EPrints installed and have a repository set up of which you are the admin user. &lt;br /&gt;
&lt;br /&gt;
You should also have a command line (or other method) for accessing and creating files within the repository directory. &lt;br /&gt;
&lt;br /&gt;
In this demo we are assuming that your root directory is always the archive's home folder found at eprints/archives/archive_name (where archive_name is your archive ID)&lt;br /&gt;
&lt;br /&gt;
==Step 1 - Decide a Package Name==&lt;br /&gt;
&lt;br /&gt;
I'm going to call my package eprints_test_package which I shall use throughout this exercise, let's hope its unique!&lt;br /&gt;
&lt;br /&gt;
To check it is unique, create a eprints_test_package.spec file with the following content:&lt;br /&gt;
&lt;br /&gt;
  package: eprints_test_package&lt;br /&gt;
  version: 0.0.1&lt;br /&gt;
  title: My First Package&lt;br /&gt;
  description: A simple screen plug-in plus config file&lt;br /&gt;
  creator: Dave Tarrant &amp;lt;davetaz@foo.bar.org&amp;gt;&lt;br /&gt;
  icon: icon.png&lt;br /&gt;
  category: training&lt;br /&gt;
&lt;br /&gt;
For more on the spec file specification see [[EPM_Specification]]&lt;br /&gt;
&lt;br /&gt;
You will have to find a random small icon you can use as well, a package without one isn't accepted! &lt;br /&gt;
&lt;br /&gt;
We then package up our spec file and icon only into the root level of a zip file in this case called eprints_test_package.epm&lt;br /&gt;
&lt;br /&gt;
Finally using the &amp;quot;Local Packages&amp;quot; tab in the Bazaar screen, upload your package. If you get a green tick back you have a unique name.&lt;br /&gt;
&lt;br /&gt;
NOTE: This process does not secure you the package name! You can't camp on a name! You secure the name by uploading a working version of your package.&lt;br /&gt;
&lt;br /&gt;
==Step 2 - Develop your package==&lt;br /&gt;
&lt;br /&gt;
In this example we shall make 3 files, a screen, a config file and a phrase file at the following locations:&lt;br /&gt;
&lt;br /&gt;
* cfg/plugins/EPrints/Plugin/Screen/Admin/EPrintsTestScreen.pm&lt;br /&gt;
* cfg/cfg.d/eprints_test_package.pl&lt;br /&gt;
* cfg/lang/en/phrases/eprints_test_package.xml&lt;br /&gt;
&lt;br /&gt;
In each of these files copy and paste the following:&lt;br /&gt;
&lt;br /&gt;
===EPrintsTestScreen.pm===&lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Screen::Admin::EPrintsTestScreen;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = ( 'EPrints::Plugin::Screen' );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  # Make the plug-in&lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        # Where the button to access the screen appears if anywhere, and what priority&lt;br /&gt;
        $self-&amp;gt;{appears} = [&lt;br /&gt;
                {&lt;br /&gt;
                        place =&amp;gt; &amp;quot;admin_actions&amp;quot;,&lt;br /&gt;
                        position =&amp;gt; 1247,&lt;br /&gt;
                },&lt;br /&gt;
        ];&lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Can anyone see this screen.&lt;br /&gt;
  sub can_be_viewed&lt;br /&gt;
  {&lt;br /&gt;
        my( $plugin ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # What to display&lt;br /&gt;
  sub render&lt;br /&gt;
  {&lt;br /&gt;
        my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $ret = $repository-&amp;gt;make_doc_fragment();&lt;br /&gt;
        my $br = $repository-&amp;gt;make_element(&amp;quot;br&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        my $lang_phrase = $self-&amp;gt;html_phrase(&amp;quot;eprints_test_phrase&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
        my $text_from_config = $repository-&amp;gt;make_text($repository-&amp;gt;{config}-&amp;gt;{eprints_test_package}-&amp;gt;{phrase});&lt;br /&gt;
  &lt;br /&gt;
        $ret-&amp;gt;appendChild($lang_phrase);&lt;br /&gt;
        $ret-&amp;gt;appendChild($br);&lt;br /&gt;
        $ret-&amp;gt;appendChild($text_from_config);&lt;br /&gt;
  &lt;br /&gt;
        return $ret;&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
===cfg/cfg.d/eprints_test_package.pl===&lt;br /&gt;
&lt;br /&gt;
  $c-&amp;gt;{eprints_test_package}-&amp;gt;{phrase} = &amp;quot;This is a phrase, but it shouldn't be we are just testing. It could be a version number or some other variable.&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
===cfg/lang/en/phrases/eprints_test_package.xml===&lt;br /&gt;
&lt;br /&gt;
Finally we need some phrases. The title and description phrases are required if you are going to allow access to the screen from one of the admin menus. &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&lt;br /&gt;
  &amp;lt;!DOCTYPE phrases SYSTEM &amp;quot;entities.dtd&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;epp:phrases xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; xmlns:epp=&amp;quot;http://eprints.org/ep3/phrase&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Admin/EPrintsTestScreen:title&amp;quot;&amp;gt;Davetaz's Test Screen&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
    &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Admin/EPrintsTestScreen:description&amp;quot;&amp;gt;I really need a description&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
    &amp;lt;epp:phrase id=&amp;quot;Plugin/Screen/Admin/EPrintsTestScreen:eprints_test_phrase&amp;quot;&amp;gt;This is our test phrase.&amp;lt;/epp:phrase&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/epp:phrases&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Step 3 - Does it work locally==&lt;br /&gt;
&lt;br /&gt;
You should now have the 3 files in place and if you reload your config (via the &amp;quot;Reload Configuration&amp;quot; button on the &amp;quot;Config. Tools&amp;quot; tab of the admin interface) you should then be able to go to the &amp;quot;Misc. Tools&amp;quot; tab and find your screen. Clicking on it should show our two phrases, one from the phrase file and one from the config listed on 2 different lines.&lt;br /&gt;
&lt;br /&gt;
==Step 3b - HELP - It didn't work==&lt;br /&gt;
&lt;br /&gt;
If you made an error then the error message will likely be in the web servers error log. &lt;br /&gt;
&lt;br /&gt;
Here is a very useful command for full debugging of EPrints and restarting the web server at the same time.&lt;br /&gt;
&lt;br /&gt;
In a new terminal as root, type and execute the following (on debian based systems):&lt;br /&gt;
&lt;br /&gt;
  apache2ctl restart &amp;amp;&amp;amp; tail -f /var/apache2/logs/error_log&lt;br /&gt;
&lt;br /&gt;
This will restart the web server and then give you a live view on the error log. &lt;br /&gt;
&lt;br /&gt;
Attempting to reload your screen again (hit F5) will the cause the error to be displayed instantly in this terminal. It is recommended to leave this terminal open for debugging at all times.&lt;br /&gt;
&lt;br /&gt;
==Step 4 - Package it up and test it==&lt;br /&gt;
&lt;br /&gt;
Now what we want to do is create a directory for our package (even better an svn or other change management system!) and move the files we just created out of the repository and into a directory which we can build out package from. &lt;br /&gt;
&lt;br /&gt;
So in your home directory (not the eprints one) make a folder for your package and move the files into it including the spec file and icon.&lt;br /&gt;
&lt;br /&gt;
IMPORTANT: The directory structure needs to be preserved thus your directory listing should look as follows:&lt;br /&gt;
&lt;br /&gt;
* icon.png&lt;br /&gt;
* eprints_test_package.spec&lt;br /&gt;
* cfg/plugins/EPrints/Plugin/Screen/Admin/EPrintsTestScreen.pm&lt;br /&gt;
* cfg/cfg.d/eprints_test_package.pl&lt;br /&gt;
* cfg/lang/en/phrases/eprints_test_package.xml&lt;br /&gt;
&lt;br /&gt;
Before we package it up we want to update our spec file to point at the configuration file, so in the spec file add the line:&lt;br /&gt;
&lt;br /&gt;
  configuration_file: cfg/cfg.d/eprints_test_package.pl &lt;br /&gt;
&lt;br /&gt;
With this done, reload the config on your repository to make sure the screen has gone! You can even use view config to make sure all the related files have gone. &lt;br /&gt;
&lt;br /&gt;
Finally package up your directory using zip to make an epm called eprints_test_package.epm as before and upload this via the &amp;quot;Local Packages&amp;quot; tab, you may need to remove the old one first! Also did you version your package from the initial 0.1 marker in the spec file. (Get a script to grab the SVN version to go here when you build a propper package) &lt;br /&gt;
&lt;br /&gt;
With all this done, if you have a green box, click the install button and see if it worked!&lt;br /&gt;
&lt;br /&gt;
If it didn't you will need to remove it (if it installed) and use the steps outlined in 3b to debug why. &lt;br /&gt;
&lt;br /&gt;
==Step 4b - I'm stuck in limbo, package won't remove (a.k.a. using epm via the command line)==&lt;br /&gt;
&lt;br /&gt;
If you get stuck you can use the command line scripts which allow you to force changes. &lt;br /&gt;
&lt;br /&gt;
You have to be aware that forcing changes means that any errors (prerm and dataset removals etc) will be ignored!&lt;br /&gt;
&lt;br /&gt;
The syntax is as follows (and needs to be executed as the eprints user at the root level of the eprints home directory)&lt;br /&gt;
&lt;br /&gt;
  perl bin/epm archive_name [install|remove] package_name [--force]&lt;br /&gt;
&lt;br /&gt;
This basically replicates the graphically functionality except the addition of the --force flag. Search functionality is still to be added... maybe.&lt;br /&gt;
&lt;br /&gt;
=Exercise 2=&lt;br /&gt;
&lt;br /&gt;
That the easy exercise done, so how about doing something a little more challenging.&lt;br /&gt;
&lt;br /&gt;
How about using our config file to specify an eprint_id or search expression and then using your screen to display something about this item/list.&lt;br /&gt;
&lt;br /&gt;
For some hints on loading and manipulating EPrints see [[Manipulating eprints in 3.2]].&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Bazaar_Bounties&amp;diff=9712</id>
		<title>Bazaar Bounties</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Bazaar_Bounties&amp;diff=9712"/>
		<updated>2010-12-16T18:18:07Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the Bazaar Bounties page where you can find information about pre-release competitions relating to the EPrints Bazaar. &lt;br /&gt;
&lt;br /&gt;
=Bounty 1 - Amaze Us=&lt;br /&gt;
&lt;br /&gt;
* Aim: Show us something that can be done via a Bazaar package which will amaze us. This could be a killer feature to benefit the whole community, something pretty, an entire language translation of EPrints or any other type of plug-in.&lt;br /&gt;
&lt;br /&gt;
* Prize: &lt;br /&gt;
** First Place: We'll take you to OR2011 in Austin Texas where you'll be on stage presenting your package to the world at the international launch of the EPrints Bazaar Store.&lt;br /&gt;
** Runners Up: Your package will be certificated* free by the EPrints team ready for the launch of the Bazaar Store.  &lt;br /&gt;
&lt;br /&gt;
* Deadline for Entries - March 30th 2011&lt;br /&gt;
&lt;br /&gt;
* Winner announced - Early April 2011&lt;br /&gt;
&lt;br /&gt;
* How to enter - Submit your packages to the Bazaar store during February and March next year when we open the store for submissions. &lt;br /&gt;
&lt;br /&gt;
* Help and guides on developing a package @ [[The_EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
==Ideas==&lt;br /&gt;
&lt;br /&gt;
* In the [[Import_and_Export_Plug-ins]] exercise we start to import the epub format into EPrints. Why not complete this exercise fully including flashy abstract page using some of the other guides to help you.&lt;br /&gt;
&lt;br /&gt;
* [[Dataset Manipulation, Triggers and Events]] shows how you can use micro-services to enhance metadata relating to EPrints. Why not think of another one?&lt;br /&gt;
&lt;br /&gt;
* [[Style (CSS) and Eloquence (Languages)]] Good at design? Know 6 languages? &lt;br /&gt;
&lt;br /&gt;
* Stats modules anyone? EPrints does record all the access log information...&lt;br /&gt;
&lt;br /&gt;
* Issues reporting modules?&lt;br /&gt;
&lt;br /&gt;
* Twitter integration?&lt;br /&gt;
&lt;br /&gt;
* + loads of others&lt;br /&gt;
&lt;br /&gt;
You are not limited in any way and i'm sure you can think of much better extensions than us!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  * Certification will only be granted to those packages which can be certificated as not risky to users and their data.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Bazaar_Bounties&amp;diff=9711</id>
		<title>Bazaar Bounties</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Bazaar_Bounties&amp;diff=9711"/>
		<updated>2010-12-16T18:01:02Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Bounty 1 - Amaze Us */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the Bazaar Bounties page where you can find information about pre-release competitions relating to the EPrints Bazaar. &lt;br /&gt;
&lt;br /&gt;
=Bounty 1 - Amaze Us=&lt;br /&gt;
&lt;br /&gt;
* Aim: Show us something that can be done via a Bazaar package which will amaze us. This could be a killer feature to benefit the whole community, something pretty, an entire language translation of EPrints or any other type of plug-in.&lt;br /&gt;
&lt;br /&gt;
* Prize: We'll take you to OR2011 in Austin Texas where you'll be on stage presenting your package to the world at the international launch of the EPrints Bazaar Store. &lt;br /&gt;
&lt;br /&gt;
* Deadline for Entries - March 30th 2011&lt;br /&gt;
&lt;br /&gt;
* Winner announced - Early April 2011&lt;br /&gt;
&lt;br /&gt;
* How to enter - Submit your packages to the Bazaar store during February and March next year when we open the store for submissions. &lt;br /&gt;
&lt;br /&gt;
* Help and guides on developing a package @ [[The_EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
==Ideas==&lt;br /&gt;
&lt;br /&gt;
* In the [[Import_and_Export_Plug-ins]] exercise we start to import the epub format into EPrints. Why not complete this exercise fully including flashy abstract page using some of the other guides to help you.&lt;br /&gt;
&lt;br /&gt;
* [[Dataset Manipulation, Triggers and Events]] shows how you can use micro-services to enhance metadata relating to EPrints. Why not think of another one?&lt;br /&gt;
&lt;br /&gt;
* [[Style (CSS) and Eloquence (Languages)]] Good at design? Know 6 languages? &lt;br /&gt;
&lt;br /&gt;
* Stats modules anyone? EPrints does record all the access log information...&lt;br /&gt;
&lt;br /&gt;
* Issues reporting modules?&lt;br /&gt;
&lt;br /&gt;
* Twitter integration?&lt;br /&gt;
&lt;br /&gt;
* + loads of others&lt;br /&gt;
&lt;br /&gt;
You are not limited in any way and i'm sure you can think of much better extensions than us!&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Bazaar_Bounties&amp;diff=9710</id>
		<title>Bazaar Bounties</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Bazaar_Bounties&amp;diff=9710"/>
		<updated>2010-12-16T18:00:38Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Bounty 1 - Amaze Us */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the Bazaar Bounties page where you can find information about pre-release competitions relating to the EPrints Bazaar. &lt;br /&gt;
&lt;br /&gt;
=Bounty 1 - Amaze Us=&lt;br /&gt;
&lt;br /&gt;
* Aim: Show us something that can be done via a Bazaar package which will amaze us. This could be a killer feature to benefit the whole community, something pretty, an entire language translation of EPrints or any other type of plug-in.&lt;br /&gt;
&lt;br /&gt;
* Prize: We'll take you to OR2011 in Austin Texas (or another conference) where you'll be on stage presenting your package to the world at the international launch of the EPrints Bazaar Store. &lt;br /&gt;
&lt;br /&gt;
* Deadline for Entries - March 30th 2011&lt;br /&gt;
&lt;br /&gt;
* Winner announced - Early April 2011&lt;br /&gt;
&lt;br /&gt;
* How to enter - Submit your packages to the Bazaar store during February and March next year when we open the store for submissions. &lt;br /&gt;
&lt;br /&gt;
* Help and guides on developing a package @ [[The_EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
==Ideas==&lt;br /&gt;
&lt;br /&gt;
* In the [[Import_and_Export_Plug-ins]] exercise we start to import the epub format into EPrints. Why not complete this exercise fully including flashy abstract page using some of the other guides to help you.&lt;br /&gt;
&lt;br /&gt;
* [[Dataset Manipulation, Triggers and Events]] shows how you can use micro-services to enhance metadata relating to EPrints. Why not think of another one?&lt;br /&gt;
&lt;br /&gt;
* [[Style (CSS) and Eloquence (Languages)]] Good at design? Know 6 languages? &lt;br /&gt;
&lt;br /&gt;
* Stats modules anyone? EPrints does record all the access log information...&lt;br /&gt;
&lt;br /&gt;
* Issues reporting modules?&lt;br /&gt;
&lt;br /&gt;
* Twitter integration?&lt;br /&gt;
&lt;br /&gt;
* + loads of others&lt;br /&gt;
&lt;br /&gt;
You are not limited in any way and i'm sure you can think of much better extensions than us!&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Bazaar_Bounties&amp;diff=9709</id>
		<title>Bazaar Bounties</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Bazaar_Bounties&amp;diff=9709"/>
		<updated>2010-12-16T18:00:12Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: Created page with 'Welcome to the Bazaar Bounties page where you can find information about pre-release competitions relating to the EPrints Bazaar.   =Bounty 1 - Amaze Us=  * Aim: Show us somethin…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the Bazaar Bounties page where you can find information about pre-release competitions relating to the EPrints Bazaar. &lt;br /&gt;
&lt;br /&gt;
=Bounty 1 - Amaze Us=&lt;br /&gt;
&lt;br /&gt;
* Aim: Show us something that can be done via a Bazaar package which will amaze us. This could be a killer feature to benefit the whole community, something pretty, an entire language translation of EPrints or any other type of plug-in which we will launch the store with.&lt;br /&gt;
&lt;br /&gt;
* Prize: We'll take you to OR2011 in Austin Texas (or another conference) where you'll be on stage presenting your package to the world at the international launch of the EPrints Bazaar Store. &lt;br /&gt;
&lt;br /&gt;
* Deadline for Entries - March 30th 2011&lt;br /&gt;
&lt;br /&gt;
* Winner announced - Early April 2011&lt;br /&gt;
&lt;br /&gt;
* How to enter - Submit your packages to the Bazaar store during February and March next year when we open the store for submissions. &lt;br /&gt;
&lt;br /&gt;
* Help and guides on developing a package @ [[The_EPrints_Bazaar]]&lt;br /&gt;
&lt;br /&gt;
==Ideas==&lt;br /&gt;
&lt;br /&gt;
* In the [[Import_and_Export_Plug-ins]] exercise we start to import the epub format into EPrints. Why not complete this exercise fully including flashy abstract page using some of the other guides to help you.&lt;br /&gt;
&lt;br /&gt;
* [[Dataset Manipulation, Triggers and Events]] shows how you can use micro-services to enhance metadata relating to EPrints. Why not think of another one?&lt;br /&gt;
&lt;br /&gt;
* [[Style (CSS) and Eloquence (Languages)]] Good at design? Know 6 languages? &lt;br /&gt;
&lt;br /&gt;
* Stats modules anyone? EPrints does record all the access log information...&lt;br /&gt;
&lt;br /&gt;
* Issues reporting modules?&lt;br /&gt;
&lt;br /&gt;
* Twitter integration?&lt;br /&gt;
&lt;br /&gt;
* + loads of others&lt;br /&gt;
&lt;br /&gt;
You are not limited in any way and i'm sure you can think of much better extensions than us!&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Dataset_Manipulation,_Triggers_and_Events&amp;diff=9708</id>
		<title>Dataset Manipulation, Triggers and Events</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Dataset_Manipulation,_Triggers_and_Events&amp;diff=9708"/>
		<updated>2010-12-16T16:09:38Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Finish and test */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this exercise, we are going to look at a lot of capabilities of EPrints combined in one exercise. &lt;br /&gt;
&lt;br /&gt;
The overall aim is to add a '''Trigger''' which queues an '''Event''' on the indexer to scan a file for it's mime type (according to the unix file command) and update this data in the file '''dataset'''&lt;br /&gt;
&lt;br /&gt;
We shall also add a new '''dataset''' although we won't specifically be using it. &lt;br /&gt;
&lt;br /&gt;
=Adding To Datasets=&lt;br /&gt;
&lt;br /&gt;
This is done with a config file under cfg/cfg.d/ which we can call package_name.pl for example. &lt;br /&gt;
&lt;br /&gt;
The following shows an example of adding the file_cmd_mime to the file dataset.&lt;br /&gt;
&lt;br /&gt;
  $c-&amp;gt;add_dataset_field( &amp;quot;file&amp;quot;, {&lt;br /&gt;
        name =&amp;gt; &amp;quot;file_cmd_mime&amp;quot;,&lt;br /&gt;
        type =&amp;gt; &amp;quot;text&amp;quot;,&lt;br /&gt;
  }, reuse =&amp;gt; 1 );&lt;br /&gt;
&lt;br /&gt;
Note that we can specify the reuse flag to say if we can reuse this field if it already exists. If this is set to 0 (or not defined) and the field already exists the package install will fail. &lt;br /&gt;
&lt;br /&gt;
Note also that if none of the config files define the field, then it is assumed it no longer required and it is removed (data included). Some investigation is need to see if upgrades work... (:S)&lt;br /&gt;
&lt;br /&gt;
=Adding New Datasets=&lt;br /&gt;
&lt;br /&gt;
Adding new datasets is much the same as adding to an existing one other than the fact we need to define the dataset and the basic class wrappers.&lt;br /&gt;
&lt;br /&gt;
  # Define the dataset&lt;br /&gt;
  $c-&amp;gt;{datasets}-&amp;gt;{package_dataset} = {&lt;br /&gt;
       class =&amp;gt; &amp;quot;EPrints::DataObj::PackageDataset&amp;quot;,&lt;br /&gt;
       sqlname =&amp;gt; &amp;quot;package_dataset&amp;quot;,&lt;br /&gt;
       datestamp =&amp;gt; &amp;quot;datestamp&amp;quot;,       &lt;br /&gt;
       sql_counter =&amp;gt; &amp;quot;datasetid&amp;quot;,&lt;br /&gt;
  };&lt;br /&gt;
  &lt;br /&gt;
  # Add fields to the dataset&lt;br /&gt;
  $c-&amp;gt;add_dataset_field( &amp;quot;package_dataset&amp;quot;, { name=&amp;gt;&amp;quot;datasetid&amp;quot;, type=&amp;gt;&amp;quot;counter&amp;quot;, required=&amp;gt;1, can_clone=&amp;gt;0, sql_counter=&amp;gt;&amp;quot;datasetid&amp;quot; }, );&lt;br /&gt;
  $c-&amp;gt;add_dataset_field( &amp;quot;package_dataset&amp;quot;, { name=&amp;gt;&amp;quot;name&amp;quot;, type=&amp;gt;&amp;quot;text&amp;quot;, required=&amp;gt;0, }, );&lt;br /&gt;
  $c-&amp;gt;add_dataset_field( &amp;quot;package_dataset&amp;quot;, { name=&amp;gt;&amp;quot;count&amp;quot;, type=&amp;gt;&amp;quot;int&amp;quot;, required=&amp;gt;0, }, );&lt;br /&gt;
  &lt;br /&gt;
  # Define the class, this can either be done using a new file in the right place, or by using this override trick, open a '{' and then continue as it this is new file&lt;br /&gt;
  {&lt;br /&gt;
    package EPrints::DataObj::PackageDataset;&lt;br /&gt;
  &lt;br /&gt;
    our @ISA = qw( EPrints::DataObj );&lt;br /&gt;
    &lt;br /&gt;
    # The new method can simply return the constructor of the super class (Dataset)&lt;br /&gt;
    sub new&lt;br /&gt;
    {&lt;br /&gt;
        return shift-&amp;gt;SUPER::new( @_ );&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    # This method is required to just return the dataset_id.&lt;br /&gt;
    sub get_dataset_id&lt;br /&gt;
    {&lt;br /&gt;
        my ($self) = @_;&lt;br /&gt;
        return &amp;quot;package_dataset&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Events=&lt;br /&gt;
&lt;br /&gt;
Events are things which can be triggered by the indexer at various times. Because we don't want to have to wait for out mime type scan to complete and are not bothered when it completes we may as well make an event which can run at a convienient time. &lt;br /&gt;
&lt;br /&gt;
Other examples of events are:&lt;br /&gt;
&lt;br /&gt;
* Thumbnail Generation&lt;br /&gt;
* Full text indexing&lt;br /&gt;
* RDF generation&lt;br /&gt;
&lt;br /&gt;
These are all things which can be queued up so as not to slow the deposit process. &lt;br /&gt;
&lt;br /&gt;
The last thing to note about events is that the indexer obeys the eprint edit-lock, so if someone has the resource locked, the events won't happen yet. &lt;br /&gt;
&lt;br /&gt;
The indexer trys to execute queued events every 30 seconds and you can view the status of events and the indexer via the &amp;quot;status&amp;quot; button under the &amp;quot;System Tools&amp;quot; tab of the admin interface.&lt;br /&gt;
&lt;br /&gt;
==ScanFile event==&lt;br /&gt;
&lt;br /&gt;
An Event is just another type of plug-in thus you create it in a the archives cfg/plugins/EPrints/Plugin/Event/ folder. &lt;br /&gt;
&lt;br /&gt;
Below is an event with a single sub which performs the needed operation, all this needs to be parsed is a file_id. &lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Event::ScanFile;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = qw( EPrints::Plugin::Event );&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub scanfile&lt;br /&gt;
  {&lt;br /&gt;
        my( $self, $file_id ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        my $file = new EPrints::DataObj::File( $repository, $file_id );&lt;br /&gt;
  &lt;br /&gt;
        my $src_path = $file-&amp;gt;get_local_copy;&lt;br /&gt;
  &lt;br /&gt;
        my $cmd = &amp;quot;file -i $src_path | awk '{split (\$0, a, \&amp;quot; \&amp;quot;); print a[2]}'&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        my $ret = `$cmd`;&lt;br /&gt;
  &lt;br /&gt;
        $ret =~ s/\r?\n//;&lt;br /&gt;
  &lt;br /&gt;
        if (defined $ret and (!($ret eq &amp;quot;&amp;quot;))) {&lt;br /&gt;
                $file-&amp;gt;set_value(&amp;quot;file_cmd_mime&amp;quot;, $ret);&lt;br /&gt;
                $file-&amp;gt;commit();&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Triggers= &lt;br /&gt;
&lt;br /&gt;
Triggers in EPrints and like message queues, you register a function which is called when a trigger point is hit.&lt;br /&gt;
&lt;br /&gt;
There are lots of triggers in EPrints which are defined in the EPrints/Const.pm file however not all of them have trigger points at the time of writing. &lt;br /&gt;
&lt;br /&gt;
Ideally we would want to use the EP_TRIGGER_FILES_MODIFIED as our trigger, however this is one of the ones which currently has no trigger point. So instead we are going to register our code against the EP_TRIGGER_AFTER_COMMIT on the '''file''' dataset only.&lt;br /&gt;
&lt;br /&gt;
There are two types of trigger:&lt;br /&gt;
&lt;br /&gt;
* Repository Triggers: General purpose triggers which should always be called with the same params and types. &lt;br /&gt;
* Dataset Triggers: Similar to repository triggers except they operate on a single dataset which changes depending on the trigger point.&lt;br /&gt;
&lt;br /&gt;
We are thus going to register our trigger against the '''file''' dataset using a dataset trigger. &lt;br /&gt;
&lt;br /&gt;
==Our Dataset Trigger==&lt;br /&gt;
&lt;br /&gt;
Triggers are registered in the repository config on load, thus the code can sit in our config file under cfg/cfg.d/. &lt;br /&gt;
&lt;br /&gt;
Don't forget to reload the config to load the trigger. &lt;br /&gt;
&lt;br /&gt;
  $c-&amp;gt;add_dataset_trigger( &amp;quot;file&amp;quot;, EP_TRIGGER_AFTER_COMMIT , sub {&lt;br /&gt;
        my ( %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = %params-&amp;gt;{repository};&lt;br /&gt;
  &lt;br /&gt;
        return undef if (!defined $repository);&lt;br /&gt;
  &lt;br /&gt;
        if (defined %params-&amp;gt;{dataobj}) {&lt;br /&gt;
                my $file = %params-&amp;gt;{dataobj};&lt;br /&gt;
                my $file_id = $file-&amp;gt;value(&amp;quot;fileid&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
                $repository-&amp;gt;dataset( &amp;quot;event_queue&amp;quot; )-&amp;gt;create_dataobj({&lt;br /&gt;
                        pluginid =&amp;gt; &amp;quot;Event::ScanFile&amp;quot;,&lt;br /&gt;
                        action =&amp;gt; &amp;quot;scanfile&amp;quot;,&lt;br /&gt;
                        params =&amp;gt; [$file_id],&lt;br /&gt;
                });&lt;br /&gt;
        }&lt;br /&gt;
  &lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=Finish and test=&lt;br /&gt;
&lt;br /&gt;
Once again we can package up these files and package install them, beware of testing the dataset stuff on the database and leaving the fields there after you remove you file for packaging.&lt;br /&gt;
&lt;br /&gt;
To test this is all working we can look in the indexer status to ensure the event it getting queued and not failing, hopefully on this page you won't see anything. &lt;br /&gt;
&lt;br /&gt;
To see the resultant values which are written to the dataset you will need to either print them back out in the file citation, or hack your way into the mysql database for your repository and see if it is putting the values in the file table.&lt;br /&gt;
&lt;br /&gt;
  select fileid,filename,file_cmd_mime from file where datasetid=&amp;quot;document&amp;quot; order by fileid desc limit 10;&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Upgrading_EPM_Packages&amp;diff=9707</id>
		<title>Upgrading EPM Packages</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Upgrading_EPM_Packages&amp;diff=9707"/>
		<updated>2010-12-14T17:08:55Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;EPM package guidelines state that you should use semantic version numbers for you package versions. This also makes upgrades easier. This page discusses why and gives an example. &lt;br /&gt;
&lt;br /&gt;
=Semantic Versioning=&lt;br /&gt;
&lt;br /&gt;
Semantic version numbers take the form X.X.X where all X's are numbers and can each be as large as you like. Another way of writing this version number is Major.Minor.Bugfix and is how we shall refer to them from now on. &lt;br /&gt;
&lt;br /&gt;
==Bugfix Releases==&lt;br /&gt;
&lt;br /&gt;
Bugfix releases of Bazaar packages should introduce '''NO''' extra functionality, they should also be able to be installed with '''NO''' user interaction. This way they can auto-update on the server if the user has specified this is OK. &lt;br /&gt;
&lt;br /&gt;
==Minor Releases==&lt;br /&gt;
&lt;br /&gt;
Minor releases can add functionality but as a guide should not change the features of that release or the underlying data model (if there is one). Minor release can require interaction from the user to install. &lt;br /&gt;
&lt;br /&gt;
==Major Releases==&lt;br /&gt;
&lt;br /&gt;
These are really up to the user to install and could completely change the functionality of a package (although not recommended). At this point you can do what you like :)&lt;br /&gt;
&lt;br /&gt;
=Upgrade Methodology=&lt;br /&gt;
&lt;br /&gt;
When an upgrade is done performed upon a package the '''postinst method is not called''' rather an '''upgrade''' method is called and passed the two version numbers. These version numbers correspond to the old version being upgraded and the new version being installed respectively. &lt;br /&gt;
&lt;br /&gt;
==Files on Disk Upgrade==&lt;br /&gt;
This is the first stage of any upgrade.&lt;br /&gt;
&lt;br /&gt;
* Any files belonging to the old version are removed or replaced by new versions. &lt;br /&gt;
* Any new files which were not there before are added.&lt;br /&gt;
* Any errors (e.g. files not under package management cos they have changed) results in an error and the old files are put back and the upgrade aborts. &lt;br /&gt;
&lt;br /&gt;
==API Calls==&lt;br /&gt;
These would have been performed initially by the POSTINST method. However neither this nor the PRERM method are called during an upgrade. Any changes required between versions must be defined in the upgrade method. &lt;br /&gt;
&lt;br /&gt;
==Data and Datasets==&lt;br /&gt;
Datasets are defined in config files, thus any dataset changes are applied. &lt;br /&gt;
&lt;br /&gt;
No data is lost unless the field containing that data is no longer defined by any config file. &lt;br /&gt;
&lt;br /&gt;
Interactive Install/Upgrade/Remove will allow the users to change this behaviour and keep the data even if it actually becomes inaccessible due to nothing in EPrints understanding it. &lt;br /&gt;
&lt;br /&gt;
=Example= &lt;br /&gt;
&lt;br /&gt;
The starting point for this is our Screen plug-in where the POSTINST and PRERM methods are defined (see [[XML manipulation of the EPrints Workflow using a Bazaar Package]]).&lt;br /&gt;
&lt;br /&gt;
To enable upgrades we simply add an upgrade sub alongside these methods:&lt;br /&gt;
&lt;br /&gt;
  sub allow_action_upgrade&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The upgrade method, this will call all upgrade subs individually between the old version number and the new version number.&lt;br /&gt;
  sub action_upgrade&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self, $old_version_number, $new_version_number ) = @_;&lt;br /&gt;
    &lt;br /&gt;
        my @versions = qw(&lt;br /&gt;
                        0.0.1&lt;br /&gt;
                        0.0.2&lt;br /&gt;
        );&lt;br /&gt;
        &lt;br /&gt;
        for(my $i = 0; $i &amp;lt; $#versions; ++$i)&lt;br /&gt;
        {&lt;br /&gt;
               if( $old_version_number eq $versions[$i] )&lt;br /&gt;
               {&lt;br /&gt;
                        no strict 'refs';&lt;br /&gt;
                        my $f = &amp;quot;upgrade_&amp;quot;.$versions[$i].&amp;quot;_to_&amp;quot;.$versions[$i+1];&lt;br /&gt;
                        $f =~ s/\./_/g;&lt;br /&gt;
                        &amp;amp;$f( $self );&lt;br /&gt;
                        $old_version_number = $versions[$i+1];&lt;br /&gt;
               }&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
   &lt;br /&gt;
  sub upgrade_0_0_1_to_0_0_2&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        print STDERR &amp;quot;IN THE UPGRADE ROUTINE FOR 0.0.1 to 0.0.2 \n\n&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Add your API calls POSTINST like stuff here to upgrade versions. &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So all you need to do is define potentially lots of upgrade_X_X_X_to_X_X_Z routines to handle all the upgrades and add this version number (which needs an upgrade routine).&lt;br /&gt;
&lt;br /&gt;
If people are upgrading from 0.0.1 to 0.0.5 then potentially 4 of these upgrade methods will be called.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Upgrading_EPM_Packages&amp;diff=9706</id>
		<title>Upgrading EPM Packages</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Upgrading_EPM_Packages&amp;diff=9706"/>
		<updated>2010-12-14T16:45:58Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;EPM package guidelines state that you should use semantic version numbers for you package versions. This also makes upgrades easier. This page discusses why and gives an example. &lt;br /&gt;
&lt;br /&gt;
=Semantic Versioning=&lt;br /&gt;
&lt;br /&gt;
Semantic version numbers take the form X.X.X where all X's are numbers and can each be as large as you like. Another way of writing this version number is Major.Minor.Bugfix and is how we shall refer to them from now on. &lt;br /&gt;
&lt;br /&gt;
==Bugfix Releases==&lt;br /&gt;
&lt;br /&gt;
Bugfix releases of Bazaar packages should introduce '''NO''' extra functionality, they should also be able to be installed with '''NO''' user interaction. This way they can auto-update on the server if the user has specified this is OK. &lt;br /&gt;
&lt;br /&gt;
==Minor Releases==&lt;br /&gt;
&lt;br /&gt;
Minor releases can add functionality but as a guide should not change the features of that release or the underlying data model (if there is one). Minor release can require interaction from the user to install. &lt;br /&gt;
&lt;br /&gt;
==Major Releases==&lt;br /&gt;
&lt;br /&gt;
These are really up to the user to install and could completely change the functionality of a package (although not recommended). At this point you can do what you like :)&lt;br /&gt;
&lt;br /&gt;
=Upgrade Methodology=&lt;br /&gt;
&lt;br /&gt;
When an upgrade is done performed upon a package the '''postinst method is not called''' rather an '''upgrade''' method is called and passed the two version numbers. These version numbers correspond to the old version being upgraded and the new version being installed respectively. &lt;br /&gt;
&lt;br /&gt;
==Files on Disk Upgrade==&lt;br /&gt;
This is the first stage of any upgrade.&lt;br /&gt;
&lt;br /&gt;
* Any files belonging to the old version are removed or replaced by new versions. &lt;br /&gt;
* Any new files which were not there before are added.&lt;br /&gt;
* Any errors (e.g. files not under package management cos they have changed) results in an error and the old files are put back and the upgrade aborts. &lt;br /&gt;
&lt;br /&gt;
==API Calls==&lt;br /&gt;
These would have been performed initially by the POSTINST method. However neither this nor the PRERM method are called during an upgrade. Any changes required between versions must be defined in the upgrade method. &lt;br /&gt;
&lt;br /&gt;
==Data and Datasets==&lt;br /&gt;
Datasets are defined in config files, thus any dataset changes are applied. &lt;br /&gt;
&lt;br /&gt;
No data is lost unless the field containing that data is no longer defined by any config file. &lt;br /&gt;
&lt;br /&gt;
Interactive Install/Upgrade/Remove will allow the users to change this behaviour and keep the data even if it actually becomes inaccessible due to nothing in EPrints understanding it. &lt;br /&gt;
&lt;br /&gt;
=Example= &lt;br /&gt;
&lt;br /&gt;
The starting point for this is our Screen plug-in where the POSTINST and PRERM methods are defined (see [[XML manipulation of the EPrints Workflow using a Bazaar Package]]).&lt;br /&gt;
&lt;br /&gt;
To enable upgrades we simply add an upgrade sub alongside these methods:&lt;br /&gt;
&lt;br /&gt;
  sub allow_action_upgrade&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The upgrade method, this will call all upgrade subs individually between the old version number and the new version number.&lt;br /&gt;
  sub action_upgrade&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self, $old_version_number, $new_version_number ) = @_;&lt;br /&gt;
    &lt;br /&gt;
        my @versions = qw(&lt;br /&gt;
                        0.0.1&lt;br /&gt;
                        0.0.2&lt;br /&gt;
        );&lt;br /&gt;
        &lt;br /&gt;
        for(my $i = 0; $i &amp;lt; $#versions; ++$i)&lt;br /&gt;
        {&lt;br /&gt;
               if( $old_version_number eq $versions[$i] )&lt;br /&gt;
               {&lt;br /&gt;
                        no strict 'refs';&lt;br /&gt;
                        my $f = &amp;quot;upgrade_&amp;quot;.$versions[$i].&amp;quot;_to_&amp;quot;.$versions[$i+1];&lt;br /&gt;
                        $f =~ s/\./_/g;&lt;br /&gt;
                        &amp;amp;$f( $self );&lt;br /&gt;
                        $old_version_number = $versions[$i+1];&lt;br /&gt;
               }&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
   &lt;br /&gt;
  sub upgrade_0_0_1_to_0_0_2&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        print STDERR &amp;quot;IN THE UPGRADE ROUTINE FOR 0.0.1 to 0.0.2 \n\n&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Add your API calls POSTINST like stuff here to upgrade versions. &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So all you need to do is define potentially lots of upgrade_X_X_X_to_X_X_Z routines to handle all the upgrades. &lt;br /&gt;
&lt;br /&gt;
If people are upgrading from 0.0.1 to 0.0.5 then potentially 4 of these upgrade methods will be called.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=Upgrading_EPM_Packages&amp;diff=9705</id>
		<title>Upgrading EPM Packages</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=Upgrading_EPM_Packages&amp;diff=9705"/>
		<updated>2010-12-14T16:45:50Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: Created page with 'EPM package guidelines state that you should use semantic version numbers for you package versions. This also makes upgrades easier. This page discusses why and gives an example.…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;EPM package guidelines state that you should use semantic version numbers for you package versions. This also makes upgrades easier. This page discusses why and gives an example. &lt;br /&gt;
&lt;br /&gt;
=Semantic Versioning=&lt;br /&gt;
&lt;br /&gt;
Semantic version numbers take the form X.X.X where all X's are numbers and can each be as large as you like. Another way of writing this version number is Major.Minor.Bugfix and is how we shall refer to them from now on. &lt;br /&gt;
&lt;br /&gt;
==Bugfix Releases==&lt;br /&gt;
&lt;br /&gt;
Bugfix releases of Bazaar packages should introduce '''NO''' extra functionality, they should also be able to be installed with '''NO''' user interaction. This way they can auto-update on the server if the user has specified this is OK. &lt;br /&gt;
&lt;br /&gt;
==Minor Releases==&lt;br /&gt;
&lt;br /&gt;
Minor releases can add functionality but as a guide should not change the features of that release or the underlying data model (if there is one). Minor release can require interaction from the user to install. &lt;br /&gt;
&lt;br /&gt;
==Major Releases==&lt;br /&gt;
&lt;br /&gt;
These are really up to the user to install and could completely change the functionality of a package (although not recommended). At this point you can do what you like :)&lt;br /&gt;
&lt;br /&gt;
=Upgrade Methodology=&lt;br /&gt;
&lt;br /&gt;
When an upgrade is done performed upon a package the '''postinst method is not called''' rather an '''upgrade''' method is called and passed the two version numbers. These version numbers correspond to the old version being upgraded and the new version being installed respectively. &lt;br /&gt;
&lt;br /&gt;
==Files on Disk Upgrade==&lt;br /&gt;
This is the first stage of any upgrade.&lt;br /&gt;
&lt;br /&gt;
* Any files belonging to the old version are removed or replaced by new versions. &lt;br /&gt;
* Any new files which were not there before are added.&lt;br /&gt;
* Any errors (e.g. files not under package management cos they have changed) results in an error and the old files are put back and the upgrade aborts. &lt;br /&gt;
&lt;br /&gt;
==API Calls==&lt;br /&gt;
These would have been performed initially by the POSTINST method. However neither this nor the PRERM method are called during an upgrade. Any changes required between versions must be defined in the upgrade method. &lt;br /&gt;
&lt;br /&gt;
==Data and Datasets==&lt;br /&gt;
Datasets are defined in config files, thus any dataset changes are applied. &lt;br /&gt;
&lt;br /&gt;
No data is lost unless the field containing that data is no longer defined by any config file. &lt;br /&gt;
&lt;br /&gt;
Interactive Install/Upgrade/Remove will allow the users to change this behaviour and keep the data even if it actually becomes inaccessible due to nothing in EPrints understanding it. &lt;br /&gt;
&lt;br /&gt;
=Example= &lt;br /&gt;
&lt;br /&gt;
The starting point for this is our Screen plug-in where the POSTINST and PRERM methods are defined (see [[XML manipulation of the EPrints Workflow using a Bazaar Package]]).&lt;br /&gt;
&lt;br /&gt;
To enable upgrades we simply add an upgrade sub alongside these methods:&lt;br /&gt;
&lt;br /&gt;
  sub allow_action_upgrade&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # The upgrade method, this will call all upgrade subs individually between the old version number and the new version number.&lt;br /&gt;
  sub action_upgrade&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self, $old_version_number, $new_version_number ) = @_;&lt;br /&gt;
    &lt;br /&gt;
        my @versions = qw(&lt;br /&gt;
                        0.0.1&lt;br /&gt;
                        0.0.2&lt;br /&gt;
        );&lt;br /&gt;
        &lt;br /&gt;
        for(my $i = 0; $i &amp;lt; $#versions; ++$i)&lt;br /&gt;
        {&lt;br /&gt;
               if( $old_version_number eq $versions[$i] )&lt;br /&gt;
               {&lt;br /&gt;
                        no strict 'refs';&lt;br /&gt;
                        my $f = &amp;quot;upgrade_&amp;quot;.$versions[$i].&amp;quot;_to_&amp;quot;.$versions[$i+1];&lt;br /&gt;
                        $f =~ s/\./_/g;&lt;br /&gt;
                        &amp;amp;$f( $self );&lt;br /&gt;
                        $old_version_number = $versions[$i+1];&lt;br /&gt;
               }&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
   &lt;br /&gt;
  sub upgrade_0_0_1_to_0_0_2&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        print STDERR &amp;quot;IN THE UPGRADE ROUTINE FOR 0.0.1 to 0.0.2 \n\n&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
        # Add your API calls POSTINST like stuff here to upgrade versions. &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So all you need to do is define potentially lots of upgrade_X_X_X_to_X_X_Z routines to handle all the upgrades. &lt;br /&gt;
&lt;br /&gt;
If people are upgrading from 0.0.1 to 0.0.5 then potentially 4 of these upgrade methods will be called.&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package&amp;diff=9703</id>
		<title>XML manipulation of the EPrints Workflow using a Bazaar Package</title>
		<link rel="alternate" type="text/html" href="https://wiki.eprints.org/w/index.php?title=XML_manipulation_of_the_EPrints_Workflow_using_a_Bazaar_Package&amp;diff=9703"/>
		<updated>2010-12-13T13:37:59Z</updated>

		<summary type="html">&lt;p&gt;DaveTarrant: /* Add a new depoist type */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Manipulation of built in EPrint files, such as the Workflows, is currently performed using the postinst method which is run after the rest of package is installed. &lt;br /&gt;
&lt;br /&gt;
Likewise when the package is removed, the prerm method needs to call exactly the opposite set of operations to clean itself up before full removal.&lt;br /&gt;
&lt;br /&gt;
As we go along we'll see that if you don't cleanup behind you, you won't even be able to re-install your same package again as the installer will detect conflicting data already in existence.&lt;br /&gt;
&lt;br /&gt;
=Pre-Requisites=&lt;br /&gt;
&lt;br /&gt;
To edit EPrints XML we need an epm package containing a spec file which points to a plug-in where we are going to put out postinst and prerm methods. &lt;br /&gt;
&lt;br /&gt;
Below is a simple framework for your plug-in (it's a Screen plug-in so needs to go in the cfg/plugins/EPrints/Plugin/Screen/Admin directory). Remember to name it applicably and match this name with the one in the spec file. &lt;br /&gt;
&lt;br /&gt;
  package EPrints::Plugin::Screen::Admin::MYNAME;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = ( 'EPrints::Plugin::Screen' );&lt;br /&gt;
   &lt;br /&gt;
  use strict;&lt;br /&gt;
  &lt;br /&gt;
  sub new&lt;br /&gt;
  {&lt;br /&gt;
        my( $class, %params ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $self = $class-&amp;gt;SUPER::new(%params);&lt;br /&gt;
  &lt;br /&gt;
        $self-&amp;gt;{actions} = [qw/ postinst prerm /];&lt;br /&gt;
        &lt;br /&gt;
        $self-&amp;gt;{package_name} = &amp;quot;package_name&amp;quot;;  &lt;br /&gt;
  &lt;br /&gt;
        return $self;&lt;br /&gt;
  } &lt;br /&gt;
  &lt;br /&gt;
  # Can this screen be viewed?&lt;br /&gt;
  sub can_be_viewed&lt;br /&gt;
  {&lt;br /&gt;
        my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Do we have a prerm method which needs executing?&lt;br /&gt;
  sub allow_action_prerm&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # Do we have a postinst method which needs executing?&lt;br /&gt;
  sub allow_action_postinst&lt;br /&gt;
  {&lt;br /&gt;
        my( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return 1;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The postinst routine&lt;br /&gt;
  sub action_postinst&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository}-&amp;gt;get_repository();&lt;br /&gt;
        &lt;br /&gt;
        # Everthing went OK (why the hell did I code this the wrong way round?)&lt;br /&gt;
        return (0,undef);&lt;br /&gt;
        # Something went wrong&lt;br /&gt;
        # return (1,&amp;quot;MUPPET!!!&amp;quot;)&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # The prerm routine&lt;br /&gt;
  sub action_prerm&lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        my $repository = $self-&amp;gt;{repository}-&amp;gt;get_repository();&lt;br /&gt;
  &lt;br /&gt;
        return (0,undef);&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  # A render method for the screen, which we don't need unless we allow this screen to be viewed.&lt;br /&gt;
  # If this screen is visible you return an html fragment, or redirect somewhere else, like a config file :)&lt;br /&gt;
  sub render &lt;br /&gt;
  {&lt;br /&gt;
        my ( $self ) = @_;&lt;br /&gt;
  &lt;br /&gt;
        return undef;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
&lt;br /&gt;
=Remember how to force remove a broken package=&lt;br /&gt;
&lt;br /&gt;
  perl bin/epm archive_name remove package_name --force&lt;br /&gt;
&lt;br /&gt;
=Exercise 1=&lt;br /&gt;
&lt;br /&gt;
In this exercise we are going to do some simple workflow editing exercises. These follow the standard EPrints training materials which teach you how to manually edit the workflow. Here we are going to do all the same stuff with API calls. &lt;br /&gt;
&lt;br /&gt;
=Adding a Divisions Stage to the Workflow=&lt;br /&gt;
&lt;br /&gt;
Basically we are simply editing XML so all we need to do is tell the repository which file to manipulate and then give it the stuff add to this file. &lt;br /&gt;
&lt;br /&gt;
So to the '''postinst''' routine we need to add the following lines. Note that you '''don't''' need to manually specify your package_name &lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  # Gap for the stuff to be defined we need to add&lt;br /&gt;
  &lt;br /&gt;
  my $rc = EPrints::XML::add_to_xml( $filename, $xml, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At the same time then it is worth adding the equivalent remove lines to the '''prerm''' method. Again you need to specify your package name. &lt;br /&gt;
&lt;br /&gt;
  my $filename = $repository-&amp;gt;config( &amp;quot;config_path&amp;quot; ).&amp;quot;/workflows/eprint/default.xml&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  EPrints::XML::remove_package_from_xml( $filename, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Note that the remove call does not return a state as it will be able to remove anything, but it won't error if there is nothing to remove. Thus all return states are OK (this may change if someone can think of an exception)&lt;br /&gt;
&lt;br /&gt;
Lastly we need to actually tell the postinst method the block of XML to add.&lt;br /&gt;
&lt;br /&gt;
  my $string = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;flow&amp;gt;&lt;br /&gt;
                &amp;lt;stage ref=&amp;quot;divisions&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/flow&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;divisions&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;component type=&amp;quot;Field::Subject&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;field ref=&amp;quot;divisions&amp;quot; required=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
                &amp;lt;/component&amp;gt;&lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
 &amp;lt;/workflow&amp;gt;&lt;br /&gt;
 ';&lt;br /&gt;
  &lt;br /&gt;
  my $xml = EPrints::XML::parse_string( undef, $string );&lt;br /&gt;
  $xml = EPrints::XML::_remove_blank_nodes($xml);&lt;br /&gt;
  my $node = $xml-&amp;gt;getFirstChild();&lt;br /&gt;
&lt;br /&gt;
Here you can see that we can simply specify the XML as a string. We can then either parse this string and send a dom object to the add method, or simply send the string and let the add_to_xml method do it for us. &lt;br /&gt;
&lt;br /&gt;
If you want to parse it yourself you will need the following code block:&lt;br /&gt;
&lt;br /&gt;
  my $xml = EPrints::XML::parse_string( undef, $string );&lt;br /&gt;
  &lt;br /&gt;
The XML represents the exact same tree as in the workflow XML file we are attempting to edit. You can view this by clicking the &amp;quot;View Configuration&amp;quot; button on the &amp;quot;Config. Tools&amp;quot; tab of the admin screen. Once here you will need to scroll down to find the file you specified (in this case /workflows/eprint/default.xml). Since it represents the same tree, only nodes which don't exist are added and marked as belonging to your package. This marker is how they are removed. &lt;br /&gt;
&lt;br /&gt;
Alternatively you can build an XML tree using the EPrints::XML methods like make_element(&amp;quot;flow&amp;quot;) etc. At this point (unless you added blank nodes) you won't need the remove line, but it doesn't hurt to leave it in there. &lt;br /&gt;
&lt;br /&gt;
Finally make sure you have all your variables like $rc (return code) defined and then this screen should be ready.&lt;br /&gt;
&lt;br /&gt;
==Divisions Phrases==&lt;br /&gt;
&lt;br /&gt;
For the divisions screen to work fully you will need to define a number of phrases.&lt;br /&gt;
&lt;br /&gt;
As usual you need a new file, basically take a copy of cfg/lang/en/phrases/zz_webcfg in cfg/lang/en/phrases/package_name. &lt;br /&gt;
&lt;br /&gt;
The clear all the defined phrases from this file and add the follow 2:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;epp:phrase id=&amp;quot;metapage_title_divisions&amp;quot;&amp;gt;Divisions&amp;lt;/epp:phrase&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;epp:phrase id=&amp;quot;Plugin/InputForm/Component/Field/Subject:divisions_search_bar&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;ep_subjectinput_searchbar&amp;quot;&amp;gt;Search for division: &amp;lt;epc:pin name=&amp;quot;input&amp;quot;/&amp;gt; &amp;lt;epc:pin name=&amp;quot;search_button&amp;quot;/&amp;gt; &amp;lt;epc:pin name=&amp;quot;clear_button&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/epp:phrase&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Package and Test=&lt;br /&gt;
&lt;br /&gt;
Finally, package all these files up and test in from the Bazaar. Note that in the spec file you need to set your configuration file to Admin::PackageName or whatever your screen is called. &lt;br /&gt;
&lt;br /&gt;
You can test this package by click the &amp;quot;manage deposits&amp;quot;  link in the admin toolbar and adding a new item. You should see a divisions tab.&lt;br /&gt;
&lt;br /&gt;
=Exercise 2=&lt;br /&gt;
&lt;br /&gt;
Change this package to add a conditional element somewhere, for example:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;epc:if test=&amp;quot;type = 'book'&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;field ref=&amp;quot;pres_type&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/epc:if&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Experiment with this and use the &amp;quot;view configuration&amp;quot; to see what your changes do to the workflow file each time.&lt;br /&gt;
&lt;br /&gt;
Clue: The correct place to put this code block is under the &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt; tag which is in the core stage &amp;lt;stage name=&amp;quot;core&amp;quot;&amp;gt;. You need to wrap the above code blog in both these tags.&lt;br /&gt;
&lt;br /&gt;
If you are using the same package as before you will need to updated your cached version and then restart apache to make it work. This is a known bug and applies the the XML manipulation code only.&lt;br /&gt;
&lt;br /&gt;
=Exercise 3=&lt;br /&gt;
&lt;br /&gt;
Here we are going to define a whole new type &amp;quot;map&amp;quot; and a different set of stages for it.&lt;br /&gt;
&lt;br /&gt;
This exercise is also one of manual customisation exercises we run. &lt;br /&gt;
&lt;br /&gt;
==Add a new depoist type==&lt;br /&gt;
&lt;br /&gt;
This stage involves the editing of the repository namedsets, specifically the eprints namedset. &lt;br /&gt;
&lt;br /&gt;
Again this used to be an entirely manual process however it can now be done with an API call via the postinst/prerm methods:&lt;br /&gt;
&lt;br /&gt;
In '''postinst''':&lt;br /&gt;
  &lt;br /&gt;
  # Load your namedset, in this case the eprint namedset&lt;br /&gt;
  my $namedset = EPrints::NamedSet-&amp;gt;new( &amp;quot;eprint&amp;quot;,repository =&amp;gt; $repository );&lt;br /&gt;
  &lt;br /&gt;
  # Add a new option (string type, package_name, offset from top) &lt;br /&gt;
  # Setting the offset to 0 will add the item at the top of list of eprint types in this case. &lt;br /&gt;
  $namedset-&amp;gt;add_option( &amp;quot;map&amp;quot;, $self-&amp;gt;{package_name}, 0 );&lt;br /&gt;
  &lt;br /&gt;
In '''prerm''' we need the corresponding remove calls! &lt;br /&gt;
&lt;br /&gt;
  my $namedset = EPrints::NamedSet-&amp;gt;new( &amp;quot;eprint&amp;quot;,repository =&amp;gt; $repository );&lt;br /&gt;
  &lt;br /&gt;
  $namedset-&amp;gt;remove_option( &amp;quot;map&amp;quot;, $self-&amp;gt;{package_name} );&lt;br /&gt;
&lt;br /&gt;
Each namedset item also needs some phrase so in our phrase file we need to add phrases for &amp;quot;eprint_typename_map&amp;quot; and &amp;quot;eprint_optdetails_type_map&amp;quot;. Lets set these to &amp;quot;Map&amp;quot; and &amp;quot;A map or chart.&amp;quot; respectively.&lt;br /&gt;
&lt;br /&gt;
==Adding a new stage and simple map workflow==&lt;br /&gt;
&lt;br /&gt;
In this section we are going to define a whole new workflow for our &amp;quot;map&amp;quot; type, so if someone selects this as their EPrint type they won't see upload (files), subjects and divisions, just a new state we going to call &amp;quot;map_stage&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Of course in order to customise the workflow we need to handle if/else statements. Helpfully there is a clever API call that does it for you. &lt;br /&gt;
&lt;br /&gt;
All we have to define in the types we want to match and the stages that these types have. Everything that doesn't match thus goes in the else condition. &lt;br /&gt;
&lt;br /&gt;
So in our postinst lets now define some variables&lt;br /&gt;
&lt;br /&gt;
  #our matching types &lt;br /&gt;
  my @types = ( &amp;quot;map&amp;quot; );&lt;br /&gt;
  &lt;br /&gt;
  #the stages&lt;br /&gt;
  my @stages = ( &amp;quot;map_stage&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Then we add these to our workflow with a similar API call to before (note the inclusion of the package_name!)&lt;br /&gt;
&lt;br /&gt;
  $rc = EPrints::Workflow::add_workflow_flow( $repository, $filename, &amp;quot;package_name&amp;quot;, \@types, \@stages );&lt;br /&gt;
&lt;br /&gt;
We can then use the xml string which we defined before to add the new stage:&lt;br /&gt;
&lt;br /&gt;
  my $string = '&lt;br /&gt;
  &amp;lt;workflow xmlns=&amp;quot;http://eprints.org/ep3/workflow&amp;quot; xmlns:epc=&amp;quot;http://eprints.org/ep3/control&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;stage name=&amp;quot;map_stage&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;component type=&amp;quot;Field::Multi&amp;quot;&amp;gt;&lt;br /&gt;
                     &amp;lt;title&amp;gt;Publisher Details&amp;lt;/title&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;place_of_pub&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;publisher&amp;quot; required=&amp;quot;yes&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;date&amp;quot; /&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;date_type&amp;quot; /&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;&lt;br /&gt;
               &amp;lt;component&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;id_number&amp;quot; /&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;&lt;br /&gt;
               &amp;lt;component&amp;gt;&lt;br /&gt;
                     &amp;lt;field ref=&amp;quot;official_url&amp;quot;/&amp;gt;&lt;br /&gt;
               &amp;lt;/component&amp;gt;      &lt;br /&gt;
        &amp;lt;/stage&amp;gt;&lt;br /&gt;
  &amp;lt;/workflow&amp;gt;&lt;br /&gt;
  ';&lt;br /&gt;
&lt;br /&gt;
=Package and Test=&lt;br /&gt;
&lt;br /&gt;
Finally, package all these files up and test in from the Bazaar. &lt;br /&gt;
&lt;br /&gt;
You can test this package by click the &amp;quot;manage deposits&amp;quot;  link in the admin toolbar and adding a new item. You should now have a new eprint type on the first screen called &amp;quot;map&amp;quot; and selecting this will give you a much shorter workflow containing only a few fields. &lt;br /&gt;
&lt;br /&gt;
Are all your phrases defined?&lt;/div&gt;</summary>
		<author><name>DaveTarrant</name></author>
		
	</entry>
</feed>