<?xml version="1.0" encoding="UTF-8"?>
<t:switch-prioritized>
<html>
  <a>Vormerkungen<t:s>reservations:=@href</t:s></a>?
  
  <table summary="list of loans - data">
    <t:switch>
    <tr>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td><!--title-->Titel</td>
      <td></td>
      <td></td>
      <td></td>
      <td><!--shelf mark-->Signatur</td>
      <td></td>
      <td></td>
      <td></td>
      <td><!--status-->Status</td>
      <td></td>
      <td></td>
      <td></td>
      <td><!--volume-->Band</td>
      <td></td>
      <td></td>
      <td></td>
      <td><!--expiry--><template:match-text regex="Leihfristende|zurückzugeben vor dem"/></td>
<!--      <td></td>
      <td></td>
      <td></td>
      <td><!- -reservations- ->Vormerkungen</td>
      <td></td>
      <td></td>
      <td></td>
      <td><!- -renewals- -><template:match-text regex="Verlängerungen"/></td>
      <td></td>
      <td></td>
      <td></td>-->
      {picaVersion := 1}
    </tr>
    
    <tr>
     <td class="infotab"/>
     <td/>
     <td class="infotab"/>
     <td></td>
     <td></td>
     <td class="infotab"/>
     <td class="infotab">Ti</td>
     <td></td>
     {picaVersion := 2}
    </tr>
    </t:switch>
    
    <tr> <td class="h2"></td> </tr>
    
    <template:read var="delete-current-books()"/>
    
    
    <t:if test="$picaVersion = 1">
      <template:loop>
      <tr>
        {book := object()}
        <td></td>
        <td >
          {book.extendId:=''}
          <input name="VB" type="checkbox">{book.extendId:=@value}</input>?
        </td>
        <td></td>
        <td></td>
        <td></td>
        <td>
          <template:read source="text()" var="book.title" regex="^[^/]*"/>
          <template:read source="text()" var="book.author" regex="^[^/]*/\s*(von)?\s*(.*)" submatch="2"/>
        </td>
    
        <td></td><td></td><td></td><td class="value-small">{$book.id}</td>
        <td></td><td></td><td></td><td class="value-small">
          <template:switch value="$book.extendId">
            <template:if value="''">
              {$book.status := normalize-space(.),
               $book.statusId := 
                 if (matches($book.status, "(Abhol|Vormerk)regal" )) then ("provided",  book.cancelable := false())[1]
                 else if (matches($book.status, "Vormerkung|bestellt" )) then ("ordered",  book.cancelable := false())[1]
                 else "critical"
               }
            </template:if>
            <template:read var="book.status:curious" source="."/>
          </template:switch>
        </td>
        <td></td><td></td><td></td><td class="value-small"></td>
        <td></td><td></td><td></td><td class="value-small">
          <template:if test="text()!=''"><template:read source="." var="book.duedate:dd-mm-yyyy"/></template:if>
        </td>
  <!--      <td></td><td></td><td></td><td class="value-small"></td>
        <td></td><td></td><td></td><td class="value-small"><iframe></iframe></td>-->
      </tr>
    </template:loop>
    </t:if>

  
    <t:if test="$picaVersion = 2">
    <tr> {$book := {}}         
      <td/>
      <td></td>
      
      <td>{$book.extendId := ''}
       <input type="checkbox" name="VB">{$book.extendId:=@value}</input>?
      </td>
      
      <td></td>
      <td></td>
      <td></td>
      
      <td></td>
      
      <td>
       
       <table>
        
        <tr>
         <td class="plain">{$book.title}</td>
         </tr>
        
        <tr>{
         for tumbling window $w in .//span/(.,following-sibling::text()  (:,following-sibling::span[1]:)  )
         start when true()
         end next $next-span when contains-token($next-span/@class, "label-small")
         let $v := string-join(tail($w))
         return switch (extract($w[1], "[A-Za-z]+")) 
           case "Signatur" return $book.id := $v
           case "Leihfristende" return $book.duedate := parse-date($v)
           case "Status" return $book.status := $v
(:           case "Vormerkungen" return $book.?? := $v:)
           default return $book.status := $book.status || ", " || join($w)
         }</tr>
        
        </table>
       
       </td>
      
      </tr>+
    </t:if>    
  
  </table>
</html>


<table summary="Message block header">
<strong class="alert">{
  string() ! (if (contains(., "Nummer und/oder Passwort sind nicht korrekt.")) then vl:raise-login(.)
  else vl:raise(.))
}</strong>
</table>
</t:switch-prioritized>
