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

<meta>
  <description>Schnittstelle für die Digibib Version 7</description>
  <variable name="searchurl"><description>Adresse des Katalog</description></variable>
  <variable name="searchparams"><description>Zusätzliche Parameter</description></variable>
</meta>


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

<action id="search">
  <s>$starturl := request-combine($searchurl || "/list?defaults=on&amp;start=1",
                                 (get("searchparams", ()), 
                                 {"q-ti": $book.title, 
                                 "q-au": $book.author, 
                                 "q-yr": $book.year, 
                                 "q-ky": $book.keywords, 
                                 "q-ib": $book.isbn, 
                                 "q-is": $book.issn})) </s>
  <page url="{$starturl}"/>
  <pattern href="search-pagination"/>  
  <pattern href="search"/>  
  
   <!-- <page url="http://www.digibib.net/{$url}" templateFile="search"/> -->
  
<!--  <page url="http://www.digibib.net/Digibib?SID={$sid}&LOCATION={$location}&SERVICE=METASEARCH&SUBSERVICE=GETLIST&PREVREQID={$reqid}&STREAMING=TRUE&VIEW={$view}&FORMAT=List&START=1&COUNT=100&METAID={$metaid}" templateFile="search"/>-->
  
<!--  <page url="http://abderos.hbz-nrw.de/Digibib?SERVICE=METASEARCH&amp;SUBSERVICE=GETLIST&amp;{$metaid}&amp;FORMAT=List&amp;URLENCODING=TRUE&amp;START=1&amp;COUNT=200&amp;SID={$sid}&amp;LOCATION={$location}&amp;{$sreqid}&amp;{$reqid}&amp;{$olreqid}&amp;STREAMING=on" templateFile="search"/>
-->  

</action>

<action id="search-next-page"> 
  <if test="contains($next-page, '/list/data')">  
    <s>
     $search-next-page-available := false(),
     $next-page-html := (),
     
    
     $eventStreamText := unparsed-text($next-page),
     let $eventStream := x:lines($eventStreamText)
     for tumbling window $w in $eventStream start when true end $line when $line eq ""
     let $id := ($w[starts-with(., "id")] ! substring-after(., ":")) => string-join() => normalize-space()
     let $data := ($w[starts-with(., "data")] ! substring-after(., ":")) => string-join()
     where string-length($data) > 5
     let $json := parse-json($data)
     where string-length($json?html) > 5
     return switch ($id)
       case "HEADER" return ()
       case "FOOTER" return footer-html := $json?html
       default return
         (
           $search-result-count := $json?hitcount,
           $next-page-html := $json?html
           (:todo multiple libraries:)
         )
    </s>
    <if test="exists($next-page-html)">  
      <page data="{$next-page-html}" pattern-href="search"/>
      <page data="{$footer-html}" pattern-href="search-pagination"/>
    </if>
  </if>
  <else>
    <page url="{$next-page}"/>
    <pattern href="search-pagination"/>
    <pattern href="search"/>
  </else>
</action>


<action id="search-details"> 
  <page url="{$book.digibib-url}" templateFile="details"/>
</action>


</actions>

 <!--<input type="hidden" name="VIEW"        value="DUEBIB:Lokale_Bibliotheken" />"/><input type="hidden" name="LOCATION"    value="DUEBIB
      QUERY_czCO = körperschaft, QUERY_0czCO
      QUERY_dzPB = verlag, QUERY_0dzPB
      
     " http://abderos.hbz-nrw.de/Digibib?SERVICE=METASEARCH&amp;SUBSERVICE=GETLIST&amp;METAID=4782&amp;FORMAT=List&amp;URLENCODING=TRUE&amp;START=1&amp;COUNT=10&amp;SID=RHEA:1906707980&amp;LOCATION=362&amp;SREQID=RHEA:38292267&amp;REQID=RHEA:38292267&amp;OLREQID=RHEA:38292267&amp;STREAMING=off"/>-->
