view software/eXist/webapp/mpdl/attribute-query-result.xql @ 17:7e883ce72fec

diverse Fehlerbehebungen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 27 Sep 2011 16:41:15 +0200
parents e99964f390e4
children
line wrap: on
line source

xquery version "1.0";

import module namespace functx = "http://www.functx.com" at "util/functx.xql";
import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "util/time.xql";
import module namespace mpdl-lucene = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/lucene/search" at "lucene/search.xql";

declare namespace request="http://exist-db.org/xquery/request";

declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/";
declare namespace TEI="http://www.tei-c.org/ns/1.0";

declare namespace dc="http://purl.org/dc/elements/1.1/";
declare namespace dct="http://purl.org/dc/terms/1.0/";
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";


let $queryType := request:get-parameter("query-type", "")
let $docbase := request:get-parameter("docbase", "")
let $attribute1 := request:get-parameter("attribute1", "")
let $relOp1 := request:get-parameter("relOp1", "")
let $attrQuery1 := request:get-parameter("attr-query1", "")
let $boolOp := request:get-parameter("boolOp", "")
let $attribute2 := request:get-parameter("attribute2", "")
let $relOp2 := request:get-parameter("relOp2", "")
let $attrQuery2 := request:get-parameter("attr-query2", "")
let $ftQuery := request:get-parameter("ft-query", "")
let $ftMorphQuery := request:get-parameter("ft-morph-query", "")
let $orderBy := request:get-parameter("order-by", "")
let $language := request:get-parameter("language", "")
let $pn := number(request:get-parameter("pn", ""))
let $reqPageSize := request:get-parameter("pageSize", "")
let $pageSize := 
  if ($reqPageSize = '' or $reqPageSize = '0')
  then 20
  else number($reqPageSize)

let $currentTimeBegin := util:system-time()

let $docPathStandard := "/db/mpdl/documents/standard"
let $docPathMorph := "/db/mpdl/documents/morph"
let $docPath := 
  if($queryType = 'fulltextMorph')
  then $docPathMorph
  else $docPathStandard

let $docBaseArch := "archimedes"
let $docBaseEcho := "echo"
let $docBaseTei := "tei"
let $docBaseDiverse := "diverse"
let $fulltextMorphArchDocPath := concat($docPathMorph, "/", $docBaseArch, "/", $language)
let $fulltextMorphEchoDocPath := concat($docPathMorph, "/", $docBaseEcho, "/", $language)
let $fulltextMorphTeiDocPath := concat($docPathMorph, "/", $docBaseTei, "/", $language)
let $fulltextMorphDiverseDocPath := concat($docPathMorph, "/", $docBaseDiverse, "/", $language)
let $fulltextMorphCollection := 
  if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei) and contains($docbase, $docBaseDiverse))
  then collection($fulltextMorphArchDocPath, $fulltextMorphEchoDocPath, $fulltextMorphTeiDocPath, $fulltextMorphDiverseDocPath)
  else if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei) and not(contains($docbase, $docBaseDiverse)))
  then collection($fulltextMorphArchDocPath, $fulltextMorphEchoDocPath, $fulltextMorphTeiDocPath)
  else if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)) and contains($docbase, $docBaseDiverse))
  then collection($fulltextMorphArchDocPath, $fulltextMorphEchoDocPath, $fulltextMorphDiverseDocPath)
  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei) and contains($docbase, $docBaseDiverse))
  then collection($fulltextMorphArchDocPath, $fulltextMorphTeiDocPath, $fulltextMorphDiverseDocPath)
  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei) and contains($docbase, $docBaseDiverse))
  then collection($fulltextMorphEchoDocPath, $fulltextMorphTeiDocPath, $fulltextMorphDiverseDocPath)
  else if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)) and not(contains($docbase, $docBaseDiverse)))
  then collection($fulltextMorphArchDocPath, $fulltextMorphEchoDocPath)
  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and not(contains($docbase, $docBaseTei)) and contains($docbase, $docBaseDiverse))
  then collection($fulltextMorphArchDocPath, $fulltextMorphDiverseDocPath)
  else if(not(contains($docbase, $docBaseArch)) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei) and contains($docbase, $docBaseDiverse))
  then collection($fulltextMorphTeiDocPath, $fulltextMorphDiverseDocPath)
  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)) and contains($docbase, $docBaseDiverse))
  then collection($fulltextMorphEchoDocPath, $fulltextMorphDiverseDocPath)
  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei) and not(contains($docbase, $docBaseDiverse)))
  then collection($fulltextMorphEchoDocPath, $fulltextMorphTeiDocPath)
  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei) and not(contains($docbase, $docBaseDiverse)))
  then collection($fulltextMorphArchDocPath, $fulltextMorphTeiDocPath)
  else if(not(contains($docbase, $docBaseArch)) and not(contains($docbase, $docBaseEcho)) and not(contains($docbase, $docBaseTei)) and contains($docbase, $docBaseDiverse))
  then collection($fulltextMorphDiverseDocPath)
  else if(not(contains($docbase, $docBaseArch)) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei) and not(contains($docbase, $docBaseDiverse)))
  then collection($fulltextMorphTeiDocPath)
  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)) and not(contains($docbase, $docBaseDiverse)))
  then collection($fulltextMorphEchoDocPath)
  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and not(contains($docbase, $docBaseTei)) and not(contains($docbase, $docBaseDiverse)))
  then collection($fulltextMorphArchDocPath)
  else ()

let $fulltextStandardArchDocPath := concat($docPathStandard, "/", $docBaseArch)
let $fulltextStandardEchoDocPath := concat($docPathStandard, "/", $docBaseEcho)
let $fulltextStandardTeiDocPath := concat($docPathStandard, "/", $docBaseTei)
let $fulltextStandardDiverseDocPath := concat($docPathStandard, "/", $docBaseDiverse)
let $fulltextStandardCollectionStr := 
  if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei) and contains($docbase, $docBaseDiverse))
  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardEchoDocPath, "', '", $fulltextStandardTeiDocPath, "', '", $fulltextStandardDiverseDocPath, "')")
  else if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei) and not(contains($docbase, $docBaseDiverse)))
  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardEchoDocPath, "', '", $fulltextStandardTeiDocPath, "')")
  else if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)) and contains($docbase, $docBaseDiverse))
  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardEchoDocPath, "', '", $fulltextStandardDiverseDocPath, "')")
  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei) and contains($docbase, $docBaseDiverse))
  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardTeiDocPath, "', '", $fulltextStandardDiverseDocPath, "')")
  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei) and contains($docbase, $docBaseDiverse))
  then concat("collection('", $fulltextStandardEchoDocPath, "', '", $fulltextStandardTeiDocPath, "', '", $fulltextStandardDiverseDocPath, "')")
  else if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)) and not(contains($docbase, $docBaseDiverse)))
  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardEchoDocPath, "')")
  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and not(contains($docbase, $docBaseTei)) and contains($docbase, $docBaseDiverse))
  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardDiverseDocPath, "')")
  else if(not(contains($docbase, $docBaseArch)) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei) and contains($docbase, $docBaseDiverse))
  then concat("collection('", $fulltextStandardTeiDocPath, "', '", $fulltextStandardDiverseDocPath, "')")
  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)) and contains($docbase, $docBaseDiverse))
  then concat("collection('", $fulltextStandardEchoDocPath, "', '", $fulltextStandardDiverseDocPath, "')")
  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei) and not(contains($docbase, $docBaseDiverse)))
  then concat("collection('", $fulltextStandardEchoDocPath, "', '", $fulltextStandardTeiDocPath, "')")
  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei) and not(contains($docbase, $docBaseDiverse)))
  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardTeiDocPath, "')")
  else if(not(contains($docbase, $docBaseArch)) and not(contains($docbase, $docBaseEcho)) and not(contains($docbase, $docBaseTei)) and contains($docbase, $docBaseDiverse))
  then concat("collection('", $fulltextStandardDiverseDocPath, "')")
  else if(not(contains($docbase, $docBaseArch)) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei) and not(contains($docbase, $docBaseDiverse)))
  then concat("collection('", $fulltextStandardTeiDocPath, "')")
  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)) and not(contains($docbase, $docBaseDiverse)))
  then concat("collection('", $fulltextStandardEchoDocPath, "')")
  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and not(contains($docbase, $docBaseTei)) and not(contains($docbase, $docBaseDiverse)))
  then concat("collection('", $fulltextStandardArchDocPath, "')")
  else ()
let $metadataStr := concat("(", $fulltextStandardCollectionStr, "/archimedes/info", "|" , $fulltextStandardCollectionStr, "/echo:echo/echo:metadata", "|" , $fulltextStandardCollectionStr, "/TEI:TEI/TEI:teiHeader", ")")
let $fulltextStandardCollection := 
  if($fulltextStandardCollectionStr != "")
  then util:eval($fulltextStandardCollectionStr)
  else ()

let $isAttributeSearch :=
  if ($queryType = "attribute")
  then true()
  else false()
let $isSimpleAttributeSearch :=
  if ($queryType = "attribute" and $attrQuery2 = "")
  then true()
  else false()
let $isBooleanAttributeSearch :=
  if ($queryType = "attribute" and $attrQuery2 != "")
  then true()
  else false()
let $errorAttributeSearch :=
  if ($docbase = "")
  then "No document check box is selected. Please select at least one of the document check boxes."
  else if ($queryType = "attribute" and $attrQuery1 = "" and $attrQuery2 != "")
  then "Your first attribute field is empty but your second not. Please use the first attribute field for a simple attribute query."
  else if ($queryType = "attribute" and $attrQuery1 = "" and $attrQuery2 = "")
  then "Your attribute fields are both empty. Please fill at least one attribute field."
  else if ($queryType = "fulltext" and $ftQuery = "")
  then "Your fulltext query field is empty. Please fill this field."
  else if ($queryType = "fulltextMorph" and $ftMorphQuery = "")
  then "Your fulltext query field is empty. Please fill this field."
  else ""

(:  TODO:  performance improvement: at this time the result is fully scanned 3 times (query, ordering, presentation)   :)
let $attrQueryResult := 
  if ($queryType = "browse" and $errorAttributeSearch = "")
  then $fulltextStandardCollection
  else if ($queryType = "fulltext" and $errorAttributeSearch = "")
  then mpdl-lucene:search($fulltextStandardCollection, $ftQuery)
  else if ($queryType = "fulltextMorph" and $errorAttributeSearch = "")
  then mpdl-lucene:search($fulltextMorphCollection, $ftMorphQuery)
  else if ($isAttributeSearch and $errorAttributeSearch = "")
  then mpdl-lucene:attrSearch($metadataStr, $attribute1, $attrQuery1, $boolOp, $attribute2, $attrQuery2)
  else ()
  
let $orderedAttrQueryResult := 
  if ($queryType = "fulltext" or $queryType = "fulltextMorph")
  then
  (for $attrElem in $attrQueryResult
   order by ft:score($attrElem) descending
   return $attrElem)
  else mpdl-lucene:order($attrQueryResult, $orderBy)

let $countResult := count($orderedAttrQueryResult)
let $countPagesTemp := $countResult idiv $pageSize + 1
let $countPages :=
  if((($countResult - 1) idiv $pageSize + 1) = ($countPagesTemp - 1))   
  then $countPagesTemp - 1   (: if countResult is exactly 10, 20, 30, ... then 1 has to be subtracted   :)
  else $countPagesTemp
let $pnLeftNumber :=
  if ($pn > 1)
  then $pn - 1
  else $pn
let $pnRightNumber :=
  if ($pn < $countPages)
  then $pn + 1
  else $pn
let $positionFrom := (($pn - 1) * $pageSize) + 1
let $positionTo := 
  if ($pn = $countPages)
  then $countResult
  else $pn * $pageSize

let $queryUrlPart :=
  if ($queryType = "fulltext")
  then concat("&amp;query-type=", $queryType, "&amp;query=", $ftQuery)
  else if ($queryType = "fulltextMorph")
  then concat("&amp;query-type=", $queryType, "&amp;query=", $ftMorphQuery)
  else ""

let $mode :=
  if ($queryType = "fulltext" or $queryType = "fulltextMorph")
  then "text"
  else "image"

let $pageResult := 
  for $elem at $pos in $orderedAttrQueryResult
    let $doc := $elem/fn:root()
    let $documentUriOrig := document-uri($doc)
    let $documentName := util:document-name($doc)
    let $documentCollection := replace(string($documentUriOrig), "(.+)/.+\..*", "$1")
    let $documentUri := substring-after($documentUriOrig, $docPath)
    let $documentUriWithoutExtension := substring-before($documentUri, ".")
    let $documentExtension := substring-after($documentUri, ".")
    let $documentUriHtml := 
      if ($documentExtension = "html")
      then concat($documentUriWithoutExtension, "-gen.html")
      else concat($documentUriWithoutExtension, ".html")
    (: let $lastModified := replace(substring-before(string(xmldb:last-modified($documentCollection, $documentName)), "."), "T", " ")  :)
    let $lastModified := substring-before(string(xmldb:last-modified($documentCollection, $documentName)), ".")
    let $docBase := substring-before(substring-after($documentUri, "/"), "/")
    let $metadata := mpdl-lucene:getMetadata($docBase, $doc)
    (: Performance: following is slow: why  (would be better structured code) ?
      let $attrAuthorStr := mpdl-lucene:getElemNameByAttr($docBase, "author")
      let $author := mpdl-lucene:getElemDynamic($metadataElem, $attrAuthorStr)
    :)    
    let $authorElems := mpdl-lucene:getElementsByAttr($metadata, $docBase, "author") 
    let $titleElems := mpdl-lucene:getElementsByAttr($metadata, $docBase, "title")
    let $placeElems := mpdl-lucene:getElementsByAttr($metadata, $docBase, "place")
    let $dateElems := mpdl-lucene:getElementsByAttr($metadata, $docBase, "date")
    let $langElems := mpdl-lucene:getElementsByAttr($metadata, $docBase, "language")
    let $authors := string-join($authorElems, ', ')
    let $titles := string-join($titleElems, ', ')
    let $places := string-join($placeElems, ', ')
    let $dates := string-join($dateElems, ', ')
    let $langs := string-join($langElems, ', ')
    let $resultElem := 
      <tr>
        <td valign="top" style="padding-left:5px;">{$pos}.</td>
        <td align="middle" valign="top" style="padding-left:7px;"><a href="interface/echo/echoDocuView.xql?document={$documentUri}"><img src="images/book.png" width="15" height="15" border="0"/></a> </td>
        <td align="middle" valign="top" style="padding-left:7px;"><a href="page-query-result.xql?document={$documentUri}&amp;mode={$mode}{$queryUrlPart}"><img src="images/book.png" width="15" height="15" border="0"/></a> </td>
        <td align="middle" valign="top"><a href="getDoc?doc={$documentUri}" target="_blank"><img src="images/download.png" width="15" height="15" border="0" alt="Download"/></a></td>
        <td align="middle" valign="top"><a href="getDoc?doc={$documentUriWithoutExtension}.pdf"><img src="images/download.png" width="15" height="15" border="0" alt="Download"/></a></td>
        <td align="middle" valign="top"><a href="getDoc?doc={$documentUriHtml}" target="_blank"><img src="images/download.png" width="15" height="15" border="0" alt="Download"/></a></td>
        <td valign="top" style="padding-left:5px;"><i>{$authors}</i></td>
        <td valign="top" style="padding-left:5px;">{$titles}</td>
        <td valign="top" style="padding-left:5px;">{$places}</td>
        <td valign="top" style="padding-left:5px;">{$dates}</td>
        <td valign="top" style="padding-left:5px;">{$documentName}</td>
        <td valign="top" style="padding-left:5px;">{$langs}</td>
        <td valign="top" style="padding-left:5px;">{$docBase}</td>
        <td valign="top" style="padding-left:5px;">{$lastModified}</td>
      </tr>
  where $pos >= $positionFrom and $pos <= $positionTo
  return $resultElem

let $docBases := string-join($docbase, ';')
let $title := 
  if ($queryType = "browse") 
  then concat("Result of your query: documentBases=", $docBases, ", browse all, orderBy=", $orderBy)
  else if ($queryType = "attribute" and $isSimpleAttributeSearch)
  then concat("Result of your query: documentBases=", $docBases, ', "', $attribute1, '"', " ", $relOp1, " ", '"', $attrQuery1, '"', ", orderBy=", '"', $orderBy, '"')
  else if ($queryType = "attribute" and $isBooleanAttributeSearch)
  then concat("Result of your query: documentBases=", $docBases, ', "', $attribute1, '"', " ", $relOp1, " ", '"', $attrQuery1, '"', $boolOp, '"', $attribute2, '"', " ", $relOp2, " ", '"', $attrQuery2, '"', ", orderBy=", '"', $orderBy, '"')
  else if ($queryType = "fulltext")
  then concat("Result of your fulltext query: documentBases=", $docBases, '"', $ftQuery, ', "', ", orderBy=", '"', "relevance", '"')
  else if ($queryType = "fulltextMorph")
  then concat("Result of your morphological fulltext query: documentBases=", $docBases, ', "', $ftMorphQuery, '"', ", language=", '"', $language, '"', ", orderBy=", '"', "relevance", '"')
  else ()

let $resultHeaderTable := 
      <table width="100%">
        <colgroup>
          <col width="85%"/>
          <col width="3%"/>
          <col width="3%"/>
          <col width="3%"/>
          <col width="3%"/>
        </colgroup>
        <tr>
        <td align="left">{$positionFrom} - {$positionTo} of {$countResult} documents</td>
        <form action="attribute-query-result.xql" method="get">
          <input type="hidden" name="docbase" value="{$docbase}"/>
          <input type="hidden" name="query-type" value="{$queryType}"/>
          <input type="hidden" name="attribute1" value="{$attribute1}"/>
          <input type="hidden" name="relOp1" value="{$relOp1}"/>
          <input type="hidden" name="attr-query1" value="{$attrQuery1}"/>
          <input type="hidden" name="boolOp" value="{$boolOp}"/>
          <input type="hidden" name="attribute2" value="{$attribute2}"/>
          <input type="hidden" name="relOp2" value="{$relOp2}"/>
          <input type="hidden" name="attr-query2" value="{$attrQuery2}"/>
          <input type="hidden" name="order-by" value="{$orderBy}"/>
          <input type="hidden" name="ft-query" value="{$ftQuery}"/>
          <input type="hidden" name="ft-morph-query" value="{$ftMorphQuery}"/>
          <input type="hidden" name="language" value="{$language}"/>
          <td><button id="buttonLeftNumber" name="pn" value="{$pnLeftNumber}" style="background:none;border:none;"><img src="images/left.gif"/></button></td>
          <td nowrap="true">{$pn} / {$countPages}</td>
          <td><button id="buttonRightNumber" name="pn" value="{$pnRightNumber}" style="background:none;border:none;"><img src="images/right.gif"/></button></td>
        </form>
        <form action="attribute-query-result.xql" method="get">
          <input type="hidden" name="docbase" value="{$docbase}"/>
          <input type="hidden" name="query-type" value="{$queryType}"/>
          <input type="hidden" name="attribute1" value="{$attribute1}"/>
          <input type="hidden" name="relOp1" value="{$relOp1}"/>
          <input type="hidden" name="attr-query1" value="{$attrQuery1}"/>
          <input type="hidden" name="boolOp" value="{$boolOp}"/>
          <input type="hidden" name="attribute2" value="{$attribute2}"/>
          <input type="hidden" name="relOp2" value="{$relOp2}"/>
          <input type="hidden" name="attr-query2" value="{$attrQuery2}"/>
          <input type="hidden" name="order-by" value="{$orderBy}"/>
          <input type="hidden" name="ft-query" value="{$ftQuery}"/>
          <input type="hidden" name="ft-morph-query" value="{$ftMorphQuery}"/>
          <input type="hidden" name="language" value="{$language}"/>
          <td nowrap="true">Page: <input type="text" size="3" name="pn" value="{$pn}"/></td>
        </form>
        </tr>
      </table>

let $attrQueryResultError := string($attrQueryResult/error)
let $resultHeader := 
  if ($attrQueryResultError = '' and $countResult > 0)
  then $resultHeaderTable
  else if ($attrQueryResultError != '')
  then (<b>Your query delivers an error: </b>, $attrQueryResultError)
  else if ($errorAttributeSearch != '')
  then (<b>Your query delivers an error: </b>, $errorAttributeSearch)
  else (<b>Your query delivers no result</b>)

let $resultPageBody := 
  if ($attrQueryResultError = '' and $countResult > 0)
  then 
    <form action="attribute-query-result.xql" method="get">
      <input type="hidden" name="docbase" value="{$docbase}"/>
      <input type="hidden" name="query-type" value="{$queryType}"/>
      <input type="hidden" name="attribute1" value="{$attribute1}"/>
      <input type="hidden" name="relOp1" value="{$relOp1}"/>
      <input type="hidden" name="attr-query1" value="{$attrQuery1}"/>
      <input type="hidden" name="boolOp" value="{$boolOp}"/>
      <input type="hidden" name="attribute2" value="{$attribute2}"/>
      <input type="hidden" name="relOp2" value="{$relOp2}"/>
      <input type="hidden" name="attr-query2" value="{$attrQuery2}"/>
      <input type="hidden" name="ft-query" value="{$ftQuery}"/>
      <input type="hidden" name="ft-morph-query" value="{$ftMorphQuery}"/>
      <input type="hidden" name="language" value="{$language}"/>
      <input type="hidden" name="pn" value="{$pn}"/>
    <table width="100%" border="2" rules="groups">
    <colgroup>
      <col width="2%"/>
      <col width="3%"/>
      <col width="3%"/>
      <col width="3%"/>
      <col width="3%"/>
      <col width="3%"/>
      <col width="15%"/>
      <col width="35%"/>
      <col width="5%"/>
      <col width="6%"/>
      <col width="6%"/>
      <col width="3%"/>
      <col width="3%"/>
      <col width="3%"/>
    </colgroup>
    <thead>
    <tr>
      <th align="left" valign="top">
        <button id="dummy" name="order-by" value="{$orderBy}" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">No.</button>
      </th>
      <th align="left" valign="top"><button id="dummy" name="order-by" value="{$orderBy}" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Full view</button></th>
      <th align="left" valign="top"><button id="dummy" name="order-by" value="{$orderBy}" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Lite view</button></th>
      <th align="left" valign="top"><button id="dummy" name="order-by" value="{$orderBy}" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Orig</button></th>
      <th align="left" valign="top"><button id="dummy" name="order-by" value="{$orderBy}" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Pdf</button></th>
      <th align="left" valign="top"><button id="dummy" name="order-by" value="{$orderBy}" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Html</button></th>
      <th align="left" valign="top">
        <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Author</button>
      </th>
      <th align="left" valign="top">
        <button name="order-by" value="title" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Title</button>
      </th>
      <th align="left" valign="top">
        <button name="order-by" value="place" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Place</button>
      </th>
      <th align="left" valign="top">
        <button name="order-by" value="date" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Year</button>
      </th>
      <th align="left" valign="top">
        <button name="order-by" value="document" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Document</button>
      </th>
      <th align="left" valign="top">
        <button name="order-by" value="language" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Language</button>
      </th>
      <th align="left" valign="top"><button id="dummy" name="order-by" value="{$orderBy}" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Schema</button></th>
      <th align="left" valign="top"><button id="dummy" name="order-by" value="{$orderBy}" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Last modified</button></th>
    </tr>
    </thead>
    <tbody>
    <tr/>
      {$pageResult}
    </tbody>
    </table>
    </form>
  else ()

let $currentTimeEnd := util:system-time()
let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin)

return
<html>
 <head>
  <title>{$title}</title>
 </head>
<body>
  <p style="font-weight:bold;font-size:20px">{$title}</p>
  {$resultHeader}
  {$resultPageBody}
  <p/>
Elapsed time: {$neededTime} ms, Back to <a href="query.xql">query page</a>, see the <a href="attribute-query-result.xql?_source=yes">XQuery source</a> of this page
  <p/>
</body>
</html>