<?xml version="1.0" encoding="UTF-8"?>
<actions>


<meta>
  <description lang="de">Schnittstelle für die standardisierte SRU-API für Suche in Katalogen</description>
  <description lang="en">Interface for the SRU API for searching in libraries</description>
  <variable name="baseurl">
    <description lang="de">URL des Servers, inklusive https:// Protokoll</description>
    <description lang="en">URL of the library server, including protocol</description>
  </variable>
<!--  <variable name="searchKeys"><description>zu verwendende Suchschlüssel (optional)</description></variable>  
  <variable name="recordSchema"><description>zu verwendendes Schema (optional)</description></variable>-->
  <!--<variable name="daiabaseurl"><description>Url für einen DAIA-Server für Bestandsanzeigen</description></variable>-->
</meta>

<action id="search-connect">
  <s>
  sruVersion := "1.1",
  recordSchema := "dc",
  searchKeys := {"title": "dc.title", 
                 "author": "dc.creator", 
                 "isbn": "dc.identifier", 
                 "year": "dc.date", 
                 "keywords": "dc.subject"}
  </s>
  <try>
    <page url="{$baseurl}" templateFile="sruconnect"/>
  <catch errors="http:*"/>
  </try>
</action>

<action id="search">
  
  <variable name="maximumRecords">20</variable>
  
  <variable name="query">
  encode-for-uri( string-join(
    (if ($book.title)    then concat($searchKeys.title, "=""", $book.title, """")    else (),
     if ($book.author)   then concat($searchKeys.author, "=""", $book.author, """")   else (),
     if ($book.isbn)     then concat($searchKeys.isbn, "=""", $book.isbn, """")     else (),
     if ($book.year)     then concat($searchKeys.year, "=""", $book.year, """")     else (),
     if ($book.keywords) then concat($searchKeys.keywords, "=""", $book.keywords, """") else ()), " AND "))
  </variable>

  <variable name="position">1</variable>

  <page url="{$baseurl}?version=1.1&operation=searchRetrieve&query={$query}&maximumRecords={$maximumRecords}&recordSchema={$recordSchema}" templateFile="list"/>
</action>

<action id="search-next-page">
  <variable name="position">$position + $maximumRecords</variable>
  <page url="{$baseurl}?version=1.1&operation=searchRetrieve&query={$query}&maximumRecords={$maximumRecords}&recordSchema={$recordSchema}&startRecord={$position}" templateFile="list"/>
</action>

<action id="search-details">
  <if test="exists($book.ppn) and contains($baseurl, 'gbv.de')">
    <page url="http://gso.gbv.de/DB=2.1/PPNSET?PPN={$book.ppn}&HILN=888#888">
      <template>
        <DIV class="holding_box" t:optional="true">{$libName:="??"}
          <DIV>
            <t:switch>
              <TABLE><TR><span class="libName">{
                $libName := .
              }</span></TR></TABLE>
              <table summary="holding info">
               {$holding := {"libraryBranch": $libName, "orderable": false() }}
               <tr>
                <td class="rec_lable_holding"><span class="left60">{$prop}</span></td>
                <td class="rec_title">{$holding($prop||"!") := .}</td>
               </tr>+
               <t:s>$book.holdings[] := $holding</t:s>
              </table>
            </t:switch>
          </DIV>*
        </DIV>
      </template>
    </page>
  </if>
</action>

</actions>
