<?xml version="1.0" encoding="UTF-8"?>
<actions max-version="1675" version-mismatch="skip">


<meta>
  <description>Template für die standardisierte SRU-API für Suche in Katalogen</description>
  <variable name="baseurl"><description>Url des Servers, inklusive Protokoll</description></variable>
  <variable name="searchKeys" default="dc.title;dc.creator;dc.identifier;dc.date;dc.subject"><description>zu verwendende Suchschlüssel</description></variable>  
  <variable name="recordSchema" default="dc"><description>zu verwendende Suchschlüssel</description></variable>
  <!--<variable name="daiabaseurl"><description>Url für einen DAIA-Server für Bestandsanzeigen</description></variable>-->
</meta>

<action id="search-connect"></action>

<action id="search">
  
  <variable name="maximumRecords">15</variable>
  <variable name="recordSchema">get("recordSchema", "dc")</variable>

  <variable name="searchKey">
  tokenize(get("searchKeys", "dc.title;dc.creator;dc.identifier;dc.date;dc.subject"), ";")
  </variable>
  
  <variable name="query">
  encode-for-uri( string-join(
    (if ($book.title != "")    then concat($searchKey[1], "=", $book.title)    else (),
     if ($book.author != "")   then concat($searchKey[2], "=", $book.author)   else (),
     if ($book.isbn != "")     then concat($searchKey[3], "=", $book.isbn)     else (),
     if ($book.year != "")     then concat($searchKey[4], "=", $book.year)     else (),
     if ($book.keywords != "") then concat($searchKey[5], "=", $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:="??", $bestand := 0}
          <DIV>
            <t:switch>
              <TABLE><TR><span class="libName">{
                $libName := .                
              }</span></TR></TABLE>
              <table summary="holding info">
               {$bestand := $bestand + 1,  $book(x"Exemplar {$bestand} in !") := $libName  }
               <tr>
                <td class="rec_lable_holding"><span class="left60">{$id}</span></td>
                <td class="rec_title">{$book(x"Ex. {$bestand} {$id}!") := .}</td>
               </tr>+
              </table>
            </t:switch>
          </DIV>*
        </DIV>
      </template>
    </page>
  </if>
</action>

</actions>
