<html>
<body>
  <t:switch prioritized="true">
    <table class="data">
      <tr> 
        <td>
          {book := $b, book._select := $b}
          <strong class="c2">Titel:</strong>
          <strong>{let $newBookTitle:=text() return
            if (  substring(normalize-space(translate($newBookTitle, "¬", "")), 1, 60)
                !=substring(normalize-space(translate($book.title  , "¬", "")), 1, 60)) then 
              vl:raise(x'Es wurde {$newBookTitle} verlängert, obwohl {$book.title} verlängert werden sollte.')
            else ()
          }</strong>
          
          <t:s>status_found:=false()</t:s>
          <strong class="c2" template:optional=true>Status:<t:s>status_found:=true()</t:s></strong>
          <t:if test="$status_found"><strong>
            <template:read source="text()" var="book.status:problematic"/>
          </strong></t:if>
          
          <strong class="c2">neues Leihfristende:
            <t:s>let $date := string-join(./following-sibling::node(), '')
                 return if (matches($date, "\d+")) then $book.duedate := parse-date($date,'dd.mm.yyyy')
                 else vl:raise("VERLÄNGERUNGSDATUM KANN NICHT GELESEN WERDEN: " || outer-html(..))
            </t:s>
          </strong>

        </td>
      </tr>       
    </table>
    
    <div class="message-confirm">Medium erfolgreich verlängert!<t:s>need-update:=true()</t:s></div>
    
    <span class="textrot">{vl:raise("Fehler beim Verlängern von " || $book.title ||": "|| .)} </span>
  </t:switch>
</body>
</html>