<t:switch prioritized="true">
  <html> {
  declare function local:parse-column($element){ 
    $element/normalize-space(string-join(node() except span[contains(@class, "oclc-module-label")])) 
  };
  reserve-request:=()
  }
    <head> 
      <meta property="og:image" content="{$book.image-url}"/>?
    </head>
    <body>
      {$book.image-url[] := css(".standardPaddingCover")//(img,input[type="image"])!(@src, tokenize(@sources, "[|]")[contains(.,"://")]) }

  
  
      <div t:condition="contains(@id, 'DivAvailRegionDetail')">
        <t:switch>
          <input type="image" t:condition="contains(@name, 'mediumImageAvailDetail')">{book.orderable := contains(@src, "false.png")}</input>
          <img t:condition="contains(@id, 'mediumImageAvailDetail')">{book.orderable := contains(@src, "false.png")}</img>
          <img t:condition="contains(@id, 'mediumImageDigitalDetail')">{$book("Download !") := ../@href}</img>
        </t:switch>
  
        <input t:test="$book.orderable">{$book._orderTarget := @name}</input>?
      </div>?
           
    
      <table t:condition="contains(@id, 'grdViewMediumCopies')">
        <tr><t:siblings-header>
          <th><template:match-text regex="Zweigstelle|Bibliothek|Bücherei"/></th>?
          <th><template:match-text regex="Standort|Bereich"/></th>*
          <th>Signatur</th>?
          <th>Status</th>?
          <th>Frist</th>?
          <th>Vorbestellungen</th>?
          <th>Barcode</th>?
          <th>Mediengruppe</th>?
          <th>Interessenkreis</th>?
          <th>Ausleihhinweis</th>?
          <th></th>*
        </t:siblings-header><!--Status,Frist,Vorbestellungen seem to be always theree--></tr>
        <tr>{$holding:={}}<t:siblings>
          <td>{$holding.libraryBranch := local:parse-column(.)}</td>
          <td>{$holding.libraryLocation := normalize-space($holding.libraryLocation || " " || local:parse-column(.))}</td>
          <td>{$holding.id := local:parse-column(.)}</td>
          <td>{$holding.statusStr := local:parse-column(.)}</td>
          <td>{translate(local:parse-column(.), "&#xA0;", "")[.] ! ( $holding.duedate := parse-date(.) ) }</td>
          <td>{translate(local:parse-column(.), "&#xA0;", "")[.] ! ( $holding.pendingOrders := . ) }</td>
          <td>{$holding.barcode := local:parse-column(.)}</td>
          <td>{$holding.category := local:parse-column(.)}</td>
          <td>{$holding.category := local:parse-column(.)}</td>
          <td>{$holding("Ausleihhinweis!") :=  local:parse-column(.)}</td>
          <td></td>
        </t:siblings>
        {let $orderBtn := .//a[contains(@id, "BtnReserve")]
         return (
           $holding("orderable") := exists($orderBtn),
           $orderBtn ! (
           $holding("_orderTarget") := extract(@href, "&#39;([^&#39;]+)&#39;", 1),
           $holding("orderTitle") := $orderBtn,
           $book.orderable := false() (: when it can order a specific holding, it does not need to order all :)
           )
         ), $book.holdings[] := $holding
        }</tr>+
        <t:s>
        if (empty($book._orderTarget) and empty($book.holdings[.("orderable")])) then 
          let $globalOrderBtn := //a[contains(@id, 'BtnReserve')]
          where exists($globalOrderBtn)
          return (
            $book._orderTarget := translate($globalOrderBtn/@id, "_", "$"),
            $book.orderable := true()
          )
        else ()
        </t:s>
      </table>?
      
      <div t:condition="contains(@id, 'tpnlDetail') or contains(@ id, 'CatalogueDetailView')"><!-- class="DnnContainer">-->
       { for $span in .//span
         let $idlbl := $span/extract(@id, "_Lbl(.*)$", 1)[.]
         where exists($idlbl) and not(ends-with($idlbl, "Value"))
         let $primary-key := exists($search-reverse-keys($idlbl))
         let $key := if ($primary-key) then $search-reverse-keys($idlbl)
                     else $span || "!"
         let $value := join($span!following-sibling::node()!(
           if (contains-token(@class, "oclc-screen-reader-only")) then ()
           else if (self::a and not($primary-key)) then (. || (if (contains(@href, "http")) then x" ( {@href} )" else ""))
           else .
         ))
         where $value
         return $book($key) := $value
           
       }
      </div>
      
      {let $target := get("need-reserve-request-target",())[.]
       where exists($target)
       return $reserve-request := form((//form)[1], {"__EVENTTARGET":  $target, "": {"kind": "submit"}})}
      
    </body>
  </html>

  
  <table t:condition="contains(@id, 'GrdVolumes')">
  <td>
    <a>{$book._volumeFirst := resolve-uri(@href), i := 1, $book("Band 1!") := .}</a>
    <a>{$book(x"Band {$x := $x + 1}!") := .}</a>*
  </td>
  </table>
  
  <span t:condition="contains(@id, 'LblVolumes') and (matches(., '^(Volumes|Bände)$')) and empty(ancestor::tr[1]/following::tr[1]//table)"/> <!-- accept pages without volumes, but still try to raise error, if nothing is on the page-->
  
  <div class="dnnFormMessage">
    <span t:condition="ends-with(@id, 'LblInfoMessage')">{vl:raise(.)}</span>
  </div>
  
</t:switch>  