comparison software/eXist/webapp/mpdl/page-query-result.xql @ 11:d6f528ad5d96

TEI Unterst?tzung, Fehlerbehebungen, externe Objekte
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Fri, 11 Mar 2011 13:34:02 +0100
parents 1ec29fdd0db8
children 469d927b9ca7
comparison
equal deleted inserted replaced
10:59ff47d1e237 11:d6f528ad5d96
11 declare namespace util = "http://exist-db.org/xquery/util"; 11 declare namespace util = "http://exist-db.org/xquery/util";
12 12
13 declare namespace dcterms="http://purl.org/dc/terms"; 13 declare namespace dcterms="http://purl.org/dc/terms";
14 declare namespace xhtml="http://www.w3.org/1999/xhtml"; 14 declare namespace xhtml="http://www.w3.org/1999/xhtml";
15 declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; 15 declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/";
16 declare namespace TEI="http://www.tei-c.org/ns/1.0";
16 17
17 let $mpdlDocUri := request:get-parameter("document", "") 18 let $mpdlDocUri := request:get-parameter("document", "")
18 let $queryType := request:get-parameter("query-type", "") 19 let $queryType := request:get-parameter("query-type", "")
19 let $mode := request:get-parameter("mode", "image") 20 let $mode := request:get-parameter("mode", "image")
20 let $reqPN := number(request:get-parameter("pn", "-1")) 21 let $reqPN := number(request:get-parameter("pn", "-1"))
52 let $metadata := 53 let $metadata :=
53 if ($docbase = 'archimedes') 54 if ($docbase = 'archimedes')
54 then $document/archimedes/info 55 then $document/archimedes/info
55 else if ($docbase = 'echo') 56 else if ($docbase = 'echo')
56 then $document/echo:echo/echo:metadata 57 then $document/echo:echo/echo:metadata
58 else if ($docbase = 'tei')
59 then $document/TEI:TEI/TEI:teiHeader
57 else '' 60 else ''
58 61
59 let $pageBreaks := 62 let $pageBreaks :=
60 if ($docbase = 'archimedes') 63 if ($docbase = 'archimedes')
61 then $document//pb 64 then $document//pb
62 else if ($docbase = 'echo') 65 else if ($docbase = 'echo')
63 then $document//echo:pb 66 then $document//echo:pb
67 else if ($docbase = 'tei')
68 then $document//TEI:pb
64 else $document//pb 69 else $document//pb
65 let $countPagesTemp := count($pageBreaks) 70 let $countPagesTemp := count($pageBreaks)
66 let $countPages := 71 let $countPages :=
67 if ($countPagesTemp > 0) 72 if ($countPagesTemp > 0)
68 then $countPagesTemp 73 then $countPagesTemp
69 else 1 74 else 1
70 75
71 (: xQuery inline execution does not work in module so it has to be done here :) 76 (: xQuery inline execution does not work in module so it has to be done here :)
72 let $xQueryPageSize := 100 77 let $xQueryPageSize := 1000
73 let $xQueryResultEval := 78 let $xQueryResultEval :=
74 if ($queryType = 'xpath' or $queryType = 'xquery' and $query != "") 79 if ($queryType = 'xpath' or $queryType = 'xquery' and $query != "")
75 then util:eval-inline($document, $query) 80 then util:eval-inline($document, $query)
76 else () 81 else ()
77 let $xQueryFrom := ($queryResultPN * $xQueryPageSize) - $xQueryPageSize + 1 82 let $xQueryFrom := ($queryResultPN * $xQueryPageSize) - $xQueryPageSize + 1
157 let $documentIdentifier := 162 let $documentIdentifier :=
158 if ($docbase = 'archimedes') 163 if ($docbase = 'archimedes')
159 then $metadata/locator 164 then $metadata/locator
160 else if ($docbase = 'echo') 165 else if ($docbase = 'echo')
161 then $metadata/dcterms:identifier 166 then $metadata/dcterms:identifier
167 else if ($docbase = 'tei')
168 then $metadata/TEI:fileDesc/TEI:publicationStmt/TEI:idno
162 else $metadata/dcterms:identifier 169 else $metadata/dcterms:identifier
163 let $echoDocIdentifier := 170 let $echoDocIdentifier :=
164 if ($documentIdentifier != '') 171 if ($documentIdentifier != '')
165 then substring-before(substring-after($documentIdentifier, "ECHO:"), ".") 172 then substring-before(substring-after($documentIdentifier, "ECHO:"), ".")
166 else '' 173 else ''
179 then $echoImageDir 186 then $echoImageDir
180 else if ($docbase = 'archimedes') 187 else if ($docbase = 'archimedes')
181 then concat("/permanent/archimedes/", $documentName) 188 then concat("/permanent/archimedes/", $documentName)
182 else if ($docbase = 'echo') 189 else if ($docbase = 'echo')
183 then concat("/permanent/library/", $echoDocIdentifier) 190 then concat("/permanent/library/", $echoDocIdentifier)
191 else if ($docbase = 'tei')
192 then $documentIdentifier
184 else '' 193 else ''
185 let $imagesDocDirectoryIndexMetaUrl := 194 let $imagesDocDirectoryIndexMetaUrl :=
186 if ($mode = "image" or $mode = "text" or $mode = "textPollux" or $mode = "gis") 195 if ($mode = "image" or $mode = "text" or $mode = "textPollux" or $mode = "gis")
187 then concat($nausikaaURLTexter, "?fn=", $imagesDocDirectory, "/index.meta") 196 then concat($nausikaaURLTexter, "?fn=", $imagesDocDirectory, "/index.meta")
188 else () 197 else ()
198 then $figuresImageDirectoryTemp 207 then $figuresImageDirectoryTemp
199 else concat(substring-before($pageImageDirectory, "pageimg"), "figures") 208 else concat(substring-before($pageImageDirectory, "pageimg"), "figures")
200 let $pageImageFileNameWithoutExtension := 209 let $pageImageFileNameWithoutExtension :=
201 if ($docbase = 'echo') 210 if ($docbase = 'echo')
202 then concat("/", string($pb1/@file)) 211 then concat("/", string($pb1/@file))
212 else if ($docbase = 'tei')
213 then concat("/", string($pb1/@facs))
203 else '' 214 else ''
204 let $imageFileName := 215 let $imageFileName :=
205 if ($reqPF = '') 216 if ($reqPF = '')
206 then concat($imagesDocDirectory, "/", $pageImageDirectory, $pageImageFileNameWithoutExtension) 217 then concat($imagesDocDirectory, "/", $pageImageDirectory, $pageImageFileNameWithoutExtension)
207 else $reqPF 218 else $reqPF
222 let $positionOfFirstFigureAfterPB1 := 233 let $positionOfFirstFigureAfterPB1 :=
223 if ($docbase = 'archimedes') 234 if ($docbase = 'archimedes')
224 then count($pb1/following::figure[1]/preceding::figure) + 1 235 then count($pb1/following::figure[1]/preceding::figure) + 1
225 else if ($docbase = 'echo') 236 else if ($docbase = 'echo')
226 then count($pb1/following::echo:figure[1]/preceding::echo:figure) + 1 237 then count($pb1/following::echo:figure[1]/preceding::echo:figure) + 1
238 else if ($docbase = 'tei')
239 then count($pb1/following::TEI:figure[1]/preceding::TEI:figure) + 1
227 else () 240 else ()
228 241
229 let $pageFragmentTmp := 242 let $pageFragmentTmp :=
230 if ($mode = "image" or $errorCode > 9) 243 if ($mode = "image" or $errorCode > 9)
231 then () 244 then ()
409 let $titleStr := concat(string-join($authors, ', '), ". ", string-join($titles, ', '), ". ", string-join($places, ', '), " ", $date, ".") 422 let $titleStr := concat(string-join($authors, ', '), ". ", string-join($titles, ', '), ". ", string-join($places, ', '), " ", $date, ".")
410 let $tmpResult := 423 let $tmpResult :=
411 if ($errorCode < 10 and $reqExport = "pdf") 424 if ($errorCode < 10 and $reqExport = "pdf")
412 then mpdl-text:html2pdf($language, $xmlResult, $xslFilePath, $titleStr, $pn, $mode) 425 then mpdl-text:html2pdf($language, $xmlResult, $xslFilePath, $titleStr, $pn, $mode)
413 else if ($errorCode < 10 and not($reqExport = "pdf")) 426 else if ($errorCode < 10 and not($reqExport = "pdf"))
414 then mpdl-text:transform($xmlResult, $xslFilePath) 427 then mpdl-text:transform($xmlResult, $xslFilePath)
415 else 428 else
416 <div>{$xmlResult}</div> (: error xml result :) 429 <div>{$xmlResult}</div> (: error xml result :)
417 let $result := 430 let $result :=
418 if ($errorCode < 10 and $reqExport = "pdf") 431 if ($errorCode < 10 and $reqExport = "pdf")
419 then response:stream-binary($tmpResult, "application/pdf", concat($documentName, "-page", $pn, ".pdf")) 432 then response:stream-binary($tmpResult, "application/pdf", concat($documentName, "-page", $pn, ".pdf"))