# HG changeset patch # User Josef Willenborg # Date 1297174606 -3600 # Node ID 5589d865af7abdbaf38ee213b3150914e111deb6 # Parent 2396a569e446d14e378c1a6540df70d45b87e262 Erstellung XQL/XSL Applikation diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/futureDev/archimedes-xml-fragment-Highlight-WordAtBeginningOfText.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/futureDev/archimedes-xml-fragment-Highlight-WordAtBeginningOfText.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,265 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + . + . + , + + +

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ [Text] + [Image] + [XML] + + + + + page-down + + + page-down + + + + / + + + + page-up + + + page-down + + + + + Page: + + + + +
+
+ + + + + + + + + + + +
+ + + + + Hits: "" +
    + +
  1. + + + Page , Sentence +
  2. +
    +
+
+
+ Elapsed time: ms, Back to query page, see the XQuery source and XSL source of this page +
+ [fast mechanism (file system search)] [slower mechanism (XQL search)] +
+ +
+ + + + + + + + + + + <> + + </> +
+
+ + + + = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/futureDev/fulltext-query-result-detail.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/futureDev/fulltext-query-result-detail.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,234 @@ +xquery version "1.0"; + +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace string-util = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/string-util"; +declare namespace time-util = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/time-util"; + +declare function time-util:duration-as-ms($t) { + round((minutes-from-duration($t) * 60 + seconds-from-duration($t)) * 1000 ) +}; + +declare function string-util:getWords($strInput as xs:string?) as xs:string* { + let $wordDelim := "[,;.\s]+" + (: let $words := fn:tokenize($strInput, $wordDelim, "i") :) + let $words := mpdltext:getWords($strInput, $wordDelim, "i") + let $distinctWords := fn:distinct-values($words) + return $distinctWords +}; + +declare function string-util:putCommaBetween($elems as element()*) as element()* { + let $count := count($elems) + for $elem at $pos in $elems + let $ret := if ($pos < $count and not(empty($elem/text()))) then + {$elem}, + else + $elem + return $ret +}; + +declare function string-util:getSortedLinkedWords($words as xs:string*, $language as xs:string) as element()* { + let $count := count($words) + let $dictURLPart1 := "http://archimedes.mpiwg-berlin.mpg.de/cgi-bin/toc/dict?step=table;word=" + for $word in $words + let $lowerCaseWord := fn:lower-case($word) + let $wordLength := string-length($lowerCaseWord) + let $linkedWord := {$lowerCaseWord} + let $ret := if ($wordLength > 0) then + $linkedWord + else + + order by $lowerCaseWord + return $ret +}; + +declare function string-util:toSortedLinkedWords($strInput as xs:string?, $language as xs:string?) as element()* { + let $words := string-util:getWords($strInput) + let $wordsWithLinks := string-util:getSortedLinkedWords($words, $language) + let $commaSep := string-util:putCommaBetween($wordsWithLinks) + return $commaSep +}; + +declare function string-util:getDummyDocument() as node() { + let $bla := + document { + element product { + attribute dept { "ACC" }, + element number { 563 }, + element name { attribute language {"en"}, "Floppy Sun Hat"} + }, + element product { + attribute dept { "BCC" }, + element number { 564 }, + element name { attribute language {"en"}, "Floppy SBun Iat"} + } + } + return $bla +}; + +let $currentTimeBegin := util:system-time() +let $lang := request:get-parameter("lang", "0") +let $language := request:get-parameter("language", "fr") +let $document := request:get-parameter("document", "") + +let $tempArchimedesDocPath := + if ($lang = "0") + then "/db/archimedes" + else concat("/db/arch/", $language) + +let $archimedesDocPath := + if ($document = "") + then $tempArchimedesDocPath + else concat($tempArchimedesDocPath, "/", $document, ".xml") + +let $archCollection := + if ($document = "") + then collection($archimedesDocPath) + else doc($archimedesDocPath) + +let $lucene-query := + if ($lang = "0") + then request:get-parameter("ft-query", "Illuſtriſsimi") + else request:get-parameter("ft-lang-query", "Illuſtriſsimi") + +let $tempResultElems := + for $s at $pos in $archCollection//s[ft:query(., $lucene-query)] + let $documentName := util:document-name($s) + let $collectionName := util:collection-name($s) + let $fullDocName := concat($collectionName, "/", $documentName) + let $docRoot := doc($fullDocName) + let $sArchInfo := $s/root()/archimedes/info let $author := string($sArchInfo/author/text()) + let $language := string($sArchInfo/lang/text()) + let $dictLinks := string-util:toSortedLinkedWords($s, $language) + let $pnOfS := count($docRoot//pb[. << $s]) (: faster: comparision only in pb elements of this document :) + (: let $pnOfS := count($s/preceding::pb[util:document-name(root()) = $documentName]) too slow: comparision in pb elements of all found documents :) + let $posOfS := count($docRoot//pb[$pnOfS]/following::s[. << $s]) + 1 (: faster: comparision only in s elements of this document :) + let $resultElem := + + {$pos} + {$fullDocName} + {$pnOfS} + {$posOfS} + {$s} + {$dictLinks} + + order by $author, $pos + return $resultElem + +(: group by operator: group documents with their hits :) +let $resultElems := + for $full-doc at $docPos in distinct-values($tempResultElems/full-doc) + let $docName := substring-before(util:document-name($full-doc), ".") + let $docPath := doc($full-doc) + let $sArchInfo := $docPath/archimedes/info let $author := string($sArchInfo/author/text()) + let $authorLit := concat($author, ". ") + let $title := string($sArchInfo/title/text()) + let $titleLit := if ($title = "") then "" else concat($title, ". ") + let $place := string($sArchInfo/place/text()) + let $date := string($sArchInfo/date/text()) + let $placeDateLit := if ($place = "" and $date = "") then "" else if ($place != "" and $date = "") then concat($place, ". ") else if ($place = "" and $date != "") then concat($date, ". ") else concat($place, ", ", $date, ". ") + let $docShortDesc := ($authorLit, $titleLit, $placeDateLit, " [", XML content, "]") + let $sInDocElem := $tempResultElems[full-doc = $full-doc] + let $docElem := + for $e at $pos in $sInDocElem + let $pnOfS := $e/pn + let $posOfS := $e/pos-of-s + order by $pos + return + + {$pos} + {$pnOfS} + {$posOfS} + {$e/s} + {$e/links} + + return + + {$docPos} + {$docName} + {$docShortDesc} + + {$docElem} + + + +let $countElems := count($tempResultElems) +let $countPages := $countElems idiv 10 + 1 + +let $pn := fn:number(request:get-parameter("pn", "1")) +let $positionFrom := xs:integer((($pn - 1) * 10) + 1) +let $positionTo := + if ($pn = $countPages) + then $countElems + else $pn * 10 + +let $pagesURLs := + if ($lang = "0") + then concat("?ft-query=", $lucene-query) + else concat("?ft-lang-query=", $lucene-query, "&lang=1&language=", $language) + +let $countPagesURLs := + for $i in (1 to $countPages) + let $pageURL := + if ($i = $pn) + then ($i, " ") + else ({$i}, " ") + return $pageURL + +(: let $pageHits := subsequence($resultElems/hits/hit, $positionFrom, $positionTo) does not work correctly !!! :) +let $pageHits := $resultElems/hits/hit (: fetch all hit elements :) +let $pageResult := + for $hit at $pos in $pageHits + let $hitFatherDoc := $hit/../.. + let $countHitsFatherDoc := count($hit/../hit) + let $hitPos := xs:integer($hit/pos) + let $pnOfS := xs:integer($hit/pn) + let $posOfS := xs:integer($hit/pos-of-s) + let $docName := $hitFatherDoc/name + let $linkPageQuery := (Page {$pnOfS}) + let $hitFatherPos := xs:integer($hitFatherDoc/pos) + let $hitInnerLI := +
  • + {$linkPageQuery}, Sentence: {$posOfS}

    + Sentence: {data($hit/s)}

    + Dictionary links: {$hit/links}

    +
  • + let $hitLI := + if ($countHitsFatherDoc = 1) (: if only one hit for the document exist then an ul element is used else an ol element :) + then + + else +
      + {$hitInnerLI} +
    + let $hitLiFatherLI := + if ($hitPos = 1) + then +
  • {$hitFatherDoc/desc} + {$hitLI} +
  • + else $hitLI + where $pos >= $positionFrom and $pos <= $positionTo + return $hitLiFatherLI + +let $currentTimeEnd := util:system-time() +let $neededTime := time-util:duration-as-ms($currentTimeEnd - $currentTimeBegin) + + +return + + + Result for your query: "{$lucene-query}" + + +

    Result of query: "{$lucene-query}"

    +{$positionFrom}-{$positionTo} of {$countElems} results. Page: {$countPagesURLs} +
      +{$pageResult} +
    +
    +

    +Elapsed time: {$neededTime} ms, Back to query page, see the XQuery source of this page + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/futureDev/fulltext-query-result-in-one-doc.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/futureDev/fulltext-query-result-in-one-doc.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,168 @@ +xquery version "1.0"; + +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace string-util = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/string-util"; +declare namespace time-util = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/time-util"; + +declare function time-util:duration-as-ms($t) { + round((minutes-from-duration($t) * 60 + seconds-from-duration($t)) * 1000 ) +}; + +declare function string-util:getWords($strInput as xs:string?) as xs:string* { + let $wordDelim := "[,;.\s]+" + (: let $words := fn:tokenize($strInput, $wordDelim, "i") :) + let $words := mpdltext:getWords($strInput, $wordDelim, "i") + let $distinctWords := fn:distinct-values($words) + return $distinctWords +}; + +declare function string-util:putCommaBetween($elems as element()*) as element()* { + let $count := count($elems) + for $elem at $pos in $elems + let $ret := if ($pos < $count and not(empty($elem/text()))) then + {$elem}, + else + $elem + return $ret +}; + +declare function string-util:getSortedLinkedWords($words as xs:string*, $language as xs:string) as element()* { + let $count := count($words) + let $dictURLPart1 := "http://archimedes.mpiwg-berlin.mpg.de/cgi-bin/toc/dict?step=table;word=" + for $word in $words + let $lowerCaseWord := fn:lower-case($word) + let $wordLength := string-length($lowerCaseWord) + let $linkedWord := {$lowerCaseWord} + let $ret := if ($wordLength > 0) then + $linkedWord + else + + order by $lowerCaseWord + return $ret +}; + +declare function string-util:toSortedLinkedWords($strInput as xs:string?, $language as xs:string?) as element()* { + let $words := string-util:getWords($strInput) + let $wordsWithLinks := string-util:getSortedLinkedWords($words, $language) + let $commaSep := string-util:putCommaBetween($wordsWithLinks) + return $commaSep +}; + +declare function string-util:getDummyDocument() as node() { + let $bla := + document { + element product { + attribute dept { "ACC" }, + element number { 563 }, + element name { attribute language {"en"}, "Floppy Sun Hat"} + }, + element product { + attribute dept { "BCC" }, + element number { 564 }, + element name { attribute language {"en"}, "Floppy SBun Iat"} + } + } + return $bla +}; + +let $currentTimeBegin := util:system-time() +let $lang := request:get-parameter("lang", "0") +let $language := request:get-parameter("language", "fr") +let $document := request:get-parameter("document", "alber_archi_003_en_1755") + +let $tempArchimedesDocPath := + if ($lang = "0") + then "/db/archimedes" + else concat("/db/arch/", $language) +let $archimedesDocPath := concat($tempArchimedesDocPath, "/", $document, ".xml") +let $archDoc := doc($archimedesDocPath) + +let $lucene-query := + if ($lang = "0") + then request:get-parameter("ft-query", "Illuſtriſsimi") + else request:get-parameter("ft-lang-query", "Illuſtriſsimi") + +let $resultElems := + for $s at $pos in $archDoc//s[ft:query(., $lucene-query)] + let $documentName := util:document-name($s) + let $collectionName := util:collection-name($s) + let $fullDocName := concat($collectionName, "/", $documentName) + let $docRoot := doc($fullDocName) + let $sArchInfo := $s/root()/archimedes/info let $author := string($sArchInfo/author/text()) + let $language := string($sArchInfo/lang/text()) + let $dictLinks := string-util:toSortedLinkedWords($s, $language) + let $pnOfS := count($docRoot//pb[. << $s]) (: faster: comparision only in pb elements of this document :) + (: let $pnOfS := count($s/preceding::pb[util:document-name(root()) = $documentName]) too slow: comparision in pb elements of all found documents :) + let $posOfS := count($docRoot//pb[$pnOfS]/following::s[. << $s]) + 1 (: faster: comparision only in s elements of this document :) + let $resultElem := + + {$pos} + {$fullDocName} + {$documentName} + {$pnOfS} + {$posOfS} + {$s} + {$dictLinks} + + order by $author, $pos + return $resultElem + +let $countElems := count($resultElems) +let $countPages := $countElems idiv 10 + 1 + +let $pn := fn:number(request:get-parameter("pn", "1")) +let $positionFrom := xs:integer((($pn - 1) * 10) + 1) +let $positionTo := + if ($pn = $countPages) + then $countElems + else $pn * 10 + +let $pagesURLs := + if ($lang = "0") + then concat("?ft-query=", $lucene-query) + else concat("?ft-lang-query=", $lucene-query, "&lang=1&language=", $language) + +let $countPagesURLs := + for $i in (1 to $countPages) + let $pageURL := + if ($i = $pn) + then ($i, " ") + else ({$i}, " ") + return $pageURL + +let $pageResult := + for $elem at $pos in $resultElems + let $hitPos := xs:integer($elem/pos) + let $pnOfS := xs:integer($elem/pn) + let $posOfS := xs:integer($elem/pos-of-s) + let $docName := $elem/name + let $linkPageQuery := (Page {$pnOfS}) + let $hitLI := +
  • + {$linkPageQuery}, Sentence: {$posOfS}

    + Sentence: {$elem/s/text()}

    + Dictionary links: {$elem/links}

    +
  • + where $pos >= $positionFrom and $pos <= $positionTo + return $hitLI + +let $currentTimeEnd := util:system-time() +let $neededTime := time-util:duration-as-ms($currentTimeEnd - $currentTimeBegin) + + +return + + + Result for your query: "{$lucene-query}" + + +

    Result of query: "{$lucene-query}"

    +{$positionFrom}-{$positionTo} of {$countElems} results. Page: {$countPagesURLs} +
      +{$pageResult} +
    +
    +

    +Elapsed time: {$neededTime} ms, Back to query page, see the XQuery source of this page + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/futureDev/highlight-matches-test.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/futureDev/highlight-matches-test.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,21 @@ +xquery version "1.0"; + +declare namespace xlink = "http://www.w3.org/1999/xlink"; +declare namespace docc = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/docc"; + +declare function docc:tagmatch($term as xs:string, $node as text(), $args as item()+) as element() { + {$term} +}; + +(: was originally in page-query-result.xql, does not work because match-any does not deliver results because fragment is not in fulltext index :) + +let $retPageFragment := + if ($mode = "image") + then () + else doc:getFragmentBetween($docPath, "pb", $pn, $pn + 1) + +let $returnPageFragmentTemp := util:parse($retPageFragment) (: string2xml: returns a valid xml document for that string :) + +let $hitTemp := $returnPageFragmentTemp[match-any(.,"di")] +let $callback := util:function(QName("http://www.mpiwg-berlin.mpg.de/ns/mpdl/docc", "docc:tagmatch"), 3) +let $returnPageFragment := text:highlight-matches($hitTemp, $callback, ()) diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/futureDev/html2fop.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/futureDev/html2fop.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,1727 @@ + + + + + + + + + + + + + + +<!DOCTYPE fo:root [ + <!ENTITY tilde "&#126;"> + <!ENTITY florin "&#131;"> + <!ENTITY elip "&#133;"> + <!ENTITY dag "&#134;"> + <!ENTITY ddag "&#135;"> + <!ENTITY cflex "&#136;"> + <!ENTITY permil "&#137;"> + <!ENTITY uscore "&#138;"> + <!ENTITY OElig "&#140;"> + <!ENTITY lsquo "&#145;"> + <!ENTITY rsquo "&#146;"> + <!ENTITY ldquo "&#147;"> + <!ENTITY rdquo "&#148;"> + <!ENTITY bullet "&#149;"> + <!ENTITY endash "&#150;"> + <!ENTITY emdash "&#151;"> + <!ENTITY trade "&#153;"> + <!ENTITY oelig "&#156;"> + <!ENTITY Yuml "&#159;"> + + <!ENTITY nbsp "&#160;"> + <!ENTITY iexcl "&#161;"> + <!ENTITY cent "&#162;"> + <!ENTITY pound "&#163;"> + <!ENTITY curren "&#164;"> + <!ENTITY yen "&#165;"> + <!ENTITY brvbar "&#166;"> + <!ENTITY sect "&#167;"> + <!ENTITY uml "&#168;"> + <!ENTITY copy "&#169;"> + <!ENTITY ordf "&#170;"> + <!ENTITY laquo "&#171;"> + <!ENTITY not "&#172;"> + <!ENTITY shy "&#173;"> + <!ENTITY reg "&#174;"> + <!ENTITY macr "&#175;"> + <!ENTITY deg "&#176;"> + <!ENTITY plusmn "&#177;"> + <!ENTITY sup2 "&#178;"> + <!ENTITY sup3 "&#179;"> + <!ENTITY acute "&#180;"> + <!ENTITY micro "&#181;"> + <!ENTITY para "&#182;"> + <!ENTITY middot "&#183;"> + <!ENTITY cedil "&#184;"> + <!ENTITY sup1 "&#185;"> + <!ENTITY ordm "&#186;"> + <!ENTITY raquo "&#187;"> + <!ENTITY frac14 "&#188;"> + <!ENTITY frac12 "&#189;"> + <!ENTITY frac34 "&#190;"> + <!ENTITY iquest "&#191;"> + <!ENTITY Agrave "&#192;"> + <!ENTITY Aacute "&#193;"> + <!ENTITY Acirc "&#194;"> + <!ENTITY Atilde "&#195;"> + <!ENTITY Auml "&#196;"> + <!ENTITY Aring "&#197;"> + <!ENTITY AElig "&#198;"> + <!ENTITY Ccedil "&#199;"> + <!ENTITY Egrave "&#200;"> + <!ENTITY Eacute "&#201;"> + <!ENTITY Ecirc "&#202;"> + <!ENTITY Euml "&#203;"> + <!ENTITY Igrave "&#204;"> + <!ENTITY Iacute "&#205;"> + <!ENTITY Icirc "&#206;"> + <!ENTITY Iuml "&#207;"> + <!ENTITY ETH "&#208;"> + <!ENTITY Ntilde "&#209;"> + <!ENTITY Ograve "&#210;"> + <!ENTITY Oacute "&#211;"> + <!ENTITY Ocirc "&#212;"> + <!ENTITY Otilde "&#213;"> + <!ENTITY Ouml "&#214;"> + <!ENTITY times "&#215;"> + <!ENTITY Oslash "&#216;"> + <!ENTITY Ugrave "&#217;"> + <!ENTITY Uacute "&#218;"> + <!ENTITY Ucirc "&#219;"> + <!ENTITY Uuml "&#220;"> + <!ENTITY Yacute "&#221;"> + <!ENTITY THORN "&#222;"> + <!ENTITY szlig "&#223;"> + <!ENTITY agrave "&#224;"> + <!ENTITY aacute "&#225;"> + <!ENTITY acirc "&#226;"> + <!ENTITY atilde "&#227;"> + <!ENTITY auml "&#228;"> + <!ENTITY aring "&#229;"> + <!ENTITY aelig "&#230;"> + <!ENTITY ccedil "&#231;"> + <!ENTITY egrave "&#232;"> + <!ENTITY eacute "&#233;"> + <!ENTITY ecirc "&#234;"> + <!ENTITY euml "&#235;"> + <!ENTITY igrave "&#236;"> + <!ENTITY iacute "&#237;"> + <!ENTITY icirc "&#238;"> + <!ENTITY iuml "&#239;"> + <!ENTITY eth "&#240;"> + <!ENTITY ntilde "&#241;"> + <!ENTITY ograve "&#242;"> + <!ENTITY oacute "&#243;"> + <!ENTITY ocirc "&#244;"> + <!ENTITY otilde "&#245;"> + <!ENTITY ouml "&#246;"> + <!ENTITY oslash "&#248;"> + <!ENTITY ugrave "&#249;"> + <!ENTITY uacute "&#250;"> + <!ENTITY ucirc "&#251;"> + <!ENTITY uuml "&#252;"> + <!ENTITY yacute "&#253;"> + <!ENTITY thorn "&#254;"> + <!ENTITY yuml "&#255;"> +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + developerWorks loves you! + + + + + ibm.com/developerWorks + + + + + + + + + + + + + + + + + + + + + Page + of + + + + + + + + + + + + + + + + + + ibm.com/developerWorks + + + + + developerWorks loves you! + + + + + + + + + + + + + + + + Page + + of + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + on page + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + developerWorks loves you! + + + ibm.com/developerWorks + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3pt + + + 12pt + + + + + + + + + + + + + + + + + + + + + + + + + black + + + + + + + + + + sans-serif + + + + + + + + + @size + + + 110% + + + 120% + + + 130% + + + 140% + + + 150% + + + 175% + + + 200% + + + 90% + + + 80% + + + 70% + + + 60% + + + 50% + + + 40% + + + 30% + + + 8pt + + + 10pt + + + 12pt + + + 14pt + + + 18pt + + + 24pt + + + 36pt + + + 12pt + + + + + 12pt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0pt + + + 12pt + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + solid + + + black + + + 1pt + + + + + + + + center + + + end + + + justify + + + start + + + + + + + center + + + end + + + justify + + + start + + + + + center + + + + + center + + + end + + + justify + + + start + + + + + start + + + + + + + + + + + + + + + + + + + + + + solid + + + black + + + 1pt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0pt + + + 12pt + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Table of Contents + + + If you're viewing this document online, you can + click any of the topics below to link directly to + that section. + + + + + + + 1cm + + + 1.5cm + + + 2cm + + + 2.5cm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Table of Contents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/futureDev/rest-doc-operation.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/futureDev/rest-doc-operation.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,67 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../util/time.xql"; + +declare namespace file = "http://exist-db.org/xquery/file"; +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace session="http://exist-db.org/xquery/session"; +declare namespace util = "http://exist-db.org/xquery/util"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; + +let $login := xmldb:authenticate("xmldb:exist:///db", "admin", "") + +let $operation := request:get-parameter("operation", "") +let $docBase := request:get-parameter("docBase", "") +let $language := request:get-parameter("language", "") +let $fileName := request:get-parameter("fileName", "") + +let $eSciDocCookieId := request:get-cookie-value("escidocCookie") + +let $srcLocalFileName := request:get-uploaded-file-name("srcLocalFileName") +let $srcExistUploadFileJavaObject := request:get-uploaded-file("srcLocalFileName") +let $srcExistUploadFileName := string({$srcExistUploadFileJavaObject}) +let $srcExistUploadFileUrl := concat("file://", $srcExistUploadFileName) + +let $reqSrcUrl := request:get-parameter("srcUrl", "") +let $srcUrl := + if ($reqSrcUrl = '') + then $srcExistUploadFileUrl + else $reqSrcUrl + +let $error := + if ($eSciDocCookieId = '' or empty($eSciDocCookieId)) + then No login context available. Please login before you do an operation + else if(($operation = 'updateExist') and ($srcUrl = '')) + then "please specify your source" + else if(($operation = 'updateExist' or $operation = 'delete') and ($fileName = '')) + then "please specify your destination document name" + else "no" + +let $jobId := + if($error = 'no' and $operation = 'updateExist') + then mpdldoc:do($operation, $srcUrl, $srcLocalFileName, $docBase, $language, $fileName, $eSciDocCookieId) + else if($error = 'no' and $operation = 'deleteExist') + then mpdldoc:do($operation, 'empty', 'empty', $docBase, $language, $fileName, $eSciDocCookieId) + else () +let $redirectUrl := here +let $resultHtml := + if ($error = 'no') + then
    See the status of your document operation {$redirectUrl}
    + else
    Error in your document operation: {$error}
    + +let $title := "MPDL: eXist document management" +return + + +{$title} + + +

    {$title}

    + {$resultHtml} +
    +
    {$eSciDocCookieId} +
    +
    + Back to document operation page, see the XQuery source of this page, if you find a bug let us know + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/archimedes-image-fragment.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/archimedes-image-fragment.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,122 @@ + + + + + + + + +

    + + . + . + , + + +

    +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + +
    + [Text] + [Image] + [XML] + + + + + page-down + + + page-down + + + + / + + + + page-up + + + page-down + + + + + Page: + +
    +
    + + + + + + + + + + + + + + +
    + + Page image: {$number} + + Hits: "" +
      + +
    1. + + + Page , Sentence +
    2. +
      +
    +
    +
    +
    + + Elapsed time: ms, Back to query page, see the XQuery source and XSL source of this page + + +
    + +
    \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/archimedes-text-fragment.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/archimedes-text-fragment.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    + + . + . + , + + +

    +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + + +
    + [Text] + [Image] + [XML] + + + + + page-down + + + page-down + + + + / + + + + page-up + + + page-down + + + + + Page: + + + + +
    +
    + + + + + + + + + + + +
    + + + + + Hits: "" +
      + +
    1. + + + Page , Sentence +
    2. +
      +
    +
    +
    + Elapsed time: ms, Back to query page, see the XQuery source and XSL source of this page +
    + [fast mechanism (file system search)] [slower mechanism (XQL search)] +
    + +
    + + +

    +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + +

    + figure: {$figureId} +

    + Figure: +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/archimedes-xml-fragment.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/archimedes-xml-fragment.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,311 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... ... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    + + . + . + , + + +

    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + [Text] + [Image] + [XML] + + + + + page-down + + + page-down + + + + / + + + + page-up + + + page-down + + + + + Page: + + + + +
    +
    + + + + + + + + + + + +
    + + + + + Hits: "" +
      + +
    1. + + + Page , Sentence :

      + + + +
    2. +
      +
    +
    +
    + Elapsed time: ms, Back to query page, see the XQuery source and XSL source of this page +
    + [fast mechanism (file system search)] [slower mechanism (XQL search)] +
    + +
    + + + + + + + + + + + <> + + </> +
    +
    + + + + = + + + + + + + + + + + + + + + +
    diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/book-pointer.gif Binary file software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/book-pointer.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/image.jpg Binary file software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/image.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/imageU.jpg Binary file software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/imageU.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/left.gif Binary file software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/left.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/right.gif Binary file software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/right.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/text.jpg Binary file software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/text.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/textU.jpg Binary file software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/textU.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/xml.jpg Binary file software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/xml.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/xmlU.jpg Binary file software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/images/xmlU.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/lucene/search.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/lucene/search.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,40 @@ +xquery version "1.0"; + +module namespace mpdl-lucene = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/lucene/search"; + +declare namespace ft = "http://exist-db.org/xquery/lucene"; + +declare function mpdl-lucene:search($docPath, $ftQuery) as node() { + let $document := doc($docPath) + (: performance reasons: all hits (not only the first 10! ) are passed through the :) + (: for loop: so the overhead in each loop has to be minimized :) + let $t := $document//s[ft:query(., $ftQuery)] + let $tempQueryResult := + for $ss at $poss in $t + (: where $poss > 100 and $poss <= 200 :) + return $ss + let $queryResult := + for $s at $pos in $tempQueryResult + let $pnOfS := count($document//pb[. << $s]) (: faster: comparison only in pb elements of this document :) + let $posOfS := count($document//pb[$pnOfS]/following::s[. << $s]) + 1 (: faster: comparisonon only in s elements of this document :) + let $resultElem := + + {$pos} + {$pnOfS} + {$posOfS} + {$s} + + return $resultElem + let $resultSize := count($queryResult) + let $result := + + {$ftQuery} + + {$resultSize} + + {$queryResult} + + + + return $result +}; \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/monte-page1.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/monte-page1.xml Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,94 @@ + + + + monte_mecha_037_it_1581 + Monte, Guidobaldo del + Le Mechaniche + 1581 + Venezia + Pigafetta, Filippo + it + monte_mecha_037_it_1581.xml + 2643.17 + 037.xml + 270 + 112 + + + 1 + http://nausikaa2.rz-berlin.mpg.de/digitallibrary/digilib.jsp?fn=/permanent/archimedes/monte_mecha_037_it_1581/037-01-pageimg&pn=1 + http://echo.mpiwg-berlin.mpg.de/zogilib?fn=/permanent/archimedes/monte_mecha_037_it_1581/037-01-pageimg&pn=1 + http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=/permanent/archimedes/monte_mecha_037_it_1581/037-01-pageimg&pn=1 + ?document=monte_mecha_037_it_1581&pn=1&mode=xml + 1 + + +

    LE + MECHANICHE + DELL'ILLVSTRISS SIG. + GVIDO VBALDO + DE' MARCHESI DEL + MONTE: + + TRADOTTE IN VOLGARE + DAL SIG. FILIPPO PIGAFETTA: + Nellequali ſi contiene la vera Dottrina di tutti gli Iſtrumenti + principali da mouer peſi grandisſimi con + picciola forza. + + + A beneficio di chi ſi diletta di queſta nobiliſſima scienza; & maſſimamente + di Capitani di guerra, Ingegnieri, Architetti, & d'ogni + Artefice, che intenda per via di Machine + far opre marauiglioſe, e quaſi + ſopra naturali. + + + Et ſi dichiarano i vocaboli, & luoghi più difficili. + +

    + + In Venetia, Appreſſo Franceſco di Franceſchi Saneſe. + MD LXXXI. + +

    +
    +
    +
    +
    +
    +
    + + Mechaniche + + 2 + + + 1 + 1 + 1 + LE + MECHANICHE + DELL'ILLVSTRISS SIG. + GVIDO VBALDO + DE' MARCHESI DEL + MONTE: + + + + 2 + 1 + 3 + + A beneficio di chi ſi diletta di queſta nobiliſſima scienza; & maſſimamente + di Capitani di guerra, Ingegnieri, Architetti, & d'ogni + Artefice, che intenda per via di Machine + far opre marauiglioſe, e quaſi + ſopra naturali. + + + + + + +
    diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/monte-page1.xpr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/monte-page1.xpr Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,12 @@ + + + + + + + + + + + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/page-query-result.xquery --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/page-query-result.xquery Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,88 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "util/time.xquery"; +import module namespace mpdl-lucene = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/lucene/search" at "lucene/search.xquery"; +import module namespace mpdl-text = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/text" at "text/all.xquery"; + +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace transform = "http://exist-db.org/xquery/transform"; +declare namespace util = "http://exist-db.org/xquery/util"; + + +let $document := request:get-parameter("document", "agric_remet_001_la_1556") +let $mode := request:get-parameter("mode", "image") +let $pn := number(request:get-parameter("pn", "1")) +let $ftQuery := request:get-parameter("ft-query", "") +let $indexTermsStartStr := request:get-parameter("index-terms-start-str", "") + +let $currentTimeBegin := util:system-time() +let $docPath := concat("/db/archimedes/", $document, ".xml") +let $docRoot := doc($docPath) +let $archimedesInfo := $docRoot/archimedes/info +let $locator := $archimedesInfo/locator +let $countPages := count($docRoot//pb) +let $pb1 := $docRoot//pb[$pn] +let $positionOfFirstFigureAfterPB1 := count($pb1/following::figure[1]/preceding::figure) + 1 (: position der ersten figure nach pb1 :) +let $pb1ImageRefLeft := substring-before($locator, ".") +let $pb1ImageRefRight := "01" +let $pb2 := $docRoot//pb[$pn + 1] +let $errorCode := + if ($pn < $countPages + 1 and $pn > 0) + then 0 + else 1 + +let $retPageFragment := + if ($mode = "image" or $errorCode > 0) + then () + else util:get-fragment-between($pb1, $pb2, true()) + +let $returnPageFragment := util:parse($retPageFragment) (: string2xml: returns a valid xml document for that string :) + +let $ftHits := + if ($ftQuery = "") + then () + else mpdl-lucene:search($docPath, $ftQuery) + +let $indexTerms := + if($indexTermsStartStr = "") + then () + else mpdl-text:indexTerms($docRoot, $indexTermsStartStr, 100) + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $xmlResult := + if ($errorCode = 0) + then + + {$mode} + + {$document} + {$archimedesInfo} + {$countPages} + {$neededTime} + + + {$pn} + http://nausikaa2.rz-berlin.mpg.de/digitallibrary/digilib.jsp?fn=/permanent/archimedes/{$document}/{$pb1ImageRefLeft}-{$pb1ImageRefRight}-pageimg&pn={$pn} + http://echo.mpiwg-berlin.mpg.de/zogilib?fn=/permanent/archimedes/{$document}/{$pb1ImageRefLeft}-{$pb1ImageRefRight}-pageimg&pn={$pn} + http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=/permanent/archimedes/{$document}/{$pb1ImageRefLeft}-{$pb1ImageRefRight}-pageimg&pn={$pn} + ?document={$document}&pn={$pn}&mode=xml + {$positionOfFirstFigureAfterPB1} + {$returnPageFragment} + + {$ftHits} + {$indexTerms} + + else if ($errorCode = 1) + then No result: Page {$pn} not found + else undefined error: {$errorCode} + +let $declare := + if ($mode = "text" or $mode = "image" or $mode = "xml") + then util:declare-option("exist:serialize", "method=html media-type=text/html omit-xml-declaration=no indent=yes encoding=UTF-8") + else util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=UTF-8") + +let $result := transform:transform($xmlResult, doc("/db/xsl/archimedes-page-fragment.xsl"), ()) + +return $result \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/page-query-result.xquery.old.xquery --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/page-query-result.xquery.old.xquery Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,151 @@ +xquery version "1.0"; + +module namespace ft="http://exist-db.org/xquery/lucene"; +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace text="http://exist-db.org/xquery/text"; +declare namespace transform="http://exist-db.org/xquery/transform"; +declare namespace util="http://exist-db.org/xquery/util"; +declare namespace docc = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/docc"; +declare namespace time-util = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/time-util"; + +declare function time-util:duration-as-ms($t) { + round((minutes-from-duration($t) * 60 + seconds-from-duration($t)) * 1000 ) +}; + +declare function docc:ft-search($docPath, $ftQuery) as node() { + let $document := doc($docPath) + (: performance reasons: all hits (not only the first 10! ) are passed through the :) + (: for loop: so the overhead in each loop has to be minimized :) + let $t := $document//s[ft:query(., $ftQuery)] + let $tempQueryResult := + for $ss at $poss in $t + (: where $poss > 100 and $poss <= 200 :) + return $ss + let $queryResult := + for $s at $pos in $tempQueryResult + let $pnOfS := count($document//pb[. << $s]) (: faster: comparison only in pb elements of this document :) + let $posOfS := count($document//pb[$pnOfS]/following::s[. << $s]) + 1 (: faster: comparisonon only in s elements of this document :) + let $resultElem := + + {$pos} + {$pnOfS} + {$posOfS} + {$s} + + return $resultElem + let $resultSize := count($queryResult) + let $result := + + {$ftQuery} + + {$resultSize} + + {$queryResult} + + + + return $result +}; + +declare function docc:termEntries($term as xs:string, $data as xs:int+) { + let $result := + + {$term} + {$data[1]} + {$data[2]} + {$data[3]} + {$data[4]} + + return $result +}; + +declare function docc:indexTerms($document, $indexTermsStartStr, $count) as node()* { + let $docName := util:document-name($document) + let $index := /archimedes/info/cvs_file[contains(., $docName)]/root()/archimedes/text + let $callback := util:function(QName("http://www.mpiwg-berlin.mpg.de/ns/mpdl/docc", "docc:termEntries"), 2) + let $result := text:index-terms($index, $indexTermsStartStr, $callback, $count) + return + + {$indexTermsStartStr} + {$result} + +}; + + +let $document := request:get-parameter("document", "agric_remet_001_la_1556") +let $mode := request:get-parameter("mode", "image") +let $pn := number(request:get-parameter("pn", "1")) +let $ftQuery := request:get-parameter("ft-query", "") +let $indexTermsStartStr := request:get-parameter("index-terms-start-str", "") + +let $currentTimeBegin := util:system-time() +let $docPath := concat("/db/archimedes/", $document, ".xml") +let $docRoot := doc($docPath) +let $archimedesInfo := $docRoot/archimedes/info +let $locator := $archimedesInfo/locator +let $countPages := count($docRoot//pb) +let $pb1 := $docRoot//pb[$pn] +let $positionOfFirstFigureAfterPB1 := count($pb1/following::figure[1]/preceding::figure) + 1 (: position der ersten figure nach pb1 :) +let $pb1ImageRefLeft := substring-before($locator, ".") +let $pb1ImageRefRight := "01" +let $pb2 := $docRoot//pb[$pn + 1] +let $errorCode := + if ($pn < $countPages + 1 and $pn > 0) + then 0 + else 1 + +let $retPageFragment := + if ($mode = "image" or $errorCode > 0) + then () + else util:get-fragment-between($pb1, $pb2, true()) + +let $returnPageFragment := util:parse($retPageFragment) (: string2xml: returns a valid xml document for that string :) + +let $ftHits := + if ($ftQuery = "") + then () + else docc:ft-search($docPath, $ftQuery) + +let $indexTerms := + if($indexTermsStartStr = "") + then () + else docc:indexTerms($docRoot, $indexTermsStartStr, 100) + +let $currentTimeEnd := util:system-time() +let $neededTime := time-util:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $xmlResult := + if ($errorCode = 0) + then + + {$mode} + + {$document} + {$archimedesInfo} + {$countPages} + {$neededTime} + + + {$pn} + http://nausikaa2.rz-berlin.mpg.de/digitallibrary/digilib.jsp?fn=/permanent/archimedes/{$document}/{$pb1ImageRefLeft}-{$pb1ImageRefRight}-pageimg&pn={$pn} + http://echo.mpiwg-berlin.mpg.de/zogilib?fn=/permanent/archimedes/{$document}/{$pb1ImageRefLeft}-{$pb1ImageRefRight}-pageimg&pn={$pn} + http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=/permanent/archimedes/{$document}/{$pb1ImageRefLeft}-{$pb1ImageRefRight}-pageimg&pn={$pn} + ?document={$document}&pn={$pn}&mode=xml + {$positionOfFirstFigureAfterPB1} + {$returnPageFragment} + + {$ftHits} + {$indexTerms} + + else if ($errorCode = 1) + then No result: Page {$pn} not found + else undefined error: {$errorCode} + +let $declare := + if ($mode = "text" or $mode = "image" or $mode = "xml") + then util:declare-option("exist:serialize", "method=html media-type=text/html omit-xml-declaration=no indent=yes encoding=UTF-8") + else util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=UTF-8") + +let $result := transform:transform($xmlResult, doc("/db/xsl/archimedes-page-fragment.xsl"), ()) + +return $result diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/page.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/page.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,532 @@ + + + + + + + + + + + + + + + + + + + + + + + (...) + + + + + + + + + (...) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    + + . + . + , + + +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + +
    + + + + + + + + + + +
    +
    +
    + / + +
    + + + + + + +
    + + + + + + + + + + +
    +
    + +
    + + Page: + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + Page image: {$number} + + + + + + +
    + + + + Book contains: + +
    +
    + + + + Index terms: + + +
    + +
    + sentences contain: "" +
      + +
    1. + + + Page , Sentence :

      + + +
    2. +
      +
    +
    + +
    + + + + terms beginning with: ""
    + + + + + + + + + + + + +
    +
      + + + + + + + + Lin Yutang + Echo + + +
    1. + () [] +
    2. +
      +
    +
    + + + + + + + +
    + + + + + +
    +
    +
    + / + +
    + + + + + + +
    + + + + + +
    +
    +
    + +
    + No results +
    + + +
    + + +
    +
    + Elapsed time: , ms, Back to query page, see the XQuery source and XSL source of this page +
    + + [slower mechanism (XQL search)] +
    + +
    + + + + + + + + +
      + <></> +
    +
    + + + ="" + + + + + + + + + + + + + + + + +

    +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + +

    + figure: {$figureId} +

    + Figure: +

    +
    + + + + + + + + + + + + + + + + +
    diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/text/all.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/text/all.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,48 @@ +xquery version "1.0"; + +module namespace mpdl-text = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/text"; + +declare namespace text = "http://exist-db.org/xquery/text"; +declare namespace util = "http://exist-db.org/xquery/util"; +declare namespace local = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/local"; + +declare function mpdl-text:indexTerms($document, $indexTermsStartStr, $pn as xs:int, $pageSize as xs:int) as node()* { + let $index := $document/archimedes/text + let $language := $document/archimedes/info/lang + let $from := ($pn * $pageSize) - $pageSize + 1 + let $to := $pn * $pageSize + let $maxTo := 10000 + let $callback := util:function(QName("http://www.mpiwg-berlin.mpg.de/ns/mpdl/local", "local:termEntries"), 2) + let $indexResult := text:index-terms($index, $indexTermsStartStr, $callback, $maxTo) + let $count := count($indexResult) + let $pages := + if ($count = 0) + then 0 + else $count idiv $pageSize + 1 + let $resultEntries := + for $entry at $pos in $indexResult + where $pos >= $from and $pos <= $to + return $entry + + let $result := + + {$indexTermsStartStr} + {$count} + {$pages} + {$pn} + {$resultEntries} + + return $result +}; + +declare function local:termEntries($term as xs:string, $data as xs:int+) { + let $result := + + {$term} + {$data[1]} + {$data[2]} + {$data[3]} + {$data[4]} + + return $result +}; diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/util/functx.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/util/functx.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,20 @@ +xquery version "1.0"; + +module namespace functx = "http://www.functx.com"; + +declare function functx:substring-before-last( $arg as xs:string?, $delim as xs:string ) as xs:string { + if (matches($arg, functx:escape-for-regex($delim))) + then replace($arg, + concat('^(.*)', functx:escape-for-regex($delim),'.*'), + '$1') + else '' +}; + +declare function functx:substring-after-last( $arg as xs:string?, $delim as xs:string ) as xs:string { + replace ($arg,concat('^.*',functx:escape-for-regex($delim)),'') +}; + +declare function functx:escape-for-regex( $arg as xs:string? ) as xs:string { + replace($arg, + '(\.|\[|\]|\\|\||\-|\^|\$|\?|\*|\+|\{|\}|\(|\))','\\$1') +}; \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/util/time.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/util/time.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,7 @@ +xquery version "1.0"; + +module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time"; + +declare function mpdl-time:duration-as-ms($t) { + round((minutes-from-duration($t) * 60 + seconds-from-duration($t)) * 1000 ) +}; diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/oxygen-projects/xql/xql.xpr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/oxygen-projects/xql/xql.xpr Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,9 @@ + + + + + + + + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/archimedes-figures.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/archimedes-figures.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,34 @@ +xquery version "1.0"; + +declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; +declare namespace exist="http://exist.sourceforge.net/NS/exist"; +declare namespace util = "http://exist-db.org/xquery/util"; + + +let $coll := collection('/db/mpdl/documents/standard/archimedes') +let $tmpResult := $coll//figure +let $result := + for $figure at $pos in $tmpResult + let $collName := util:collection-name($figure) + let $shortCollName := substring-after(substring-after(substring-after(substring-after(substring-after($collName, "/"), "/"), "/"), "/"), "/") + let $docName := util:document-name($figure) + let $mpdlDocUri := concat("/", $shortCollName, "/", $docName) + let $fullDocName := concat($collName, "/", $docName) + let $document := doc($fullDocName) + let $pageBreaks := $document//pb + let $pnOfFigure := count($pageBreaks[. << $figure]) + let $hit := +
  • + {$mpdlDocUri}, Page {$pnOfFigure} +
  • + order by $fullDocName, $pnOfFigure + return $hit + +return + + +

    All figures in all Archimedes documents

    +
      {$result}
    + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/controller.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/controller.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,64 @@ +xquery version "1.0"; + +(: Controller XQuery for the mpdl application. :) + +let $id := "blabla" + +return +if ($exist:path eq '/test.xql') +then + + + + + +else if (starts-with($exist:path, '/ir/')) then + + + + + +else if ($exist:resource eq 'execute') then + let $query := request:get-parameter("qu", ()) + let $startTime := util:system-time() + return + + + + + + + + + + + + + + + + + + + + +(: Retrieve an item from the query results stored in the HTTP session. The + format of the URL will be /sandbox/results/X, where X is the number of the + item in the result set :) +else if (starts-with($exist:path, '/results/')) then + + + + + +else if (starts-with($exist:path, '/scripts/yui')) then + + + +else + (: everything else is passed through :) + + + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/doc.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/doc.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,7 @@ +document { + element product { + attribute dept { "ACC" }, + element number { 563 }, + element name { attribute language {"en"}, "Floppy Sun Hat"} + } +} diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/dummy.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/dummy.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,46 @@ +xquery version "1.0"; + +declare namespace dummy = "http://archimedes.mpiwg-berlin.mpg.de"; +declare namespace xlink = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"; + +declare option exist:serialize "method=xml media-type=text/xml omit-xml-declaration=no indent=yes"; + +declare function dummy:getDummyDocument() as node() { + let $bla := + document { + element product { + attribute dept { "ACC" }, + element number { 563 }, + element name { attribute language {"en"}, "Floppy Sun Hat"} + }, + element product { + attribute dept { "BCC" }, + element number { 564 }, + element name { attribute language {"en"}, "Floppy SBun Iat"} + } + } + return $bla +}; + +declare function dummy:milestone-chunk($ms1 as node(), $ms2 as node(), $node as node()) as node()* { (: Version 1.0 -- 7 Feb 2005 -- David Sewell Usage: The first two parameters are the starting and ending milestone elements in a document or document fragment. Example: $doc//pb[@n='1'], $doc//pb[@n='2']. The third parameter should initially be an element that is a parent or ancestor of all the milestones, like $doc//body or $doc//text. (This parameter is the only one that varies as the function is called recursively.) The function returns only a single node containing the content between the two milestones. To return, for example, all the pages in a book, call the function repeatedly by reiterating over every , where $ms2 will be either the following or, for the last one, the final node() in the document or document fragment. English-language explanation of the function operation: Test for node type. For an element, if it is (1) an ancestor or self of one of the two milestones, use the "element" function to return an element of the same name, with its content created by recursing over any child nodes. If it is (2) an element in between the two milestones, return the element. If it is (3) anything else, return null. For an attribute node, return the entire attribute. For a text node, return it if it is between the milestones; otherwise return null. :) typeswitch ($node) case element() return if ($node is $ms1) then $node else if ( some $n in $node/descendant::* satisfies ($n is $ms1 or $n is $ms2) ) then element { name($node) } { for $i in ( $node/node() | $node/@* ) return dummy:milestone-chunk($ms1, $ms2, $i) } else if ( $node >> $ms1 and $node << $ms2 ) then $node else () case attribute() return attribute { name($node) } { data($node) } default return if ( $node >> $ms1 and $node << $ms2 ) then $node else () }; + +let $dummy := dummy:getDummyDocument() + +let $docAchil := /archimedes/info[cvs_file = 'achil_propo_087_la_1545.xml']/fn:root() +let $pb184 := $docAchil//pb[@n='185'] +let $pb185 := $docAchil//pb[@n='186'] +let $page184 := dummy:milestone-chunk($pb184, $pb185, $docAchil//text) + + +return + (: :) + transform:transform($dummy, doc("/db/xsl/archimedes.xsl"), ()) + +(: + + + + Dummy + + +:) \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/echo-figures.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/echo-figures.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,69 @@ +xquery version "1.0"; + +declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; +declare namespace exist="http://exist.sourceforge.net/NS/exist"; +declare namespace util = "http://exist-db.org/xquery/util"; + +import module namespace mpdl-text = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/text" at "../..//text/all.xql"; + +let $coll := collection('/db/mpdl/documents/standard/echo') +let $tmpResult := $coll//echo:figure +let $result := + for $figure at $pos in $tmpResult + let $collName := util:collection-name($figure) + let $shortCollName := substring-after(substring-after(substring-after(substring-after(substring-after($collName, "/"), "/"), "/"), "/"), "/") + let $docName := util:document-name($figure) + let $mpdlDocUri := concat("/", $shortCollName, "/", $docName) + let $echoArchivePath := mpdl-text:getEchoArchivePath($mpdlDocUri) + let $figLabel := string($figure/@xlink:label) + let $imageFileName := string($figure/echo:image/@file) + let $imageXlinkHref := string($figure/echo:image/@xlink:href) + let $fullDocName := concat($collName, "/", $docName) + let $document := doc($fullDocName) + let $pageBreaks := $document//echo:pb + let $pnOfFigure := count($pageBreaks[. << $figure]) + let $captionStr := + if (not(empty($figure/echo:caption))) + then string-join($figure/echo:caption, " ") + else "" + let $descriptionStr := + if (not(empty($figure/echo:description))) + then string-join($figure/echo:description, " ") + else "" + let $captionElemStr := + if ($captionStr != "") + then concat("    <caption>", $captionStr, "</caption>") + else "" + let $descriptionElemStr := + if ($descriptionStr != "") + then concat("    <description>", $descriptionStr, "</description>") + else "" + let $caption := + if ($captionElemStr != "") + then {$captionElemStr}
    + else () + let $description := + if ($descriptionElemStr != "") + then {$descriptionElemStr}
    + else () + let $hit := +
  • + {$mpdlDocUri}, Page {$pnOfFigure} +
    +   <figure xlink:label="{$figLabel}">
    +     <image file="{$imageFileName}" xlink:href="{$imageXlinkHref}"/>
    + {$caption} + {$description} +   </figure> +
  • + order by $fullDocName, $pnOfFigure + return $hit + +return + + +

    All figures in all Echo documents

    +
      {$result}
    + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/echo-post.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/echo-post.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,16 @@ +xquery version "1.0"; + +(: echo-post.xq: Return all data from an HTTP post to the caller. Test all web forms :) + +declare namespace exist = "http://exist.sourceforge.net/NS/exist"; +declare namespace xmldb="http://exist-db.org/xquery/xmldb"; +declare namespace request="http://exist-db.org/xquery/request"; + +declare option exist:serialize "method=xml media-type=text/xml indent=yes"; + +let $post-data := request:get-data() + +return + + {$post-data} + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/echo.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/echo.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,7 @@ +xquery version "1.0"; + + +{myecho:myecho("Hello")} +{myecho:myecho("MPDL")} +{mpdltext:getWords("bla blu blub. hh gb-hh", "[,;.\s]+", "i")} + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/get-fragment.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/get-fragment.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,19 @@ +xquery version "1.0"; + +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; +declare namespace exist="http://exist.sourceforge.net/NS/exist"; +declare namespace util = "http://exist-db.org/xquery/util"; +declare namespace foo = "http://exist-db.org/xquery/foo"; + + +let $coll := collection("/db/mpdl/documents/standard/archimedes/la") +let $doc := doc("/db/mpdl/documents/standard/echo/zh/SongYingxing_1637.xml") +let $pn := 300 +let $xpathQuery := "//place" + + +let $node := blablaggggg let $nodeTest := barblaggggg let $login := xmldb:login('/db/', 'admin', '') let $store := xmldb:store('/db/', 'test.xml', $node) let $doc := doc('/db/test.xml') +let $ms1 := subsequence($doc//*:b, 1, 1) +let $ms2 := subsequence($doc//*:c, 1, 1) let $result := util:get-fragment-between($ms1, $ms2, true()) +let $bla := util:parse($result) +return $bla \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/kwic.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/kwic.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,174 @@ +(: module namespace kwic="http://exist-db.org/xquery/kwic"; :) +module namespace kwic="/exist/xquery/archimedes/kwic"; + +declare variable $kwic:CHARS_SUMMARY := 120; +declare variable $kwic:CHARS_KWIC := 40; + +(:~ + Retrieve the following and preceding text chunks for a given match. + + @param $match the text node containing the match + @param $mode the selection mode: either "previous" or "following" +:) +declare function kwic:get-context($match as element(exist:match), $mode as xs:string) as node()* { + let $sibs := + if ($mode eq 'previous') then + $match/preceding::text() + else + $match/text()/following::text() + for $sib in $sibs + return + if ($sib/parent::exist:match) then + {$sib} + else + $sib +}; + +(:~ + Like fn:substring, but takes a node argument. If the node is an element, + a new element is created with the same node-name as the old one and the + shortened text content. +:) +declare function kwic:substring($node as node(), $start as xs:int, $count as xs:int) as item()? { + let $str := substring($node, $start, $count) + return + if ($node instance of element()) then + element { node-name($node) } { $str } + else + $str +}; + +(:~ + Generate the left-hand context of the match. Returns a sequence of nodes + and strings, whose total string length is less than or equal to $max characters. + + Note: this function calls itself recursively until $nodes is empty or + the returned sequence has the desired total string length. +:) +declare function kwic:truncate-previous($nodes as node()*, $truncated as item()*, + $max as xs:int, $chars as xs:int) { + if ($nodes) then + let $next := $nodes[last()] + return + if ($chars + string-length($next) gt $max) then + let $remaining := $max - $chars + return + ("...", kwic:substring($next, string-length($next) - $remaining, $remaining), $truncated) + else + kwic:truncate-previous(subsequence($nodes, 1, count($nodes) - 1), ($next, $truncated), + $max, $chars + string-length($next)) + else + $truncated +}; + +(:~ + Generate the right-hand context of the match. Returns a sequence of nodes + and strings, whose total string length is less than or equal to $max characters. + + Note: this function calls itself recursively until $nodes is empty or + the returned sequence has the desired total string length. +:) +declare function kwic:truncate-following($nodes as node()*, $truncated as item()*, $max as xs:int, $chars as xs:int) { + if ($nodes) then + let $next := $nodes[1] + return + if ($chars + string-length($next) gt $max) then + let $remaining := $max - $chars + return + ($truncated, kwic:substring($next, 1, $remaining), "...") + else + kwic:truncate-following(subsequence($nodes, 2), ($truncated, $next), + $max, $chars + string-length($next)) + else + $truncated +}; + +(:~ + Computes the total string length of the nodes in the argument sequence +:) +declare function kwic:string-length($nodes as item()*) as xs:int { + if (exists($nodes)) then + sum(for $n in $nodes return string-length($n)) + else + 0 +}; + +(:~ + Print a summary of the match in $node. Output a predefined amount of text to + the left and the right of the match. + + @param $root the root element containing the match. This is the original element + stored in the database. + @param $node the exist:match element to process. + @param $config configuration element which determines the behaviour of the function +:) +declare function kwic:get-summary($root as node(), $node as element(exist:match), $config as element(config)) as element() { + let $chars := xs:int($config/@width) + let $table := $config/@table = ('yes', 'true') + let $prev := kwic:get-context($node, 'previous') + let $prevTrunc := kwic:truncate-previous($prev, (), $chars, 0) + let $remain := + if (not($table)) then + $chars * 2 - kwic:string-length($prevTrunc) + else + $chars + let $following := kwic:get-context($node, 'following') + let $followingTrunc := kwic:truncate-following($following, (), $remain, 0) + return + if (not($table)) then +

    + {$prevTrunc} + { + if ($config/@link) then + { $node/text() } + else + { $node/text() } + } + {$followingTrunc} +

    + else + + {$prevTrunc} + + { + if ($config/@link) then + {$node/text()} + else + $node/text() + } + + {$followingTrunc} + +}; + +(:~ + Main function of the KWIC module: takes the passed element and returns an + XHTML fragment containing a chunk of text before and after the first full text + match in the node. + + The optional config parameter is used to configure the behaviour of the function: + + <config width="character width" table="yes|no" link="URL to which the match is linked"/> + + By default, kwic:summarize returns an XHTML fragment with the following structure: + + <p xmlns="http://www.w3.org/1999/xhtml"> + <span class="previous">Text before match</span> + <a href="passed URL if any" class="hi">The highlighted term</a> + <span class="following">Text after match</span> + </p> + + If table=yes is passed with the config element, a tr table row will be returned instead + of a span (using the same class names). + + @param $hit an arbitrary XML element which has been selected by one of the full text + operations or an ngram search. + @param $config configuration element to configure the behaviour of the function +:) +declare function kwic:summarize($hit as element(), $config as element(config)) +as element()* { + let $expanded := util:expand($hit) + for $match in $expanded//exist:match[1] + return + kwic:get-summary($hit, $match, $config) +}; diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/test-trigger.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/test-trigger.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,25 @@ +xquery version "1.0"; + +(: + A simple XQuery for an XQueryTrigger that + logs all trigger events for which it is executed + in the file /db/triggersLogs.xml +:) + +declare namespace xmldb="http://exist-db.org/xquery/xmldb"; + +declare variable $local:triggerEvent external; +declare variable $local:eventType external; +declare variable $local:collectionName external; +declare variable $local:documentName external; +declare variable $local:document external; + +declare variable $local:triggersLogFile := "test-trigger-log.xml"; + +(: create the log file if it does not exist :) +if(not(doc-available($local:triggersLogFile))) +then (xmldb:store("/db/test", $local:triggersLogFile, )) +else () + +(: log the trigger details to the log file :) +update insert {$local:document} into doc("/db/test/test-trigger-log.xml")/triggers diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/test2.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/test2.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,17 @@ +xquery version "1.0"; + +import module namespace request="http://exist-db.org/xquery/request"; + +let $id := request:get-parameter("id", ()) + +return + + + Example Web Application + + +

    This is a test

    + {$id} + + + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/test3.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/test3.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,36 @@ +xquery version "1.0"; + +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; +declare namespace exist="http://exist.sourceforge.net/NS/exist"; +declare namespace util = "http://exist-db.org/xquery/util"; +declare namespace ft = "http://exist-db.org/xquery/lucene"; + + +let $coll := collection("/db/mpdl/documents/standard/archimedes/la") +let $doc := doc("/db/mpdl/documents/standard/echo/zh/SongYingxing_1637.xml") +let $pn := 300 +let $xpathQuery := "//place" + +let $pageBreaks := $doc//echo:pb +let $pb1 := subsequence($pageBreaks, $pn, 1) +let $pb2 := subsequence($pageBreaks, $pn + 1, 1) +let $pageFragment := + if ($pn != -1) + then util:get-fragment-between($pb1, $pb2, true()) + else () +let $fragmentNode := util:parse($pageFragment) + +let $bla := 12 +let $tmpFragmentNode := util:eval-inline($fragmentNode, ".") + +let $result := util:eval-inline($doc, "let $a := //echo:metadata let $b := for $elem in $a let $bla := $elem return $bla return $b") +let $result2 := util:eval-inline($bla, "bla/place") +let $result3 := util:eval-inline($fragmentNode, "let $a := .//place return $a") +let $result4 := util:eval-inline($tmpFragmentNode, ".//place") +let $result5 := util:eval-inline($fragmentNode, concat (".", $xpathQuery)) +let $result6 := util:eval-inline($doc, "util:node-id(//echo:metadata)") +let $result7 := util:eval-inline($bla, "let $a := .//place let $b := for $elem in $a let $bla := $elem return $bla return $b") +let $result8 := util:eval-inline($doc, "let $a := .//echo:place let $b := for $elem at $i in $a let $bla := concat($i, '. Place: ', $elem, ' (Level: ', util:node-id($elem), ', ', util:node-xpath($elem), ')') return $bla return $b") + + +return $result8 diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/_stuff/testDev/testXslFO.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/testXslFO.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,21 @@ +xquery version "1.0"; +declare namespace fo="http://www.w3.org/1999/XSL/Format"; +declare namespace xslfo="http://exist-db.org/xquery/xslfo"; + +let $fo := + + + + + + + + + Hello World! + + + + +let $pdf := xslfo:render($fo, "application/pdf", ()) + +return response:stream-binary($pdf, "application/pdf", "test-page-1.pdf") diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/attribute-query-result.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/attribute-query-result.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,335 @@ +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 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 $fulltextMorphArchDocPath := concat($docPathMorph, "/", $docBaseArch, "/", $language) +let $fulltextMorphEchoDocPath := concat($docPathMorph, "/", $docBaseEcho, "/", $language) +let $fulltextMorphCollection := + if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho)) + then collection($fulltextMorphArchDocPath, $fulltextMorphEchoDocPath) + else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho))) + then collection($fulltextMorphArchDocPath) + else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho)) + then collection($fulltextMorphEchoDocPath) + else () + +let $fulltextStandardArchDocPath := concat($docPathStandard, "/", $docBaseArch) +let $fulltextStandardEchoDocPath := concat($docPathStandard, "/", $docBaseEcho) +let $fulltextStandardCollectionStr := + if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho)) + then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardEchoDocPath, "')") + else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho))) + then concat("collection('", $fulltextStandardArchDocPath, "')") + else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho)) + then concat("collection('", $fulltextStandardEchoDocPath, "')") + else "" +let $metadataStr := concat("(", $fulltextStandardCollectionStr, "/archimedes/info", "|" , $fulltextStandardCollectionStr, "/echo:echo/echo:metadata", ")") +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("&query-type=", $queryType, "&query=", $ftQuery) + else if ($queryType = "fulltextMorph") + then concat("&query-type=", $queryType, "&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 $documentUri := substring-after($documentUriOrig, $docPath) + let $documentUriWithoutExtension := substring-before($documentUri, ".") + 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 $authors := string-join($authorElems, ', ') + let $titles := string-join($titleElems, ', ') + let $places := string-join($placeElems, ', ') + let $dates := string-join($dateElems, ', ') + let $resultElem := + + {$pos}. + + + Download + Download + Download + {$authors} + {$titles} + {$places} + {$dates} + + 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 := + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    {$positionFrom} - {$positionTo} of {$countResult} documents
    {$pn} / {$countPages}
    Page:
    + +let $attrQueryResultError := string($attrQueryResult/error) +let $resultHeader := + if ($attrQueryResultError = '' and $countResult > 0) + then $resultHeaderTable + else if ($attrQueryResultError != '') + then (Your query delivers an error: , $attrQueryResultError) + else if ($errorAttributeSearch != '') + then (Your query delivers an error: , $errorAttributeSearch) + else (Your query delivers no result) + +let $resultPageBody := + if ($attrQueryResultError = '' and $countResult > 0) + then +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {$pageResult} + +
    + + + + + + + + + +
    +
    + else () + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +return + + + {$title} + + +

    {$title}

    + {$resultHeader} + {$resultPageBody} +

    +Elapsed time: {$neededTime} ms, Back to query page, see the XQuery source of this page +

    + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/doc/admin.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/doc/admin.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,18 @@ +xquery version "1.0"; + +import module namespace request="http://exist-db.org/xquery/request"; + +let $operation := request:get-parameter("operation", "") +let $jobId := mpdldoc:do(string($operation), 'empty', 'empty', 'empty', 'empty', 'empty', 'empty') + +return + + + Admin + + +

    Admin

    + JobId of your operation: {$jobId} + + + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/doc/doc-operation-exist.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/doc/doc-operation-exist.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,259 @@ +xquery version "1.0"; + +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace util = "http://exist-db.org/xquery/util"; + +declare namespace escidocItem="http://www.escidoc.de/schemas/item/0.9"; +declare namespace container="http://www.escidoc.de/schemas/container/0.8"; +declare namespace escidocMetadataRecords="http://www.escidoc.de/schemas/metadatarecords/0.5"; +declare namespace dc="http://purl.org/dc/elements/1.1/"; +declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace mpiwg="http://www.mpiwg-berlin.mpg.de/ns/mpiwg"; + +let $docBaseReq := request:get-parameter("docBase", "") +let $docBase := + if ($docBaseReq = '') + then 'echo' + else $docBaseReq +let $languageReq := request:get-parameter("language", "") +let $language := + if ($languageReq = '') + then 'la' + else string($languageReq) + +let $docPathStandard := "/db/mpdl/documents/standard" +let $docPath := concat($docPathStandard, "/", $docBase, "/", $language) +let $docCollectionStr := concat("collection('", $docPath, "')") +let $docCollection := util:eval($docCollectionStr) +let $docFileNames := + for $elem at $pos in $docCollection + let $doc := $elem/fn:root() let $documentUriOrig := document-uri($doc) + let $documentFileName := substring-after(substring-after($documentUriOrig, $docPath), "/") + return $documentFileName + +let $javascriptHtml := + + +let $eSciDocCookieId := session:get-attribute("eSciDocCookieId") + +let $docBaseOptions := + +let $docBaseOptionsSelected := + for $option in $docBaseOptions/option + return element { node-name($option)} + { if ($option/@value = $docBase) + then attribute {'selected'} + {'true'} + else (), + $option/@*, + $option/node() } +let $docBaseSelectBoxDest := + +let $docBaseSelectBoxList := + + +let $languageOptions := + +let $languageOptionsSelected := + for $option in $languageOptions/option + return element { node-name($option)} + { if ($option/@value = $language) + then attribute {'selected'} + {'true'} + else (), + $option/@*, + $option/node() } +let $languageSelectBoxDest := + +let $languageSelectBoxList := + + +let $docsSelectBoxOptions := + for $docFileName at $pos in $docFileNames + let $existIdentifier := concat("/", $docBase, "/", $language, "/", $docFileName) + let $option := + order by $docFileName + return $option +let $docsSelectBox := + + +let $error := + if ($eSciDocCookieId = '' or empty($eSciDocCookieId)) + then No login context available. Please login before you do an operation + else "no" + +let $resultHtml := + if ($error = 'no') + then +
    + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Operation
    + + + Info document interface operation +

    Source Info document interface source
    Local file: +
    or
    Url:

    Destination
    Document base: + {$docBaseSelectBoxDest} +
    Language: + {$languageSelectBoxDest} +
    Document name: Info document interface source
    Document link:
    +
    +
    +
    + + + + + +
    + Documents
    +
    + Document base: + {$docBaseSelectBoxList} + Language: + {$languageSelectBoxList} +
    {$docsSelectBox}
    +
    +
    +
    + else +
    Error in operation: {$error}
    + + + +let $title := "MPDL: eXist document interface" +return + + +{$title} +{$javascriptHtml} + + +

    {$title}

    + {$resultHtml} +
    + See the XQuery source of this page, if you find a bug let us know + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/doc/doc-operation-result-exist.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/doc/doc-operation-result-exist.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,67 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../util/time.xql"; + +declare namespace file = "http://exist-db.org/xquery/file"; +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace session="http://exist-db.org/xquery/session"; +declare namespace util = "http://exist-db.org/xquery/util"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; + +let $login := xmldb:authenticate("xmldb:exist:///db", "admin", "") + +let $operation := request:get-parameter("operation", "") +let $docBase := request:get-parameter("docBase", "") +let $language := request:get-parameter("language", "") +let $fileName := request:get-parameter("fileName", "") + +let $eSciDocCookieId := session:get-attribute("eSciDocCookieId") + +let $srcLocalFileName := request:get-uploaded-file-name("srcLocalFileName") +let $srcExistUploadFileJavaObject := request:get-uploaded-file("srcLocalFileName") +let $srcExistUploadFileName := string({$srcExistUploadFileJavaObject}) +let $srcExistUploadFileUrl := concat("file://", $srcExistUploadFileName) + +let $reqSrcUrl := request:get-parameter("srcUrl", "") +let $srcUrl := + if ($reqSrcUrl = '') + then $srcExistUploadFileUrl + else $reqSrcUrl + +let $error := + if ($eSciDocCookieId = '' or empty($eSciDocCookieId)) + then No login context available. Please login before you do an operation + else if(($operation = 'updateExist') and ($srcUrl = '')) + then "please specify your source" + else if(($operation = 'updateExist' or $operation = 'delete') and ($fileName = '')) + then "please specify your destination document name" + else "no" + +let $jobId := + if($error = 'no' and $operation = 'updateExist') + then mpdldoc:do($operation, $srcUrl, $srcLocalFileName, $docBase, $language, $fileName, $eSciDocCookieId) + else if($error = 'no' and $operation = 'deleteExist') + then mpdldoc:do($operation, 'empty', 'empty', $docBase, $language, $fileName, $eSciDocCookieId) + else () +let $redirectUrl := here +let $resultHtml := + if ($error = 'no') + then
    See the status of your document operation {$redirectUrl}
    + else
    Error in your document operation: {$error}
    + +let $title := "MPDL: eXist document management" +return + + +{$title} + + +

    {$title}

    + {$resultHtml} +
    +
    +
    +
    + Back to document operation page, see the XQuery source of this page, if you find a bug let us know + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/doc/doc-operation-result.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/doc/doc-operation-result.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,67 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../util/time.xql"; + +declare namespace file = "http://exist-db.org/xquery/file"; +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace session="http://exist-db.org/xquery/session"; +declare namespace util = "http://exist-db.org/xquery/util"; +declare namespace xmldb = "http://exist-db.org/xquery/xmldb"; + +let $login := xmldb:authenticate("xmldb:exist:///db", "admin", "") + +let $operation := request:get-parameter("operation", "") +let $docBase := request:get-parameter("docBase", "") +let $language := request:get-parameter("language", "") +let $fileName := request:get-parameter("fileName", "") + +let $eSciDocCookieId := session:get-attribute("eSciDocCookieId") + +let $srcLocalFileName := request:get-uploaded-file-name("srcLocalFileName") +let $srcExistUploadFileJavaObject := request:get-uploaded-file("srcLocalFileName") +let $srcExistUploadFileName := string({$srcExistUploadFileJavaObject}) +let $srcExistUploadFileUrl := concat("file://", $srcExistUploadFileName) + +let $reqSrcUrl := request:get-parameter("srcUrl", "") +let $srcUrl := + if ($reqSrcUrl = '') + then $srcExistUploadFileUrl + else $reqSrcUrl + +let $error := + if ($eSciDocCookieId = '' or empty($eSciDocCookieId)) + then No login context available. Please login before you do an operation + else if(($operation = 'create' or $operation = 'update') and ($srcUrl = '')) + then "please specify your source" + else if(($operation = 'create' or $operation = 'update' or $operation = 'delete') and ($fileName = '')) + then "please specify your destination document name" + else "no" + +let $jobId := + if($error = 'no' and ($operation = 'create' or $operation = 'update')) + then mpdldoc:do($operation, $srcUrl, $srcLocalFileName, $docBase, $language, $fileName, $eSciDocCookieId) + else if($error = 'no' and ($operation = 'delete')) + then mpdldoc:do($operation, 'empty', 'empty', $docBase, $language, $fileName, $eSciDocCookieId) + else () +let $redirectUrl := here +let $resultHtml := + if ($error = 'no') + then
    See the status of your document operation {$redirectUrl}
    + else
    Error in your document operation: {$error}
    + +let $title := "MPDL: eXist/eSciDoc document management" +return + + +{$title} + + +

    {$title}

    + {$resultHtml} +
    +
    +
    +
    + Back to document operation page, see the XQuery source of this page, if you find a bug let us know + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/doc/doc-operation.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/doc/doc-operation.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,319 @@ +xquery version "1.0"; + +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace util = "http://exist-db.org/xquery/util"; + +declare namespace escidocItem="http://www.escidoc.de/schemas/item/0.9"; +declare namespace container="http://www.escidoc.de/schemas/container/0.8"; +declare namespace escidocMetadataRecords="http://www.escidoc.de/schemas/metadatarecords/0.5"; +declare namespace dc="http://purl.org/dc/elements/1.1/"; +declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace mpiwg="http://www.mpiwg-berlin.mpg.de/ns/mpiwg"; + +let $docBaseReq := request:get-parameter("docBase", "") +let $docBase := + if ($docBaseReq = '') + then 'echo' + else $docBaseReq +let $languageReq := request:get-parameter("language", "") +let $language := + if ($languageReq = '') + then 'la' + else string($languageReq) + +let $docPathStandard := "/db/mpdl/documents/standard" +let $docPath := concat($docPathStandard, "/", $docBase, "/", $language) +let $docCollectionStr := concat("collection('", $docPath, "')") +let $docCollection := util:eval($docCollectionStr) +let $docFileNames := + for $elem at $pos in $docCollection + let $doc := $elem/fn:root() let $documentUriOrig := document-uri($doc) + let $documentFileName := substring-after(substring-after($documentUriOrig, $docPath), "/") + return $documentFileName + +let $javascriptHtml := + + +let $eSciDocCookieId := session:get-attribute("eSciDocCookieId") + +let $docBaseOptions := + +let $docBaseOptionsSelected := + for $option in $docBaseOptions/option + return element { node-name($option)} + { if ($option/@value = $docBase) + then attribute {'selected'} + {'true'} + else (), + $option/@*, + $option/node() } +let $docBaseSelectBoxDest := + +let $docBaseSelectBoxList := + + +let $languageOptions := + +let $languageOptionsSelected := + for $option in $languageOptions/option + return element { node-name($option)} + { if ($option/@value = $language) + then attribute {'selected'} + {'true'} + else (), + $option/@*, + $option/node() } +let $languageSelectBoxDest := + +let $languageSelectBoxList := + + +let $docsSelectBoxOptions := + for $docFileName at $pos in $docFileNames + let $existIdentifier := concat("/", $docBase, "/", $language, "/", $docFileName) + let $option := + order by $docFileName + return $option +let $docsSelectBox := + + +let $error := + if ($eSciDocCookieId = '' or empty($eSciDocCookieId)) + then No login context available. Please login before you do an operation + else "no" + +let $resultHtml := + if ($error = 'no') + then +
    + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    Operation
    + + + Info document interface operation +

    Source Info document interface source
    Local file: +
    or
    Url:

    Destination
    Document base: + {$docBaseSelectBoxDest} +
    Language: + {$languageSelectBoxDest} +
    Document name: Info document interface source
    eXist document link:
    eSciDoc document link:
    +
    +
    +
    + + + + + + +
    + Documents
    +
    + Document base: + {$docBaseSelectBoxList} + Language: + {$languageSelectBoxList} +
    {$docsSelectBox}
    +
    +
    +
    + else +
    Error in operation: {$error}
    + + + +let $title := "MPDL: eXist/eSciDoc document interface" +return + + +{$title} +{$javascriptHtml} + + +

    {$title}

    + {$resultHtml} +
    + See the XQuery source of this page, if you find a bug let us know + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/doc/get-escidoc-containerid.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/doc/get-escidoc-containerid.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,12 @@ +xquery version "1.0"; + +let $existId := request:get-parameter("existId", "") +let $eSciDocCookieId := request:get-parameter("eSciDocCookieId", "") + +let $eSciDocId := + if ($eSciDocCookieId != '') + then mpdldoc:escidoc-get-containerid($existId, $eSciDocCookieId) + else "" + +return + $eSciDocId \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/doc/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/doc/index.html Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,20 @@ + + +MPDL: document interface + + +

    MPDL: document interface

    +

    eXist document interface

    +

    Login to the eXist document interface here.

    +


    +If your user account is not active yet, please perform the following steps: +

      +
    • Initialize your account: login into eSciDoc with your MPIWG user account (e.g. User-Id: jwillenborg, Password: yourPassword): click here
    • +
    • Send an e-mail to Josef Willenborg with subject "MPDL document interface: get user rights"
    • +
    • Wait for an answer mail (this needs normally a few days)
    • +
    • Now you have the user rights to read, create, update and delete documents: login into the eXist document interface: click here
    • +
    +
    +If you find a bug let us know + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/doc/login-exist.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/doc/login-exist.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,61 @@ +xquery version "1.0"; + +import module namespace functx = "http://www.functx.com" at "../util/functx.xql"; + +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace response="http://exist-db.org/xquery/response"; +declare namespace session="http://exist-db.org/xquery/session"; + +declare variable $docOperationExistUrlStr { "http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/doc/doc-operation-exist.xql"}; +declare variable $redirect-uri as xs:anyURI { xs:anyURI($docOperationExistUrlStr) }; + +declare function local:login($userName as xs:string, $password as xs:string) { + let $eSciDocCookieId := mpdldoc:escidoc-login($userName, $password) + return + if ($eSciDocCookieId = '' or empty($eSciDocCookieId)) + then +

    Login failed: User/password is not correct.

    + else if ($eSciDocCookieId = '-10') + then +

    Login failed: Your user account has not enough user rights for the MPDL document management. Please send an e-mail to Josef Willenborg with subject "MPDL document interface: get user rights"

    + else + ( + session:set-attribute("userName", $userName), + session:set-attribute("eSciDocCookieId", $eSciDocCookieId), + response:redirect-to(session:encode-url($redirect-uri)) + ) +}; + +declare function local:do-login() { + let $userName := request:get-parameter("userName", "") + let $password := request:get-parameter("password", "") + return + if ($userName = '') then + '' + else + local:login($userName, $password) +}; + +session:invalidate(), +session:create(), + +let $title := "MPDL: eXist document management" +return + + +{$title} + + +

    {$title}

    +
    + + User name:

    + Password:

    + +

    +
    + { local:do-login() } +
    + See the XQuery source of this page, if you find a bug let us know + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/doc/login.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/doc/login.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,61 @@ +xquery version "1.0"; + +import module namespace functx = "http://www.functx.com" at "../util/functx.xql"; + +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace response="http://exist-db.org/xquery/response"; +declare namespace session="http://exist-db.org/xquery/session"; + +declare variable $docOperationExistUrlStr { "http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/doc/doc-operation.xql"}; +declare variable $redirect-uri as xs:anyURI { xs:anyURI($docOperationExistUrlStr) }; + +declare function local:login($userName as xs:string, $password as xs:string) { + let $eSciDocCookieId := mpdldoc:escidoc-login($userName, $password) + return + if ($eSciDocCookieId = '' or empty($eSciDocCookieId)) + then +

    Login failed: User/password is not correct.

    + else if ($eSciDocCookieId = '-10') + then +

    Login failed: Your user account has not enough user rights for the MPDL document management. Please send an e-mail to Josef Willenborg with subject "MPDL document interface: get user rights"

    + else + ( + session:set-attribute("userName", $userName), + session:set-attribute("eSciDocCookieId", $eSciDocCookieId), + response:redirect-to(session:encode-url($redirect-uri)) + ) +}; + +declare function local:do-login() { + let $userName := request:get-parameter("userName", "") + let $password := request:get-parameter("password", "") + return + if ($userName = '') then + '' + else + local:login($userName, $password) +}; + +session:invalidate(), +session:create(), + +let $title := "MPDL: eXist/eSciDoc document management" +return + + +{$title} + + +

    {$title}

    +
    + + User name:

    + Password:

    + +

    +
    + { local:do-login() } +
    + See the XQuery source of this page, if you find a bug let us know + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/escidoc/controller.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/escidoc/controller.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,25 @@ +xquery version "1.0"; + +(: Controller for the eSciDoc REST interface :) + +let $bla := "" + +return +if (starts-with($exist:path, '/ir/')) then + + + + + +else if (contains($exist:path, '/exist:xquery/execute')) then + + + + + +else + (: everything else is passed through :) + + + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/2downarrow.png Binary file software/eXist/webapp/mpdl/images/2downarrow.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/2leftarrow.png Binary file software/eXist/webapp/mpdl/images/2leftarrow.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/2rightarrow.png Binary file software/eXist/webapp/mpdl/images/2rightarrow.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/2uparrow.png Binary file software/eXist/webapp/mpdl/images/2uparrow.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/book-pointer.gif Binary file software/eXist/webapp/mpdl/images/book-pointer.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/book.png Binary file software/eXist/webapp/mpdl/images/book.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/camera.png Binary file software/eXist/webapp/mpdl/images/camera.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/copyleft.png Binary file software/eXist/webapp/mpdl/images/copyleft.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/dictionary.gif Binary file software/eXist/webapp/mpdl/images/dictionary.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/dictionaryMorph.gif Binary file software/eXist/webapp/mpdl/images/dictionaryMorph.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/dot.gif Binary file software/eXist/webapp/mpdl/images/dot.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/download.png Binary file software/eXist/webapp/mpdl/images/download.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/echo.gif Binary file software/eXist/webapp/mpdl/images/echo.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/figures.png Binary file software/eXist/webapp/mpdl/images/figures.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/help.png Binary file software/eXist/webapp/mpdl/images/help.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/image.jpg Binary file software/eXist/webapp/mpdl/images/image.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/imageU.jpg Binary file software/eXist/webapp/mpdl/images/imageU.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/info.png Binary file software/eXist/webapp/mpdl/images/info.png has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/left.gif Binary file software/eXist/webapp/mpdl/images/left.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/malcolm.jpg Binary file software/eXist/webapp/mpdl/images/malcolm.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/malcolm.tif Binary file software/eXist/webapp/mpdl/images/malcolm.tif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/pirate-joey.gif Binary file software/eXist/webapp/mpdl/images/pirate-joey.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/right.gif Binary file software/eXist/webapp/mpdl/images/right.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/search.gif Binary file software/eXist/webapp/mpdl/images/search.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/searchMorph.gif Binary file software/eXist/webapp/mpdl/images/searchMorph.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/searchStructural.gif Binary file software/eXist/webapp/mpdl/images/searchStructural.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/searchXPath.gif Binary file software/eXist/webapp/mpdl/images/searchXPath.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/text.jpg Binary file software/eXist/webapp/mpdl/images/text.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/textPollux.jpg Binary file software/eXist/webapp/mpdl/images/textPollux.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/textPolluxU.jpg Binary file software/eXist/webapp/mpdl/images/textPolluxU.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/textU.jpg Binary file software/eXist/webapp/mpdl/images/textU.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/toc.gif Binary file software/eXist/webapp/mpdl/images/toc.gif has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/xml.jpg Binary file software/eXist/webapp/mpdl/images/xml.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/images/xmlU.jpg Binary file software/eXist/webapp/mpdl/images/xmlU.jpg has changed diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/index.html Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,10 @@ + + + +MPDL prototype + + +

    MPDL prototype

    +please click here + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/info.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/info.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,81 @@ +xquery version "1.0"; + +declare namespace request="http://exist-db.org/xquery/request"; + +let $info := request:get-parameter("info", "") (: default: no info :) + +let $infoTitle := + if ($info = '') + then () + else if ($info = 'mpdl') + then 'MPDL prototype' + else if ($info = 'docBases') + then 'MPDL documents' + else if ($info = 'fulltextMorph') + then 'Morphological search' + else if ($info = 'fulltext') + then 'Fulltext search' + else if ($info = 'xpath') + then 'Xpath' + else if ($info = 'xquery') + then 'XQuery' + else if ($info = 'pollux') + then 'MPDL Pollux service.' + else if ($info = 'wordInfo') + then 'MPDL language technology: Word information.' + else () + +let $infoText := + if ($info = '') + then () + else if ($info = 'mpdl') + then ('The prototype is based on eXist/Lucene technology. It is implemented in XQuery/XPath, XSL and Java. Also eXist itself is extended a little. All software is open source under the LGPL license ', lgpl,

    , 'The MPDL project is funded by the ', Max Planck Institute for the History of Science, '.',

    , 'More information about the MPDL project could be found ', here, '.',

    , 'And that is the guy who is the developer of that stuff: ',

    pirate

    ) + else if ($info = 'malcolm') + then (

    Malcolm HymanDr. Malcolm Hyman
    † September 4, 2009

    ,

    In memoriam

    , 'This software is dedicated to Malcolm Hyman, who was the founder and leader of this project. He died suddenly and unexpectedly. This project owes everything to him.',

    His homepages

    , ) + else if ($info = 'docBases') + then (Archimedes DTD (until 2008): , 'more than 120 documents (4KB - 18MB), coming from Echo collections "Archimedes" and "Historical Travel Guides", languages: latin, italian, english, german, french, dutch, greek, arabic, chinese',
    ,
    , Echo Schema (since2009): , 'planned more than 100 documents in different languages') + else if ($info = 'attr') + then ('Attribute search is case sensitive.',

    , 'Query syntax see: ', Lucene query syntax, '.') + else if ($info = 'fulltextMorph') + then ('Morphological index is built up by ', Donatus, ' and ', Snowball, '. It is case insensitive.',

    , 'Query syntax see: ', Lucene query syntax, '.') + else if ($info = 'fulltext') + then ('Fulltext index is a case sensitive word index. It should be used especially for wildcard searching (with * and ?).',

    , 'Query syntax see: ', Lucene query syntax, '.') + else if ($info = 'xpath') + then (

    XPath queries are executed against its context (a path relative to the context). The context is the document from which the XPath query is executed.

    ,

    Example: /archimedes/info/author finds only the author of the document from which the query is executed (and not of all documents). XPath queries are namespace aware.

    ,

    References: XPath Language 2.0, see: here.

    ) + else if ($info = 'xquery') + then (

    XQueries are executed against its context (a path relative to the context). The context is the document from which the XQuery is executed. XQueries are namespace aware.

    ,

    Example 1: return all echo:metadata entries of current document
    let $result := //echo:metadata/*
    return $result

    ,

    Example 2: count words of first 3 sentences of current document:
    let $s := //echo:s
    let $first3s := $s[position() < 4]
    let $first3Str := string-join($first3s, ' ')
    let $wordCounter := count(tokenize($first3Str, '\W+')[. != ''])
    return $wordCounter

    ,

    If you want to query over many documents you could do this for example by specifying the document collection and using an XPath expression relative from this collection:

    ,

    Example 3 (XQuery over all documents): return all authors of all archimedes documents ordered
    let $coll := collection('/db/mpdl/documents/standard/archimedes')
    let $result := $coll/archimedes/info/author
    let $orderedResult :=
      for $elem in $result
      order by $elem
      return $elem
    return $orderedResult

    ,

    References: XQuery Language 1.0, see here, Wikipedia article, eXist functions, see here

    ) + else if ($info = 'pollux') + then (

    MPDL Pollux service.

    ,

    Following dictionaries are supported

    ,
    • Autenrieth, a Homeric lexicon (10158 entries)
    • Baretti, a dictionary of the English and Italian languages (53555 entries)
    • Bonitz, index Aristotelicus (14648 entries)
    • Cooper, Thesaurus Linguae Romanae et Brittanicae (33124 entries)
    • Florio, a worlde of wordes, or most copious, dictionarie in Italian and English (70091 entries)
    • Lewis and Short, Latin dictionary (53500 entries)
    • Liddell-Scott-Jones, a Greek-English lexicon (112631 entries)
    • Salmoné, an advanced learner's Arabic-English dictionary (6360 entries)
    • Webster's revised unabridged dictionary - 1913 (111733 entries)
    ) + else if ($info = 'wordInfo') + then (

    Morphology information: MPDL Donatus and Snowball.

    ,

    Following morphological data is used and provided

    ,
    • Perseus
      • arabic: 97.249 forms
      • greek: 1.020.846 forms
      • latin: 710.620 forms
    • Celex
      • dutch: 381.275 forms and 124.136 lemmas
      • english: 160.595 forms and 52.447 lemmas
      • german: 365.530 forms and 51.728 lemmas
    • Lexique
      • french: 306.795 forms
    ,

    Dictionary information: MPDL Pollux

    ,

    Following internal dictionaries are provided

    ,
    • Autenrieth, a Homeric lexicon (10158 entries)
    • Baretti, a dictionary of the English and Italian languages (53555 entries)
    • Bonitz, index Aristotelicus (14648 entries)
    • Cooper, Thesaurus Linguae Romanae et Brittanicae (33124 entries)
    • Florio, a worlde of wordes, or most copious, dictionarie in Italian and English (70091 entries)
    • Lewis and Short, Latin dictionary (53500 entries)
    • Liddell-Scott-Jones, a Greek-English lexicon (112631 entries)
    • Salmoné, an advanced learner's Arabic-English dictionary (6360 entries)
    • Webster's revised unabridged dictionary - 1913 (111733 entries)
    ,

    Following external dictionaries are provided

    ,
    • Deutsches Wörterbuch der deutschen Sprache
    • William J. Slater, Lexicon to Pindar
    • The ARTFL project: Dictionnaires d'autrefois: French dictionaries of the 17th, 18th, 19th and 20th centuries
    • The ARTFL project: French - English dictionary
    • Charlton T. Lewis, an Elementary Latin Dictionary
    • Wiktionary: WikiWoordenboek
    • Lin Yutang
    ,

    Wikipedia information: MPDL Wiki

    ,

    Links to following Wikipedia servers are provided

    ,
    • ar.wikipedia.org
    • de.wikipedia.org
    • el.wikipedia.org
    • en.wikipedia.org
    • fr.wikipedia.org
    • it.wikipedia.org
    • la.wikipedia.org
    • nl.wikipedia.org
    • zh.wikipedia.org
    ,

    Place information

    ,

    Place links in Echo texts are supported. Place dictionaries are not yet implemented

    ) + else if ($info = 'donatus') + then (

    MPDL Donatus and Snowball service.

    ,

    At this time following morphological data is used and provided

    ,
    • Perseus
      • arabic: 97.249 forms
      • greek: 1.020.846 forms
      • latin: 710.620 forms
    • Celex
      • dutch: 381.275 forms and 124.136 lemmas
      • english: 160.595 forms and 52.447 lemmas
      • german: 365.530 forms and 51.728 lemmas
    • Lexique
      • french: 306.795 forms
    ) + else if ($info = 'docInterfaceOperation') + then (

    MPDL document interface: Operation
    Please do not overload the system by executing too many document operations at the same time. Please finish one document operation after the other. Look into the status of your document operation (each one has a job id) and see if it is finished (job status finished has a time stamp). Then start another operation.

    ) + else if ($info = 'docInterfaceSource') + then (

    MPDL document interface: Source document
    The source document has to be a valid XML-document against either the Echo schema (see the Echo Relax NG Schema) or against the Archimedes document format

    ) + else if ($info = 'docInterfaceDestDocName') + then (

    MPDL document interface: Destination document name

    • has to be unique within a document base and a language. If you use a name which is already used - please look in the documents list (on the right side) - it will be updated (not created).
    • always needs the extension ".xml".
    • example: "Benedetti_1585.xml"

    ) + else () + + +return + + +MPDL info + + + + + + + + + +
    + Info MPDL +       + {$infoTitle} +
    {$infoText}
    + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/doc-query.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/doc-query.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,150 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../util/time.xql"; +import module namespace functx = "http://www.functx.com" at "../util/functx.xql"; +import module namespace mpdl-lucene = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/lucene/search" at "../lucene/search.xql"; +import module namespace mpdl-text = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/text" at "../text/all.xql"; + +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace transform = "http://exist-db.org/xquery/transform"; +declare namespace util = "http://exist-db.org/xquery/util"; + +declare namespace dcterms="http://purl.org/dc/terms"; +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; + +let $mpdlDocUri := request:get-parameter("document", "") +let $mode := request:get-parameter("mode", "image") +let $queryType := request:get-parameter("queryType", "") +let $query := request:get-parameter("query", "") +let $reqQueryResultPageSize := request:get-parameter("queryResultPageSize", "") +let $queryResultPageSize := + if ($reqQueryResultPageSize = '' or $reqQueryResultPageSize = '0') + then 100 + else number($reqQueryResultPageSize) +let $reqQueryResultPN := request:get-parameter("queryResultPN", "") +let $queryResultPN := + if ($reqQueryResultPN = '' or $reqQueryResultPN = '0') + then 1 + else number($reqQueryResultPN) + +let $presentationPath := "/db/mpdl/presentation" +(: e.g. mpdlCollectioName is derived from mpdlDocUri: /archimedes/la/yourDoc.xml :) +let $documentName := substring-before(substring-after(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/"), ".") +let $language := substring-before(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/") +let $docbase := substring-before(substring-after($mpdlDocUri, "/"), "/") +let $fullDocumentUri := + if ($queryType = 'fulltext' or $queryType = 'ftIndex') + then concat('/db/mpdl/documents/standard', $mpdlDocUri) + else if ($queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma' or $queryType = 'ftIndexMorph') + then concat('/db/mpdl/documents/morph', $mpdlDocUri) + else concat('/db/mpdl/documents/morph', $mpdlDocUri) +let $currentTimeBegin := util:system-time() +let $documentAvailable := doc-available($fullDocumentUri) +let $document := doc($fullDocumentUri) +let $metadata := + if ($docbase = 'archimedes') + then $document/archimedes/info + else if ($docbase = 'echo') + then $document/echo:echo/echo:metadata + else '' + +(: xQuery inline execution does not work in module so it has to be done here :) +let $xQueryPageSize := 100 +let $xQueryResultEval := + if ($queryType = 'xpath' or $queryType = 'xquery' and $query != "") + then util:eval-inline($document, $query) + else () +let $xQueryFrom := ($queryResultPN * $xQueryPageSize) - $xQueryPageSize + 1 +let $xQueryTo := $queryResultPN * $xQueryPageSize +let $xQueryResultEntries := + for $entry at $pos in $xQueryResultEval + where $pos >= $xQueryFrom and $pos <= $xQueryTo + return $entry +let $xQuerySize := count($xQueryResultEval) +let $xQueryPages := + if ($xQuerySize = 0) + then 0 + else $xQuerySize idiv $xQueryPageSize + 1 +let $xQueryResult := + + {$xQuerySize} + {$xQueryPageSize} + {$xQueryPages} + {$queryResultPN} + {$xQueryResultEntries} + + +let $queryResult := + if (($queryType = 'fulltext' or $queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma') and $query != "") + then mpdl-lucene:search($docbase, $language, $document, $queryType, $query, $queryResultPN, $queryResultPageSize) + else if (($queryType = 'ftIndex' or $queryType = 'ftIndexMorph') and $query != "") + then mpdl-text:indexTerms($docbase, $language, $document, $query, $queryResultPN, $queryResultPageSize) + else if ($queryType = 'xpath' or $queryType = 'xquery' and $query != "") + then $xQueryResult + else if ($queryType = 'toc' or $queryType = 'figures') + then mpdl-text:get-toc($docbase, $queryType, $document, $queryResultPN, $queryResultPageSize) + else if ($query = "") + then + + 0 + 0 + 0 + 0 + + + else () + +let $countHits := count($queryResult/result/hits/hit) +let $firstHit := $queryResult/result/hits/hit[1] + +(: 10 or more is an error :) +let $errorCode := + if (not($documentAvailable)) + then 10 + else 0 + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $xmlResult := + if ($errorCode < 10) + then + + + {$mpdlDocUri} + {$docbase} + {$documentName} + {$language} + + + {$mode} + + + {$queryType} + {$query} + {$queryResult} + + {$neededTime} + + else if ($errorCode = 10) + then {$errorCode}Fulltext document: {$mpdlDocUri} is not available yet + else {$errorCode}undefined error: {$errorCode} + +let $declare := + if ($mode = "text" or $mode = "textPollux" or $mode = "image" or $mode = "xml") + then util:declare-option("exist:serialize", "method=html media-type=text/html omit-xml-declaration=no indent=yes encoding=utf-8") + else if ($mode = "pureXml") + then util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") + else util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") +let $xslFilePath := + if($mode = "text" or $mode = "textPollux" or $mode = "image" or $mode = "xml") + then concat($presentationPath, "/queryHtml.xsl") + else concat($presentationPath, "/pageXml.xsl") +let $xslDoc := doc($xslFilePath) +let $result := + if($errorCode < 10) + then transform:transform($xmlResult, $xslDoc, ()) + else +
    {$xmlResult}
    (: error xml result :) + +return $result \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/echo/controller.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/echo/controller.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,25 @@ +xquery version "1.0"; + +(: Controller XQuery for the mpdl application. :) + +declare namespace dcterms="http://purl.org/dc/terms"; +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; + + +let $mpdlDocUri := "/archimedes/it/borro_fluss_012_it_1561.xml" +(: let $echoArchivePath := mpdl-text:getEchoArchivePath($mpdlDocUri) :) +let $echoURLDocuView := concat("http://echo.mpiwg-berlin.mpg.de/ECHOdocuView?url=", '') + +return +if (starts-with($exist:path, '/docuView.xql')) +then + + + +(: :) +(: :) +else + (: everything else is passed through :) + + + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/echo/echoDocuView.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/echo/echoDocuView.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,35 @@ +xquery version "1.0"; + +import module namespace request="http://exist-db.org/xquery/request"; + +import module namespace mpdl-text = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/text" at "../..//text/all.xql"; + +let $mpdlDocUri := request:get-parameter("document", ()) +let $echoArchivePath := mpdl-text:getEchoArchivePath($mpdlDocUri) +let $echoURLDocuView := concat("http://mpdl-dev.mpiwg-berlin.mpg.de/ECHOdocuView?url=", $echoArchivePath) +let $urlDocuViewer := redirect to Echo +let $diglibAvailable := + if ($echoArchivePath = "XXXXDigilibNotAvailableXXXX") + then false() + else true() +let $metaRefresh := + if ($diglibAvailable) + then + else () +let $message := + if ($diglibAvailable) + then Url: {$urlDocuViewer} + else Could not open Echo Docu Viewer: nausikaa2.rz-berlin.mpg.de does not answer for {$mpdlDocUri}: please try again later + +return + + + Redirector Echo Docu Viewer + {$metaRefresh} + + +

    Redirector Echo Docu Viewer

    + {$message} + + + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/external/object.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/external/object.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,19 @@ +xquery version "1.0"; + +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace response="http://exist-db.org/xquery/response"; +declare namespace session="http://exist-db.org/xquery/session"; +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; + +let $operation := request:get-parameter("operation", "") +let $type := request:get-parameter("type", "") +let $uid := request:get-parameter("uid", "") +let $document := request:get-parameter("document", "") +let $pn := request:get-parameter("pn", "-1") +let $xpath := request:get-parameter("xpath", "") +let $charPosition := request:get-parameter("charPosition", "") +let $externalObject := request:get-parameter("externalObject", "") + +let $result := mpdltext:externalObject($operation, $type, $uid, $document, $pn, $xpath, $charPosition, $externalObject) + +return $result \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/lt/lemma.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/lt/lemma.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,63 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../../util/time.xql"; + +declare namespace request="http://exist-db.org/xquery/request"; + +let $language := request:get-parameter("language", "") +let $lemmaName := request:get-parameter("lemma", "") +let $formName := request:get-parameter("form", "") +let $luceneQuery := request:get-parameter("query", "") + +let $currentTimeBegin := util:system-time() + +let $lemmas := + if ($formName != '') + then mpdltext:get-lemmas-by-form-name($language, $formName) + else if ($lemmaName != '') + then mpdltext:get-lemma($language, $lemmaName) + else mpdltext:get-lemmas-by-lucene-query($language, $luceneQuery) +let $orderedLemmas := + if (empty($lemmas)) + then ("no lemmas found for your query") + else + for $lemma in $lemmas/lemmas/lemma + let $lemmaText := concat($lemma/lemma-name, " (", $lemma/provider, ")") + let $orderedForms := + for $form in $lemma/forms/form + let $formNameText := $form/form-name + let $providerText := $form/provider + let $liForm :=
  • {$formNameText} ({$providerText})
  • + order by $form/form-name + return $liForm + let $lemmaLi := +
  • Lemma: {$lemmaText} +
      {$orderedForms}
    +
  • + order by $lemma/lemma-name + return $lemmaLi + +let $queryResultHeaderStr := + if ($formName != '') + then

    Mpdl-Donatus: Lemmas and forms: Result of your query: Language={$language}, Form={$formName}

    + else if ($lemmaName != '') + then

    Mpdl-Donatus: Lemmas and forms: Result of your query: Language={$language}, Lemma={$lemmaName}

    + else

    Mpdl-Donatus: Lemmas and forms: Result of your query: Language={$language}, Query={$luceneQuery}

    + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $retHtmlResult := + + + Lemmas and forms + + + {$queryResultHeaderStr} +

    + {$orderedLemmas} +

    + + + +return $retHtmlResult \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/lt/lex.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/lt/lex.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,42 @@ +xquery version "1.0"; + +declare namespace request="http://exist-db.org/xquery/request"; + +let $language := request:get-parameter("language", "") +let $formName := request:get-parameter("form", "") +let $luceneQuery := request:get-parameter("query", "") + +let $lexica := + if ($formName != '') + then mpdltext:get-lex-entries-by-form-name($language, $formName) + else mpdltext:get-lex-entries-by-lucene-query($language, $luceneQuery) +let $htmlLexica := + if (empty($lexica)) + then ("no lexical entries found for your query") + else + for $lexicon in $lexica/lexica/lexicon + let $lexDescription := $lexicon/description + let $lexEntries := $lexicon/entries + let $liLexEntryContent := + for $lexEntry in $lexicon/entries/entry + let $lexEntryContent := $lexEntry/content + let $lexEntryXmlValid := $lexEntryContent/xml-valid + let $lexEntryOriginalContent := $lexEntryContent/original-entry + let $lexEntryRepairedContent := $lexEntryContent/repaired-entry + let $lexEntryContentParsed := + if ($lexEntryXmlValid = "true") + then util:parse($lexEntryRepairedContent) + else [Remark: lexical entry in lexicon has no valid XML, so only the Betacode text version of the entry could be displayed]

    {$lexEntryOriginalContent} + return
  • {($lexEntryContentParsed)}
  • + let $lexiconLi := +
  • {$lexDescription} +
      {$liLexEntryContent}
    +
  • + return $lexiconLi + +let $retHtmlResult := +
    + {$htmlLexica} +
    + +return $retHtmlResult \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/lt/wordInfo.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/lt/wordInfo.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,405 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../../util/time.xql"; + +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace xlink="http://www.w3.org/1999/xlink"; + +(: TODO: Verlinkung von lemma, form, weiteren Einheiten in den Infos auf mpdl-proto (HTML und XML) :) + +let $type := request:get-parameter("type", "all") +let $language := request:get-parameter("language", "") +let $word := request:get-parameter("word", "") +let $placeHref := request:get-parameter("placeHref", "") +let $output := request:get-parameter("output", "xml") + +let $currentTimeBegin := util:system-time() + +let $lemmas := mpdltext:get-lemmas-by-form-name($language, $word) +let $htmlOrderedLemmas := + if (empty($lemmas)) + then ("no lemmas found for your query") + else + for $lemma in $lemmas/lemmas/lemma + let $lemmaText := concat($lemma/lemma-name, " (", $lemma/provider, ")") + let $orderedFormsStrTmp := + for $form in $lemma/forms/form + let $formStr := concat($form/form-name, " (", $form/provider, ")") + order by $form/form-name + return $formStr + let $orderedFormsStr := string-join($orderedFormsStrTmp, ", ") + let $remotePerseusLink := + if ($language = "ar" or $language = "la") + then concat("http://www.perseus.tufts.edu/hopper/morph?l=", $lemma/lemma-name, "&la=", $language) + else if ($language = "el") + then concat("http://www.perseus.tufts.edu/hopper/morph?l=", $lemma/lemma-name, "&la=greek") + else "" + let $lemmaLi := + if ($language = "ar" or $language = "el" or $language = "la") + then +
  • Lemma: {$lemmaText} (see this entry in www.perseus.tufts.edu) +
      {$orderedFormsStr}
    +
  • + else +
  • Lemma: {$lemmaText} +
      {$orderedFormsStr}
    +
  • + order by $lemma/lemma-name + return $lemmaLi +let $xmlOrderedLemmas := + for $lemma in $lemmas/lemmas/lemma + let $orderedForms := + for $form in $lemma/forms/form + order by $form/form-name + return $form + let $retLemma := + + {$lemma/provider} + {$lemma/language} + {$lemma/lemma-name} + {$orderedForms} + + order by $lemma/lemma-name + return $retLemma +let $lemmasStrTmpTmp := + if (empty($lemmas)) + then "" + else + for $lemma in $lemmas/lemmas/lemma + let $lemmaStr := $lemma/lemma-name + order by $lemma/lemma-name + return $lemmaStr +let $lemmasStrWithoutWord := string-join($lemmasStrTmpTmp, " ") +let $lemmasStrTmp := + if (not(contains($lemmasStrWithoutWord, $word))) + then concat($word, " ", $lemmasStrWithoutWord) (: also the form itself is added :) + else $lemmasStrWithoutWord +let $lemmasStr := + if ($language = "de" and (contains($lemmasStrTmp, "ae") or contains($lemmasStrTmp, "oe") or contains($lemmasStrTmp, "ue") or contains($lemmasStrTmp, "ss"))) + then replace(replace(replace(replace($lemmasStrTmp, "ae", "ä"), "oe", "ö"), "ue", "ü"), "ss", "ß") + else $lemmasStrTmp +let $lemmasStrTokenized := tokenize($lemmasStr, " ") + +let $dictionariesLocal := + if ($type = "all" or $type = "dict") + then mpdltext:get-lex-entries-by-lucene-query($language, $lemmasStr) + else () +let $dictionariesRemoteTmp := + if ($language = "de") + then + + + dwds + Deutsches Wörterbuch der deutschen Sprache + + + else if ($language = "el") + then + + + slater + William J. Slater, Lexicon to Pindar + + + else if ($language = "fr") + then + + + artfl-fr + The ARTFL project: Dictionnaires d'autrefois: French dictionaries of the 17th, 18th, 19th and 20th centuries + + + artfl-fr-en + The ARTFL project: French - English dictionary + + + else if ($language = "la") + then + + + lewis + Charlton T. Lewis, an Elementary Latin Dictionary + + + else if ($language = "nl") + then + + + wikiwoordenboek + Wiktionary: WikiWoordenboek + + + else if ($language = "zh") + then + + + linyutan + Lin Yutang + + + else () + +let $dictionariesRemote := + for $lex in $dictionariesRemoteTmp//lexicon + let $lexName := $lex/name + let $lexEntries := + for $l in $lemmasStrTokenized + let $lLink := + if ($language = "el") + then mpdltext:transcode("unicode", "betacode", $l) + else if ($language = "zh") + then mpdltext:encode-big5($l) + else $l + let $repairedEntryContentLink := + if ($lexName = "dwds") + then concat("http://beta.dwds.de/?qu=", $l) + else if ($lexName = "slater") + then concat("http://www.perseus.tufts.edu/hopper/text?doc=Perseus:text:1999.04.0072:entry=", $lLink) + else if ($lexName = "artfl-fr-en") + then concat("http://machaut.uchicago.edu/?resource=frengdict&action=search&french=", $l) + else if ($lexName = "artfl-fr") + then concat("http://artflx.uchicago.edu/cgi-bin/dicos/pubdico1look.pl?strippedhw=", $l) + else if ($lexName = "lewis") + then concat("http://www.perseus.tufts.edu/hopper/text?doc=Perseus:text:1999.04.0060:entry=", $l) + else if ($lexName = "wikiwoordenboek") + then concat("http://nl.wiktionary.org/wiki/", $l) + else if ($lexName = "linyutan") + then concat("http://humanum.arts.cuhk.edu.hk/cgi-bin/agrep-lindict?query=", $lLink, "&category=wholerecord") + else "" + let $lexiconEntry := + +
    {$l}
    + + true + <original-entry></original-entry> + {$l} + +
    + return $lexiconEntry + return + + + {$lex/name} + {$lex/description} + {$lexEntries} + + + +let $dictionaries := + + + {$dictionariesLocal//lexicon} + {$dictionariesRemote//lexicon} + + +let $retDictionaries := + if (empty($dictionaries)) + then () + else + for $dictionary in $dictionaries/lexica/lexicon + let $dictName := $dictionary/name + let $dictDescription := $dictionary/description + let $dictEntries := $dictionary/entries + let $entryDictEntryContent := + for $dictEntry in $dictionary/entries/entry + let $dictEntryContent := $dictEntry/content + let $dictEntryXmlValid := $dictEntryContent/xml-valid + let $dictEntryOriginalContent := $dictEntryContent/original-entry + let $dictEntryRepairedContent := $dictEntryContent/repaired-entry + let $dictEntryRepairedContentLink := $dictEntryRepairedContent/directLink + let $dictEntryForm := + if ($language = "el") + then mpdltext:transcode("unicode", "betacode", string($dictEntry/form)) + else if ($language = "ar") + then mpdltext:transcode("unicode", "buckwalter", string($dictEntry/form)) + else $dictEntry/form + let $dictEntryContentParsedTmp := + if ($dictEntryXmlValid = "true" and empty($dictEntryRepairedContentLink)) + then util:parse($dictEntryRepairedContent) + else if ($dictEntryXmlValid = "true" and not(empty($dictEntryRepairedContentLink)) and $output = "html") + then + else if ($dictEntryXmlValid = "true" and not(empty($dictEntryRepairedContentLink)) and $output = "xml") + then
    {$dictEntryRepairedContentLink}
    + else [Remark: entry in dictionary has no valid XML, so only the Betacode text version of the entry could be displayed]

    {$dictEntryOriginalContent}
    + let $dictEntryContentParsed := + if ($dictionary/name = "ls" and $output = "html") + then
    {$dictEntryContentParsedTmp}
    (external link to www.perseus.tufts.edu)
    + else if ($dictionary/name = "ls" and $output = "xml") + then
    {$dictEntryContentParsedTmp}www.perseus.tufts.edu
    + else if ($dictionary/name = "lsj" and $output = "html") + then
    {$dictEntryContentParsedTmp}
    (external link to www.perseus.tufts.edu)
    + else if ($dictionary/name = "lsj" and $output = "xml") + then
    {$dictEntryContentParsedTmp}www.perseus.tufts.edu
    + else if ($dictionary/name = "autenrieth" and $output = "html") + then
    {$dictEntryContentParsedTmp}
    (external link to www.perseus.tufts.edu)
    + else if ($dictionary/name = "autenrieth" and $output = "xml") + then
    {$dictEntryContentParsedTmp}www.perseus.tufts.edu
    + else if ($dictionary/name = "buckwalter" and $output = "html") + then
    {$dictEntryContentParsedTmp}
    (external link to www.perseus.tufts.edu)
    + else if ($dictionary/name = "buckwalter" and $output = "xml") + then
    {$dictEntryContentParsedTmp}www.perseus.tufts.edu
    + else if ($dictionary/name = "salmone" and $output = "html") + then
    {$dictEntryContentParsedTmp}
    (external link to www.perseus.tufts.edu)
    + else if ($dictionary/name = "salmone" and $output = "xml") + then
    {$dictEntryContentParsedTmp}www.perseus.tufts.edu
    + else $dictEntryContentParsedTmp + let $liDictEntryContentParsed := + if ($output = "html") + then
  • {($dictEntryContentParsed)}
  • + else if ($output = "xml") + then {($dictEntryContentParsed)} + else () + return $liDictEntryContentParsed + let $dictLi := + if ($output = "html") + then +
  • {$dictDescription} +
      {$entryDictEntryContent}
    +
  • + else if ($output = "xml") + then + + + {$dictName} + {$dictDescription} + {$entryDictEntryContent} + + + else () + return $dictLi + +let $wikiArticles := + if (empty($lemmas)) + then () + else + for $l in $lemmasStrTokenized + let $wikiHref1 := concat("http://", $language, ".wikipedia.org/wiki/", $l) + let $wikiHref2 := concat("http://", $language, ".wikipedia.org/wiki/index.php?search=", $l) + let $wikiArticle := + if ($output = "html") + then
  • Article: External link: {$l} (or search for {$l})
  • + else if ($output = "xml") + then +
    + {$l} + + +
    + else () + return $wikiArticle +let $places := + if ($placeHref != "" and $output = "html") + then
  • Place: External link: {$word}
  • + else if ($placeHref != "" and $output = "html") + then + + {$word} + + + else () + +let $dict := + if (not(empty($retDictionaries)) and ($type = "all" or $type = "dict") and $output = "html") + then +

    +

    Dictionary

    +
      {$retDictionaries}
    +

    + else if (empty($retDictionaries) and ($type = "all" or $type = "dict") and $output = "html") + then +

    +

    Dictionary

    +
      No information available
    +

    + else if (not(empty($retDictionaries)) and ($type = "all" or $type = "dict") and $output = "xml") + then $retDictionaries + else () +let $morph := + if (not(empty($htmlOrderedLemmas)) and ($type = "all" or $type = "morph") and $output = "html") + then +

    +

    Morphology

    +
      {$htmlOrderedLemmas}
    +

    + else if (empty($htmlOrderedLemmas) and ($type = "all" or $type = "morph") and $output = "html") + then +

    +

    Morphology

    +
      No information available
    +

    + else if (not(empty($htmlOrderedLemmas)) and ($type = "all" or $type = "morph") and $output = "xml") + then {$xmlOrderedLemmas} + else if ($type = "morph" and $output = "string") + then $lemmasStrWithoutWord + else () +let $wiki := + if (not(empty($wikiArticles)) and ($type = "all" or $type = "wiki") and $output = "html") + then +

    +

    Wikipedia

    +
      {$wikiArticles}
    +

    + else if (not(empty($wikiArticles)) and ($type = "all" or $type = "wiki") and $output = "xml") + then {$wikiArticles} + else () +let $place := + if (not(empty($places)) and ($type = "all" or $type = "place") and $output = "html") + then +

    +

    Place

    +
      {$places}
    +

    + else if (not(empty($places)) and ($type = "all" or $type = "place") and $output = "xml") + then {$places} + else () + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $declare := + if ($output = "html" or $output = "string") + then util:declare-option("exist:serialize", "method=html media-type=text/html omit-xml-declaration=no indent=yes encoding=utf-8") + else util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") + +let $queryResultHeaderStr :=

    Word information for: {$word}

    +let $commentExternalLinks := + "[* no guarantee for external links]" + +let $retXmlResult := + +
    {$word}
    + Max Planck Institute for the History of Science, Berlin + {$morph} + {$dict} + {$wiki} + {$place} +
    +let $retHtmlResult := + + + Mpdl: word information + + + + +
    [This is a MPDL language technology service] MPDL language technology service
    +

    + {$queryResultHeaderStr} + {$morph} + {$dict} + {$wiki} + {$place} + {$commentExternalLinks} +


    +

    + Elapsed time: {$neededTime} ms, see the XQuery documentation and the XQuery source of this page, if you find a bug let us know + + + +let $retResult := + if ($output = "html") + then $retHtmlResult + else if ($type = "morph" and $output = "string") + then $morph + else $retXmlResult +return $retResult \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/page-fragment.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/page-fragment.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,401 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../util/time.xql"; +import module namespace functx = "http://www.functx.com" at "../util/functx.xql"; +import module namespace mpdl-lucene = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/lucene/search" at "../lucene/search.xql"; +import module namespace mpdl-text = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/text" at "../text/all.xql"; + +declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace transform = "http://exist-db.org/xquery/transform"; +declare namespace util = "http://exist-db.org/xquery/util"; + +declare namespace dcterms="http://purl.org/dc/terms"; +declare namespace xhtml="http://www.w3.org/1999/xhtml"; +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; + +let $mpdlDocUri := request:get-parameter("document", "") +let $mode := request:get-parameter("mode", "image") + +let $reqPN := number(request:get-parameter("pn", "-1")) +let $reqPF := request:get-parameter("pf", "") +let $reqSN := number(request:get-parameter("sn", "-1")) +let $highlightQuery := request:get-parameter("highlightQuery", "") +let $regCharNorm := request:get-parameter("characterNormalization", "") +let $tmpCharNorm := string-join($regCharNorm, ',') +let $charNorm := + if($tmpCharNorm = "regPlusNorm") + then "reg,norm" + else $tmpCharNorm +let $reqExport := request:get-parameter("export", "") +let $options := string(request:get-parameter("options", "")) + +let $presentationPath := "/db/mpdl/presentation" +(: e.g. mpdlCollectioName is derived from mpdlDocUri: /archimedes/la/yourDoc.xml :) +let $documentName := substring-before(substring-after(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/"), ".") +let $language := substring-before(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/") +let $docbase := substring-before(substring-after($mpdlDocUri, "/"), "/") +let $fullDocumentUri := concat('/db/mpdl/documents/morph', $mpdlDocUri) +let $currentTimeBegin := util:system-time() +let $documentAvailable := doc-available($fullDocumentUri) +let $document := doc($fullDocumentUri) +let $metadata := + if ($docbase = 'archimedes') + then $document/archimedes/info + else if ($docbase = 'echo') + then $document/echo:echo/echo:metadata + else '' + +let $pageBreaks := + if ($docbase = 'archimedes') + then $document//pb + else if ($docbase = 'echo') + then $document//echo:pb + else $document//pb +let $countPagesTemp := count($pageBreaks) +let $countPages := + if ($countPagesTemp > 0) + then $countPagesTemp + else 1 + +(: for performance reasons: deliver count of gis places and toc/figure entries :) +let $gisPlaces := + if ($docbase = 'echo') + then $document//echo:place + else () +let $countGisPlaces := count($gisPlaces) +let $tocEntries := + if ($docbase = 'echo') + then $document//echo:div[@type = 'section' or @type = 'chapter'] + else () +let $figureEntries := + if ($docbase = 'echo') + then $document//echo:figure + else if ($docbase = 'archimedes') + then $document//figure + else () +let $countTocEntries := count($tocEntries) +let $countFigureEntries := count($figureEntries) + +(: jump to first pn and sn hit in fulltext mode :) +let $pn := + if ($reqPN = -1) + then 1 + else $reqPN +let $sn := $reqSN + +(: 10 or more is an error :) +let $errorCode := + if (not($documentAvailable)) + then 10 + else if ($countPagesTemp != 0 and ($pn > $countPagesTemp or $pn <= 0)) + then 11 + else if ($countPagesTemp = 0) + then 1 (: if no page break is found then the document should have exactly one page :) + else if (not($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml" or $mode = "pureXml")) + then 12 + else 0 + +let $pb1 := + if ($errorCode = 0) + then subsequence($pageBreaks, $pn, 1) + else if ($errorCode = 1) + then subsequence(mpdl-lucene:getText($docbase, $document), 1, 1) + else () +let $pb2 := + if ($errorCode = 0) + then subsequence($pageBreaks, $pn + 1, 1) + else if ($errorCode = 1) + then subsequence(mpdl-lucene:getText($docbase, $document), 2, 1) + else () +let $pageHeader := string($pb1/@rhead) +let $pageNumberOrig := string($pb1/@o) + +let $documentIdentifier := + if ($docbase = 'archimedes') + then $metadata/locator + else if ($docbase = 'echo') + then $metadata/dcterms:identifier + else $metadata/dcterms:identifier +let $echoDocIdentifier := + if ($documentIdentifier != '') + then substring-before(substring-after($documentIdentifier, "ECHO:"), ".") + else '' +let $echoURLZogilib := "http://echo.mpiwg-berlin.mpg.de/zogilib" +let $nausikaaURLScaler := "http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler" +let $nausikaaURLDlInfo := "http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/dlInfo-xml.jsp" +let $nausikaaURLTexter := "http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/servlet/Texter" +let $echoImageDir := + if ($docbase = 'archimedes') + then string($metadata/echodir) + else if ($docbase = 'echo') + then string($metadata/echo:echodir) + else '' +let $imagesDocDirectory := + if ($echoImageDir != '') + then $echoImageDir + else if ($docbase = 'archimedes') + then concat("/permanent/archimedes/", $documentName) + else if ($docbase = 'echo') + then concat("/permanent/library/", $echoDocIdentifier) + else '' +let $imagesDocDirectoryIndexMetaUrl := + if ($mode = "image" or $mode = "text" or $mode = "textPollux" or $mode = "gis") + then concat($nausikaaURLTexter, "?fn=", $imagesDocDirectory, "/index.meta") + else () +let $digilibAvailable := mpdldoc:check-uri($imagesDocDirectoryIndexMetaUrl, 2000) +let $imagesDocDirectoryIndexMeta := + if (($mode = "image" or $mode = "text" or $mode = "textPollux" or $mode = "gis") and $digilibAvailable) + then doc($imagesDocDirectoryIndexMetaUrl) + else () +let $pageImageDirectory := string($imagesDocDirectoryIndexMeta/resource/meta/texttool/image) +let $figuresImageDirectoryTemp := string($imagesDocDirectoryIndexMeta/resource/meta/texttool/figures) +let $figuresImageDirectory := + if ($figuresImageDirectoryTemp != '') + then $figuresImageDirectoryTemp + else concat(substring-before($pageImageDirectory, "pageimg"), "figures") +let $pageImageFileNameWithoutExtension := + if ($docbase = 'echo') + then concat("/", string($pb1/@file)) + else '' +let $imageFileName := + if ($reqPF = '') + then concat($imagesDocDirectory, "/", $pageImageDirectory, $pageImageFileNameWithoutExtension) + else $reqPF +let $imageEcho := {$echoURLZogilib}?fn={$imageFileName}&pn={$pn} +let $imageScaler := {$nausikaaURLScaler}?fn={$imageFileName}&pn={$pn} + +let $imageFileNameUrl := concat($nausikaaURLDlInfo, "?fn=", $imageFileName) +let $testImageResult := + if ($mode = 'image' and $digilibAvailable) + then doc($imageFileNameUrl) + else () +let $testImageResultParamImgFn := string($testImageResult//parameter[@name='img.fn']/@value) +let $imageIsAvailable := + if ($testImageResultParamImgFn = '' and $reqPF = '') + then 'false' + else 'true' + +let $positionOfFirstFigureAfterPB1 := + if ($docbase = 'archimedes') + then count($pb1/following::figure[1]/preceding::figure) + 1 + else if ($docbase = 'echo') + then count($pb1/following::echo:figure[1]/preceding::echo:figure) + 1 + else () + +let $pageFragmentTmp := + if ($mode = "image" or $errorCode > 9) + then () + else if ($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "xml" or $mode = "pureXml") + then util:get-fragment-between($pb1, $pb2, true()) + else () +(: replace the soft hyphen (Unicode character for 00AD) just before the line break by a normal hyphen :) +(: delete the hyphen just before the line break in case of options=withoutLBs :) +let $pageFragment := + if (($mode = "text" or $mode = "textPollux") and not(contains($options, "withoutLBs")) and contains($pageFragmentTmp, "­ 9) + then () + else if (($mode = "text" or $mode = "textPollux" or $mode = "gis") and $charNorm = "") + then mpdltext:normalizeChars('reg,norm', $language, $pageFragment) + else if (($mode = "xml" or $mode = "pureXml") and $charNorm = "") + then $pageFragment + else if (($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "xml" or $mode = "pureXml") and $charNorm != "") + then mpdltext:normalizeChars($charNorm, $language, $pageFragment) + else () +let $retPageFragment := + if ($mode = "image" or $errorCode > 9) + then () + else if ($mode = "text" or $mode = "gis" or $mode = "xml" or $mode = "pureXml") + then $pageFragmentNormalized + else if ($mode = "textPollux") + then mpdltext:dictionarize($pageFragmentNormalized, $language) + else () +let $returnPageFragmentTmp := util:parse($retPageFragment) (: returns a valid xml document for that string :) + +let $externalElementsTmpTmp := mpdltext:externalObject("read", "element", "", $mpdlDocUri, string($pn), "", "", "") +let $externalElementsTmp := + if(not($externalElementsTmpTmp = "")) + then util:parse($externalElementsTmpTmp) + else () +let $externalElements := $externalElementsTmp/result/element +let $containsExternalElements := + if(not(empty($externalElements))) + then true() + else false() +let $returnPageFragmentTmpp := + if (contains($options, "withXmlNodeId") or $containsExternalElements) + then mpdl-text:insertNodeIdAttribute($returnPageFragmentTmp/*[1]) + else $returnPageFragmentTmp + +let $returnPageFragment := + if($containsExternalElements) + then mpdl-text:insert($returnPageFragmentTmpp/*[1], $externalElements) + else $returnPageFragmentTmpp + +let $pageFigureAnchors := $returnPageFragment//anchor[@type = 'figure'] +let $pageFigures := + for $pageFigureAnchor in $pageFigureAnchors + let $href := string($pageFigureAnchor/@xlink:href) + let $pageFigureTmp := $document//echo:figure[@xlink:label = $href] + let $pageFigure := subsequence($pageFigureTmp, 1, 1) + return + $pageFigure +let $pageHandwrittenAnchors := $returnPageFragment//anchor[@type = 'handwritten'] +let $pageHandwritten := + for $pageHandwrittenAnchor in $pageHandwrittenAnchors + let $handwrittenHref := string($pageHandwrittenAnchor/@xlink:href) + let $pageHandwrittenTmp := $document//echo:handwritten[@xlink:label = $handwrittenHref] + let $pageHandwritten := subsequence($pageHandwrittenTmp, 1, 1) + return + $pageHandwritten +let $pageTableAnchors := $returnPageFragment//anchor[@type = 'table'] +let $pageTables := + for $pageTableAnchor in $pageTableAnchors + let $tableHref := string($pageTableAnchor/@xlink:href) + let $pageTableTmp := $document//xhtml:table[@xlink:label = $tableHref] + let $pageTable := subsequence($pageTableTmp, 1, 1) + return + $pageTable +let $pageNoteAnchors := $returnPageFragment//anchor[@type = 'note'] +let $pageNotes := + if ($docbase = "echo") + then + for $pageNoteAnchor in $pageNoteAnchors + let $noteHref := string($pageNoteAnchor/@xlink:href) + let $pageNoteTmp := $document//echo:note[@xlink:label = $noteHref] + let $pageNote := subsequence($pageNoteTmp, 1, 1) + return + $pageNote + else + $returnPageFragment//note + +(: Metadata handling: only metadata of the selected document is scanned :) +let $identifier := $documentIdentifier +let $authors := mpdl-lucene:getElementsByAttr($metadata, $docbase, "author") +let $titles := mpdl-lucene:getElementsByAttr($metadata, $docbase, "title") +let $places := mpdl-lucene:getElementsByAttr($metadata, $docbase, "place") +let $date := mpdl-lucene:getElementsByAttr($metadata, $docbase, "date") +let $rights := mpdl-lucene:getElementsByAttr($metadata, $docbase, "rights") +let $accessRights := mpdl-lucene:getElementsByAttr($metadata, $docbase, "accessRights") +let $licenses := mpdl-lucene:getElementsByAttr($metadata, $docbase, "license") +let $file := mpdl-lucene:getElementsByAttr($metadata, $docbase, "file") +let $translator := mpdl-lucene:getElementsByAttr($metadata, $docbase, "translator") +let $version := mpdl-lucene:getElementsByAttr($metadata, $docbase, "version") + +let $highlightQueryWordsTemp := + if ($highlightQuery != '') + then mpdltext:get-query-morph-forms($language, $highlightQuery) + else '' +let $highlightQueryRegularizations := + if ($highlightQuery != '') + then mpdltext:get-query-regularizations($language, $highlightQuery) + else '' +let $highlightQueryWords := + if ($highlightQueryWordsTemp != '' and $highlightQueryRegularizations = '') + then $highlightQueryWordsTemp + else if ($highlightQueryWordsTemp = '' and $highlightQueryRegularizations != '') + then $highlightQueryRegularizations + else if ($highlightQueryWordsTemp != '' and $highlightQueryRegularizations != '') + then concat($highlightQueryWordsTemp, '|', $highlightQueryRegularizations) + else () + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $xmlResult := + if ($errorCode < 10) + then + + + {$mpdlDocUri} + {$docbase} + {$documentName} + {$language} + {$authors} + {$titles} + {$places} + {$date} + {$identifier} + {$rights} + {$accessRights} + {$licenses} + {$file} + {$translator} + {$version} + {$countPages} + {$countGisPlaces} + {$countTocEntries} + {$countFigureEntries} + + + {$mode} + {$pn} +

    {$pageHeader}
    + {$pageNumberOrig} + {$sn} + {$digilibAvailable} + {$imageIsAvailable} + {$imageFileName} + {$imageEcho} + {$imageScaler} + ?document={$documentName}&pn={$pn}&mode=xml + {$imagesDocDirectory}/{$pageImageDirectory} + {$imagesDocDirectory}/{$figuresImageDirectory} + {$positionOfFirstFigureAfterPB1} + {$pageFigures} + {$pageHandwritten} + {$pageTables} + {$pageNotes} + + {$highlightQuery} + {$highlightQueryWords} + + {$returnPageFragment} + {$charNorm} + {$options} + + {$neededTime} + + else if ($errorCode = 10) + then {$errorCode}Fulltext document: {$mpdlDocUri} is not available yet + else if ($errorCode = 11) + then {$errorCode}No result: Page {$pn} not found + else if ($errorCode = 12) + then {$errorCode}View mode {$mode} not available + else {$errorCode}undefined error: {$errorCode} + +let $declare := + if ($errorCode > 9 or $mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml") + then util:declare-option("exist:serialize", "method=xhtml media-type=text/html omit-xml-declaration=no indent=yes encoding=utf-8") + else if ($mode = "pureXml") + then util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") + else util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") +let $xslFilePath := + if($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml") + then concat($presentationPath, "/pageFragmentHtml.xsl") + else concat($presentationPath, "/pageXml.xsl") + +let $titleStr := concat(string-join($authors, ', '), ". ", string-join($titles, ', '), ". ", string-join($places, ', '), " ", $date, ".") +let $tmpResult := + if ($errorCode < 10 and $reqExport = "pdf") + then mpdl-text:html2pdf($language, $xmlResult, $xslFilePath, $titleStr, $pn, $mode) + else if ($errorCode < 10 and not($reqExport = "pdf")) + then mpdl-text:transform($xmlResult, $xslFilePath) + else +
    {$xmlResult}
    (: error xml result :) +let $result := + if ($errorCode < 10 and $reqExport = "pdf") + then response:stream-binary($tmpResult, "application/pdf", concat($documentName, "-page", $pn, ".pdf")) + else $tmpResult + +let $setHeader := + if ($mode = "pureXml") + then response:set-header('Content-Disposition', concat('filename=', $documentName, '-page', $pn)) + else () + +return $result \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/queryResult.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/queryResult.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,261 @@ +xquery version "1.0"; + +import module namespace functx = "http://www.functx.com" at "../util/functx.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 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("queryType", "") +let $docbase := request:get-parameter("docbase", "") +let $output := request:get-parameter("output", "html") +let $attribute1 := request:get-parameter("attribute1", "") +let $relOp1 := request:get-parameter("relOp1", "") +let $attrQuery1 := request:get-parameter("attrQuery1", "") +let $boolOp := request:get-parameter("boolOp", "") +let $attribute2 := request:get-parameter("attribute2", "") +let $relOp2 := request:get-parameter("relOp2", "") +let $attrQuery2 := request:get-parameter("attrQuery2", "") +let $ftQuery := request:get-parameter("ftQuery", "") +let $ftMorphQuery := request:get-parameter("ftMorphQuery", "") +let $orderBy := request:get-parameter("orderBy", "") +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 $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 $fulltextMorphArchDocPath := concat($docPathMorph, "/", $docBaseArch, "/", $language) +let $fulltextMorphEchoDocPath := concat($docPathMorph, "/", $docBaseEcho, "/", $language) +let $fulltextMorphCollection := + if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho)) + then collection($fulltextMorphArchDocPath, $fulltextMorphEchoDocPath) + else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho))) + then collection($fulltextMorphArchDocPath) + else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho)) + then collection($fulltextMorphEchoDocPath) + else () + +let $fulltextStandardArchDocPath := concat($docPathStandard, "/", $docBaseArch) +let $fulltextStandardEchoDocPath := concat($docPathStandard, "/", $docBaseEcho) +let $fulltextStandardCollectionStr := + if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho)) + then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardEchoDocPath, "')") + else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho))) + then concat("collection('", $fulltextStandardArchDocPath, "')") + else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho)) + then concat("collection('", $fulltextStandardEchoDocPath, "')") + else () +let $metadataStr := concat("(", $fulltextStandardCollectionStr, "/archimedes/info", "|" , $fulltextStandardCollectionStr, "/echo:echo/echo:metadata", ")") +let $fulltextStandardCollection := util:eval($fulltextStandardCollectionStr) + +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() + +(: TODO: performance improvement: at this time the result is fully scanned 3 times (query, ordering, presentation) :) +let $attrQueryResult := + if ($queryType = "browse") + then $fulltextStandardCollection + else if ($queryType = "fulltext") + then mpdl-lucene:search($fulltextStandardCollection, $ftQuery) + else if ($queryType = "fulltextMorph") + then mpdl-lucene:search($fulltextMorphCollection, $ftMorphQuery) + else if ($isAttributeSearch) + 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 $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 $documentUri := substring-after($documentUriOrig, $docPath) + 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 $authors := string-join($authorElems, ', ') + let $titles := string-join($titleElems, ', ') + let $places := string-join($placeElems, ', ') + let $dates := string-join($dateElems, ', ') + let $resultElem := + if ($output = "html") + then + + {$pos}. + + Download + {$authors} + {$titles} + {$places} + {$dates} + + else if ($output = "xml") + then + + {$pos} + {$documentUri} + {$authors} + {$titles} + {$places} + {$dates} + + else () + where $pos >= $positionFrom and $pos <= $positionTo + return $resultElem + +let $attrQueryResultError := string($attrQueryResult/error) + +let $resultPageBody := + if ($attrQueryResultError = '' and $countResult > 0) + then +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {$pageResult} + +
    + + + + + + + + + +
    +
    + else if ($attrQueryResultError != '') + then (Your query delivers an error: , $attrQueryResultError) + else (Your query delivers no result) + +let $resultPage := + if ($output = "html") + then +
    + +
    + {$resultPageBody} +
    +
    + else if ($output = "xml") + then + + + {$queryType} + {$language} + {$docbase} + {$ftQuery} + {$ftMorphQuery} + + + {$countResult} + + {$pageSize} + {$pn} + {$pageResult} + + + + else () +return $resultPage + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/xpath.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/xpath.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,70 @@ +xquery version "1.0"; + +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace util = "http://exist-db.org/xquery/util"; +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; + +(: ToDo wenn eine pn gegeben ist, wird momentan der namespace ignoriert :) +let $mpdlDocUri := request:get-parameter("document", "") +let $pn := number(request:get-parameter("pn", "-1")) +let $xpath := request:get-parameter("xpath", "") +let $output := request:get-parameter("output", "") +let $resultPageNumber := number(request:get-parameter("resultPN", "1")) +let $resultPageSize := number(request:get-parameter("resultPageSize", "50")) + +let $documentName := substring-before(substring-after(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/"), ".") +let $docbase := substring-before(substring-after($mpdlDocUri, "/"), "/") +let $fullDocumentUri := concat('/db/mpdl/documents/morph', $mpdlDocUri) +let $document := doc($fullDocumentUri) +let $pageBreaks := + if ($docbase = 'archimedes' and $pn != -1) + then $document//pb + else if ($docbase = 'echo' and $pn != -1) + then $document//echo:pb + else $document//pb +let $countPBs := count($pageBreaks) +let $pb1 := subsequence($pageBreaks, $pn, 1) +let $pb2 := subsequence($pageBreaks, $pn + 1, 1) +let $pageFragmentStr := + if ($pn != -1 and $countPBs > 0) + then util:get-fragment-between($pb1, $pb2, true()) + else if ($pn != -1 and $countPBs = 0) + then "" + else () +let $pageFragment := + if ($countPBs > 0) + then util:parse($pageFragmentStr) + else $document +let $xPathFragment := concat(".", $xpath) +let $resultEval := + if ($pn > 0) + then util:eval-inline($pageFragment, $xPathFragment) + else util:eval-inline($document, $xPathFragment) +let $from := ($resultPageNumber * $resultPageSize) - $resultPageSize + 1 +let $to := $resultPageNumber * $resultPageSize +let $resultEvalPage := + for $entry at $pos in $resultEval + where $pos >= $from and $pos <= $to + return $entry +let $size := count($resultEval) +let $pages := + if ($size = 0) + then 0 + else $size idiv $resultPageSize + 1 +let $result := + + {$mpdlDocUri} + {$pn} + {$size} + {$resultPageSize} + {$pages} + {$resultPageNumber} + {$resultEvalPage} + + +let $declare := + if ($output != "html") + then util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") + else util:declare-option("exist:serialize", "method=html media-type=text/html omit-xml-declaration=no indent=yes encoding=utf-8") + +return $result \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/interface/xquery.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/interface/xquery.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,98 @@ +xquery version "1.0"; + +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace util = "http://exist-db.org/xquery/util"; +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; + +(: ToDo wenn eine pn gegeben ist (also im Fragment untersucht werden soll) geht es momentan nicht s.u. :) +(: ToDo wenn eine pn gegeben ist, wird momentan der namespace ignoriert wie z.B. xquery=//echo:s&pn=14 :) +let $xQuery := request:get-parameter("xquery", "") +let $xQueryPath := request:get-parameter("xqueryPath", "") +let $mpdlDocUri := request:get-parameter("document", "") +let $pn := number(request:get-parameter("pn", "-1")) +let $startRecord := number(request:get-parameter("startRecord", "1")) +let $maximumRecords := number(request:get-parameter("maximumRecords", "-1")) +let $output := request:get-parameter("output", "") +let $options := request:get-parameter("options", "") + +let $documentName := substring-before(substring-after(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/"), ".") +let $docbase := substring-before(substring-after($mpdlDocUri, "/"), "/") +let $fullDocumentUri := concat('/db/mpdl/documents/morph', $mpdlDocUri) +let $document := doc($fullDocumentUri) +let $pageBreaks := + if ($docbase = 'archimedes') + then $document//pb + else if ($docbase = 'echo') + then $document//echo:pb + else $document//pb +let $countPBs := count($pageBreaks) +let $pb1 := subsequence($pageBreaks, $pn, 1) +let $pb2 := subsequence($pageBreaks, $pn + 1, 1) +let $pageFragmentStr := + if ($pn != -1 and $countPBs > 0) + then util:get-fragment-between($pb1, $pb2, true()) + else if ($pn != -1 and $countPBs = 0) + then "" + else "" +let $pageFragment := + if ($countPBs > 0) + then util:parse($pageFragmentStr) + else $document +(: ToDo im Fragment geht es nur mit vorn angehängtem Punkt. Das gibt aber Probleme, wenn es komplizierte XQueries gibt: let $xPathFragment := concat(".", $xpath) :) +let $resultEval := + if ($xQueryPath != "" and $document != "" and $pn > 0) + then util:eval-inline($pageFragment, $xQueryPath) + else if ($xQueryPath != "" and $document != "" and $pn = -1) + then util:eval-inline($document, $xQueryPath) + else if ($xQueryPath != "" and $mpdlDocUri = "") + then util:eval($xQueryPath) + else if ($xQueryPath = "" and $document != "" and $pn > 0) + then util:eval-inline($pageFragment, $xQuery) + else if ($xQueryPath = "" and $document != "" and $pn = -1) + then util:eval-inline($document, $xQuery) + else if ($xQueryPath = "" and $mpdlDocUri = "") + then util:eval($xQuery) + else () +let $size := count($resultEval) +let $from := $startRecord +let $to := + if ($maximumRecords != -1) + then $startRecord + $maximumRecords - 1 + else $size +let $resultEvalPage := + for $entry at $pos in $resultEval + where $pos >= $from and $pos <= $to + return + + {$pos} + {$entry} + + +let $resDocument := + if ($document != '' and $pn != -1) + then {$mpdlDocUri}{$pn} + else if ($document != '' and $pn = -1) + then {$mpdlDocUri} + else '' +let $result := + + {$xQuery} + {$resDocument} + + {$size} + {$startRecord} + {$maximumRecords} + + {$resultEvalPage} + + + + + + +let $declare := + if ($output != "html") + then util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") + else util:declare-option("exist:serialize", "method=html media-type=text/html omit-xml-declaration=no indent=yes encoding=utf-8") + +return $result \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/lt/encoder.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/lt/encoder.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,48 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../util/time.xql"; + +declare namespace request="http://exist-db.org/xquery/request"; + +let $fromCoding := request:get-parameter("from-encoding", "") +let $toCoding := request:get-parameter("to-encoding", "") +let $inputString := request:get-parameter("input-string", "") + +let $currentTimeBegin := util:system-time() + +let $encodedStr := mpdltext:transcode($fromCoding, $toCoding, $inputString) +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $retHtmlResult := + + + Mpdl language technology + + +

    Mpdl language technology: Result of your query: from-encoding={$fromCoding}, to-encoding={$toCoding}

    + Your input string: +

    + {$inputString} +

    + Encoded string: +

    + {$encodedStr} +


    +

    + Elapsed time: {$neededTime} ms, see the XQuery documentation and the XQuery source of this page, if you find a bug let us know + + + +let $declare := util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") + + +return + + + {$fromCoding} + {$toCoding} + {$inputString} + + {$encodedStr} + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/lt/lemma.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/lt/lemma.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,68 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../util/time.xql"; + +declare namespace request="http://exist-db.org/xquery/request"; + +let $language := request:get-parameter("language", "") +let $lemmaName := request:get-parameter("lemma", "") +let $formName := request:get-parameter("form", "") +let $luceneQuery := request:get-parameter("query", "") + +let $currentTimeBegin := util:system-time() + +let $lemmas := + if ($formName != '') + then mpdltext:get-lemmas-by-form-name($language, $formName) + else if ($lemmaName != '') + then mpdltext:get-lemma($language, $lemmaName) + else mpdltext:get-lemmas-by-lucene-query($language, $luceneQuery) +let $orderedLemmas := + if (empty($lemmas)) + then ("no lemmas found for your query") + else + for $lemma in $lemmas/lemmas/lemma + let $lemmaText := concat($lemma/lemma-name, " (", $lemma/provider, ")") + let $orderedForms := + for $form in $lemma/forms/form + let $liForm :=

  • {$form/form-name} ({$form/provider})
  • + order by $form/form-name + return $liForm + let $lemmaLi := +
  • Lemma: {$lemmaText} +
      {$orderedForms}
    +
  • + order by $lemma/lemma-name + return $lemmaLi + +let $queryResultHeaderStr := + if ($formName != '') + then

    Mpdl-Donatus: Lemmas and forms: Result of your query: Language={$language}, Form={$formName}

    + else if ($lemmaName != '') + then

    Mpdl-Donatus: Lemmas and forms: Result of your query: Language={$language}, Lemma={$lemmaName}

    + else

    Mpdl-Donatus: Lemmas and forms: Result of your query: Language={$language}, Query={$luceneQuery}

    + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $retHtmlResult := + + + Lemmas and forms + + + {$queryResultHeaderStr} + + +
    [This is a MPDL Donatus and Snowball service] MPDL Donatus service
    +

    + {$orderedLemmas} +

    + (* in parentheses the data provider of the lemma/form) +


    +

    + Elapsed time: {$neededTime} ms, see the XQuery documentation and the XQuery source of this page, if you find a bug let us know + + + +return $retHtmlResult \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/lt/lex.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/lt/lex.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,68 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "../util/time.xql"; + +declare namespace request="http://exist-db.org/xquery/request"; + +let $language := request:get-parameter("language", "") +let $formName := request:get-parameter("form", "") +let $luceneQuery := request:get-parameter("query", "") + +let $currentTimeBegin := util:system-time() + +let $lexica := + if ($formName != '') + then mpdltext:get-lex-entries-by-form-name($language, $formName) + else mpdltext:get-lex-entries-by-lucene-query($language, $luceneQuery) +let $htmlLexica := + if (empty($lexica)) + then ("no lexical entries found for your query") + else + for $lexicon in $lexica/lexica/lexicon + let $lexDescription := $lexicon/description + let $lexEntries := $lexicon/entries + let $liLexEntryContent := + for $lexEntry in $lexicon/entries/entry + let $lexEntryContent := $lexEntry/content + let $lexEntryXmlValid := $lexEntryContent/xml-valid + let $lexEntryOriginalContent := $lexEntryContent/original-entry + let $lexEntryRepairedContent := $lexEntryContent/repaired-entry + let $lexEntryContentParsed := + if ($lexEntryXmlValid = "true") + then util:parse($lexEntryRepairedContent) + else [Remark: lexical entry in lexicon has no valid XML, so only the Betacode text version of the entry could be displayed]

    {$lexEntryOriginalContent} + return
  • {($lexEntryContentParsed)}
  • + let $lexiconLi := +
  • {$lexDescription} +
      {$liLexEntryContent}
    +
  • + return $lexiconLi + +let $queryResultHeaderStr := + if ($formName != '') + then

    Mpdl-Pollux: Result of your query: Language={$language}, Form={$formName}

    + else

    Mpdl-Pollux: Result of your query: Language={$language}, Query={$luceneQuery}

    + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $retHtmlResult := + + + Mpdl-Pollux + + + {$queryResultHeaderStr} + + +
    [This is a MPDL Pollux service] MPDL Pollux service
    + +

    + {$htmlLexica} +


    +

    + Elapsed time: {$neededTime} ms, see the XQuery documentation and the XQuery source of this page, if you find a bug let us know + + + +return $retHtmlResult \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/lucene/search.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/lucene/search.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,385 @@ +xquery version "1.0"; + +module namespace mpdl-lucene = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/lucene/search"; + +import module namespace functx = "http://www.functx.com" at "../util/functx.xql"; + +declare namespace ft = "http://exist-db.org/xquery/lucene"; + +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; + +declare namespace dc="http://purl.org/dc/elements/1.1/"; +declare namespace dcterms="http://purl.org/dc/terms"; + +declare function mpdl-lucene:search($mpdlCollection, $queryStr) { + let $luceneParseResult := mpdltext:lucene-parse-query($queryStr) + let $result := + if ($luceneParseResult = '') + then $mpdlCollection/.[ft:query(archimedes/text, $queryStr) or ft:query(echo:echo/echo:text, $queryStr)] + else + + {$luceneParseResult} + 0 + 0 + 0 + + + return $result +}; + +declare function mpdl-lucene:search($mpdlCollectionName, $language, $document, $queryType, $queryStr, $pn as xs:int, $pageSize as xs:int) as node() { + (: performance reasons: all hits (not only the first 10! ) are passed through the :) + (: for loop: so the overhead in each loop has to be minimized :) + let $query := + if ($queryType = 'fulltext' or $queryType = 'fulltextMorph') + then $queryStr + else if ($queryType = 'fulltextMorphLemma') + then concat('lemmalemma', $queryStr) + else () + let $pageBreaks := + if ($mpdlCollectionName = 'archimedes') + then $document//pb + else if ($mpdlCollectionName = 'echo') + then $document//echo:pb + else $document//pb + let $luceneParseResult := mpdltext:lucene-parse-query($queryStr) + let $t := + if ($luceneParseResult != '') + then () + else if ($mpdlCollectionName = 'archimedes') + then $document//s[ft:query(., $query)] + else if ($mpdlCollectionName = 'echo') + then $document//echo:s[ft:query(., $query)] + else $document//s[ft:query(., $query)] + let $from := ($pn * $pageSize) - $pageSize + 1 + let $to := $pn * $pageSize + (: performance improvements: result set of 500 needs 3 sec., result set of 10 needs 0,7 sec.:) + let $tempQueryResult := + for $ss at $poss in $t + where $poss >= $from and $poss <= $to + return $ss + let $queryResult := + for $s at $pos in $tempQueryResult + let $pnOfS := count($pageBreaks[. << $s]) (: faster: comparison only in pb elements of this document :) + let $pb := subsequence($pageBreaks, $pnOfS, 1) + (: test if sentence surrounds page break; costs 0,1 sec performance :) + let $pbPlus1 := subsequence($pageBreaks, $pnOfS + 1, 1) + let $sSurroundsPB := + if ($pbPlus1/parent::node() = $s and $pbPlus1 intersect $s/descendant::node()) + then true() + else false() + let $posOfS := (: faster: comparison only in s elements of this document :) + if ($mpdlCollectionName = 'archimedes') + then count($pb/following::s[. << $s]) + 1 + else if ($mpdlCollectionName = 'echo') + then count($pb/following::echo:s[. << $s]) + 1 + else count($pb/following::s[. << $s]) + 1 + let $position := $from - 1 + $pos + let $resultElem := + + {$position} + {$pnOfS} + {$posOfS} + {string($s)} + {$sSurroundsPB} + + return $resultElem + let $resultSize := count($t) + let $pages := + if ($resultSize = 0) + then 0 + else $resultSize idiv $pageSize + 1 + let $queryForms := + if ($queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma') + then mpdltext:get-query-morph-forms($language, $queryStr) + else () + let $queryRegularizations := + if ($queryType = 'fulltextMorph') + then mpdltext:get-query-regularizations($language, $queryStr) + else () + + let $encodedQueryTerms := + if ($language = "zh") + then + mpdltext:get-big5-encoded-terms($query) + else () + + let $result := + if ($luceneParseResult != '') + then + + {$luceneParseResult} + 0 + 0 + 0 + + + else + + {$resultSize} + {$pageSize} + {$pages} + {$pn} + + {$queryResult} + + {$queryForms} + {$queryRegularizations} + {$encodedQueryTerms} + + + return $result +}; + +declare function mpdl-lucene:attrSearch($metadataStr, $attribute1, $attrValue1, $boolOp, $attribute2, $attrValue2) { + let $attrFtQueryStr1 := mpdl-lucene:getAttrQueryStr($attribute1, $attrValue1) + let $attrFtQueryStr2 := mpdl-lucene:getAttrQueryStr($attribute2, $attrValue2) + let $booleanQueryStr := + if ($attrValue2 = "") + then $attrFtQueryStr1 + else if ($attrValue2 != "" and $boolOp = "or") + then concat($attrFtQueryStr1, " or ", $attrFtQueryStr2) + else if ($attrValue2 != "" and $boolOp = "and") + then concat("(", $attrFtQueryStr1, ") and (", $attrFtQueryStr2, ")") + else if ($attrValue2 != "" and $boolOp = "andNot") + then concat("(", $attrFtQueryStr1, ") and not(", $attrFtQueryStr2, ")") + else () + let $attrQuery := concat($metadataStr, "/.[", $booleanQueryStr, "]") + let $luceneParseResult1 := mpdltext:lucene-parse-query($attrValue1) + let $luceneParseResult2 := mpdltext:lucene-parse-query($attrValue2) + let $luceneParseResult := + if ($luceneParseResult1 = '' and $luceneParseResult2 = '') + then '' + else if ($luceneParseResult1 != '' and $luceneParseResult2 = '') + then concat("attribute ", $attribute1, " with value: ", $attrValue1, ": ", $luceneParseResult1) + else if ($luceneParseResult1 = '' and $luceneParseResult2 != '') + then concat("attribute ", $attribute2, " with value: ", $attrValue2, ": ", $luceneParseResult2) + else if ($luceneParseResult1 != '' and $luceneParseResult2 != '') + then concat("attribute ", $attribute1, " with value: ", $attrValue1, ": ", $luceneParseResult1, ", attribute ", $attribute2, " with value: ", $attrValue2, ": ", $luceneParseResult2) + else () + let $result := + if ($luceneParseResult = '') + then util:eval($attrQuery) + else + + {$luceneParseResult} + 0 + 0 + 0 + + + + return $result +}; + +declare function mpdl-lucene:order($metadata, $orderBy) { + let $result := + (for $attrElem in $metadata + let $doc := $attrElem/fn:root() + let $documentUri := document-uri($doc) + let $docBase := functx:substring-after-last(functx:substring-before-last(functx:substring-before-last($documentUri, "/"), "/"), "/") + let $metadataElem := mpdl-lucene:getMetadata($docBase, $doc) + let $attrElemName := mpdl-lucene:getElemNameByAttr($docBase, $orderBy) + let $orderByElem := mpdl-lucene:getElemDynamic($metadataElem, $attrElemName) (: this costs performance for many result elements :) + let $orderByTemp := lower-case(string-join($orderByElem, ', ')) order by $orderByTemp + return $attrElem) + + return $result + + (: performance improvement (?): + let $result := + for $x in doc(/db/doc1.xml) + order by $x + if ($sortOrder eq "asc") + then ( "ascending" ) + else ( "descending" ) + :) +}; + +declare function mpdl-lucene:getMetadata($docBase, $doc) { + let $result := + if ($docBase = 'archimedes') + then $doc/archimedes/info + else if ($docBase = 'echo') + then $doc/echo:echo/echo:metadata + else () + return $result +}; + +declare function mpdl-lucene:getText($docBase, $doc) { + let $result := + if ($docBase = 'archimedes') + then $doc/archimedes/text + else if ($docBase = 'echo') + then $doc/echo:echo/echo:text + else () + return $result +}; + + +(: TODO: performance improvement: each time util:eval is executed :) +declare function mpdl-lucene:getElemDynamic($path, $elemStr) { + let $evalExpr := + if($elemStr != "") + then concat("$path/", $elemStr) + else "" + let $result := util:eval($evalExpr) + return $result +}; + +declare function mpdl-lucene:getAttrQueryStr($attribute, $attrValue) { + let $attrArch := mpdl-lucene:getElemNameByAttr("archimedes", $attribute) + let $attrEcho := mpdl-lucene:getElemNameByAttr("echo", $attribute) + let $attrArchRelQueryStr := + if ($attribute = "date") + then concat($attrArch, " = '", $attrValue, "'") + else concat("ft:query(", $attrArch, ", '", $attrValue, "')") + let $attrEchoRelQueryStr := + if ($attribute = "date") + then concat($attrEcho, " = '", $attrValue, "'") + else concat("ft:query(", $attrEcho, ", '", $attrValue, "')") + let $result := + if ($attrArch != "" and $attrEcho != "") + then concat($attrArchRelQueryStr, " or ", $attrEchoRelQueryStr) + else if ($attrArch = "" and $attrEcho != "") + then $attrEchoRelQueryStr + else if ($attrArch != "" and $attrEcho = "") + then $attrArchRelQueryStr + else "" + return $result +}; + +declare function mpdl-lucene:getElemNameByAttr($docBase, $attribute) { + let $docBaseArch := "archimedes" + let $docBaseEcho := "echo" + let $result := + if ($docBase = $docBaseArch and $attribute = "author") + then "author" + else if ($docBase = $docBaseEcho and $attribute = "author") + then "dcterms:creator" + else if ($docBase = $docBaseArch and $attribute = "title") + then "title" + else if ($docBase = $docBaseEcho and $attribute = "title") + then "dcterms:title" + else if ($docBase = $docBaseArch and $attribute = "place") + then "place" + else if ($docBase = $docBaseEcho and $attribute = "place") + then "" + else if ($docBase = $docBaseArch and $attribute = "date") + then "date" + else if ($docBase = $docBaseEcho and $attribute = "date") + then "dcterms:date" + else if ($docBase = $docBaseArch and $attribute = "language") + then "lang" + else if ($docBase = $docBaseEcho and $attribute = "language") + then "dcterms:language" + else if ($docBase = $docBaseArch and $attribute = "identifier") + then "locator" + else if ($docBase = $docBaseEcho and $attribute = "identifier") + then "dcterms:identifier" + else if ($docBase = $docBaseArch and $attribute = "rights") + then "" + else if ($docBase = $docBaseEcho and $attribute = "rights") + then "dcterms:rights" + else if ($docBase = $docBaseArch and $attribute = "license") + then "" + else if ($docBase = $docBaseEcho and $attribute = "license") + then "dcterms:license" + else if ($docBase = $docBaseArch and $attribute = "accessRights") + then "" + else if ($docBase = $docBaseEcho and $attribute = "accessRights") + then "dcterms:accessRights" + else if ($docBase = $docBaseArch and $attribute = "file") + then "cvs_file" + else if ($docBase = $docBaseEcho and $attribute = "file") + then "" + else if ($docBase = $docBaseArch and $attribute = "translator") + then "translator" + else if ($docBase = $docBaseEcho and $attribute = "translator") + then "" + else if ($docBase = $docBaseArch and $attribute = "version") + then "cvs_version" + else if ($docBase = $docBaseEcho and $attribute = "version") + then "" + else "" + + return $result +}; + +declare function mpdl-lucene:getElementsByAttr($metadata, $docBase, $attribute) { + let $docBaseArch := "archimedes" + let $docBaseEcho := "echo" + let $result := + if ($docBase = $docBaseArch and $attribute = "author") + then + for $elem in $metadata/author + return {$elem} + else if ($docBase = $docBaseEcho and $attribute = "author") + then + for $elem in $metadata/dcterms:creator + return {$elem} + else if ($docBase = $docBaseArch and $attribute = "title") + then + for $elem in $metadata/title + return {$elem} + else if ($docBase = $docBaseEcho and $attribute = "title") + then + for $elem in $metadata/dcterms:title + return {$elem} + else if ($docBase = $docBaseArch and $attribute = "place") + then + for $elem in $metadata/place + return {$elem} + else if ($docBase = $docBaseEcho and $attribute = "place") + then () + else if ($docBase = $docBaseArch and $attribute = "date") + then + for $elem in $metadata/date + return {$elem} + else if ($docBase = $docBaseEcho and $attribute = "date") + then + for $elem in $metadata/dcterms:date + return {$elem} + else if ($docBase = $docBaseArch and $attribute = "language") + then $metadata/lang + else if ($docBase = $docBaseEcho and $attribute = "language") + then $metadata/dcterms:language + else if ($docBase = $docBaseArch and $attribute = "identifier") + then $metadata/locator + else if ($docBase = $docBaseEcho and $attribute = "identifier") + then $metadata/dcterms:identifier + else if ($docBase = $docBaseArch and $attribute = "rights") + then () + else if ($docBase = $docBaseEcho and $attribute = "rights") + then + for $elem in $metadata/dcterms:rights + return {$elem} + else if ($docBase = $docBaseArch and $attribute = "accessRights") + then () + else if ($docBase = $docBaseEcho and $attribute = "accessRights") + then + for $elem in $metadata/dcterms:accessRights + return {$elem} + else if ($docBase = $docBaseArch and $attribute = "license") + then () + else if ($docBase = $docBaseEcho and $attribute = "license") + then + for $elem in $metadata/dcterms:license + return {$elem} + else if ($docBase = $docBaseArch and $attribute = "file") + then $metadata/cvs_file + else if ($docBase = $docBaseEcho and $attribute = "file") + then () + else if ($docBase = $docBaseArch and $attribute = "translator") + then $metadata/translator + else if ($docBase = $docBaseEcho and $attribute = "translator") + then () + else if ($docBase = $docBaseArch and $attribute = "version") + then $metadata/cvs_version + else if ($docBase = $docBaseEcho and $attribute = "version") + then () + else () + + return $result +}; + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/page-query-result.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/page-query-result.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,431 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "util/time.xql"; +import module namespace functx = "http://www.functx.com" at "util/functx.xql"; +import module namespace mpdl-lucene = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/lucene/search" at "lucene/search.xql"; +import module namespace mpdl-text = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/text" at "text/all.xql"; + +declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace transform = "http://exist-db.org/xquery/transform"; +declare namespace util = "http://exist-db.org/xquery/util"; + +declare namespace dcterms="http://purl.org/dc/terms"; +declare namespace xhtml="http://www.w3.org/1999/xhtml"; +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; + +let $mpdlDocUri := request:get-parameter("document", "") +let $queryType := request:get-parameter("query-type", "") +let $mode := request:get-parameter("mode", "image") +let $reqPN := number(request:get-parameter("pn", "-1")) +let $reqPF := request:get-parameter("pf", "") +let $reqSN := number(request:get-parameter("sn", "-1")) +let $query := request:get-parameter("query", "") +let $reqQueryResultPN := request:get-parameter("query-result-pn", "") +let $queryResultPN := + if ($reqQueryResultPN = '' or $reqQueryResultPN = '0') + then 1 + else number($reqQueryResultPN) +let $regCharNorm := request:get-parameter("characterNormalization", "") +let $tmpCharNorm := string-join($regCharNorm, ',') +let $charNorm := + if($tmpCharNorm = "regPlusNorm") + then "reg,norm" + else $tmpCharNorm +let $reqExport := request:get-parameter("export", "") +let $options := string(request:get-parameter("options", "")) + +let $presentationPath := "/db/mpdl/presentation" +(: e.g. mpdlCollectioName is derived from mpdlDocUri: /archimedes/la/yourDoc.xml :) +let $documentName := substring-before(substring-after(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/"), ".") +let $language := substring-before(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/") +let $docbase := substring-before(substring-after($mpdlDocUri, "/"), "/") +let $fullDocumentUri := + if ($queryType = 'fulltext' or $queryType = 'ftIndex') + then concat('/db/mpdl/documents/standard', $mpdlDocUri) + else if ($queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma' or $queryType = 'ftIndexMorph') + then concat('/db/mpdl/documents/morph', $mpdlDocUri) + else concat('/db/mpdl/documents/morph', $mpdlDocUri) +let $currentTimeBegin := util:system-time() +let $documentAvailable := doc-available($fullDocumentUri) +let $document := doc($fullDocumentUri) +let $metadata := + if ($docbase = 'archimedes') + then $document/archimedes/info + else if ($docbase = 'echo') + then $document/echo:echo/echo:metadata + else '' + +let $pageBreaks := + if ($docbase = 'archimedes') + then $document//pb + else if ($docbase = 'echo') + then $document//echo:pb + else $document//pb +let $countPagesTemp := count($pageBreaks) +let $countPages := + if ($countPagesTemp > 0) + then $countPagesTemp + else 1 + +(: xQuery inline execution does not work in module so it has to be done here :) +let $xQueryPageSize := 100 +let $xQueryResultEval := + if ($queryType = 'xpath' or $queryType = 'xquery' and $query != "") + then util:eval-inline($document, $query) + else () +let $xQueryFrom := ($queryResultPN * $xQueryPageSize) - $xQueryPageSize + 1 +let $xQueryTo := $queryResultPN * $xQueryPageSize +let $xQueryResultEntries := + for $entry at $pos in $xQueryResultEval + where $pos >= $xQueryFrom and $pos <= $xQueryTo + return $entry +let $xQuerySize := count($xQueryResultEval) +let $xQueryPages := + if ($xQuerySize = 0) + then 0 + else $xQuerySize idiv $xQueryPageSize + 1 +let $xQueryResult := + + {$xQuerySize} + {$xQueryPageSize} + {$xQueryPages} + {$queryResultPN} + {$xQueryResultEntries} + + +let $queryResult := + if (($queryType = 'fulltext' or $queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma') and $query != "") + then mpdl-lucene:search($docbase, $language, $document, $queryType, $query, $queryResultPN, 10) + else if (($queryType = 'ftIndex' or $queryType = 'ftIndexMorph') and $query != "") + then mpdl-text:indexTerms($docbase, $language, $document, $query, $queryResultPN, 100) + else if ($queryType = 'xpath' or $queryType = 'xquery' and $query != "") + then $xQueryResult + else if ($queryType = 'toc' or $queryType = 'figures') + then mpdl-text:get-toc($docbase, $queryType, $document, $queryResultPN, 100) + else if ($query = "") + then + + 0 + 0 + 0 + + + else () + +let $countHits := count($queryResult/result/hits/hit) +let $firstHit := $queryResult/result/hits/hit[1] +(: jump to first pn and sn hit in fulltext mode :) +let $pn := + if (($queryType = 'fulltext' or $queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma') and $countHits > 0 and $reqPN <= 0) + then number($firstHit/pn) + else if ($reqPN = -1) + then 1 + else $reqPN +let $sn := + if (($queryType = 'fulltext' or $queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma') and $countHits > 0 and $reqPN <= 0 and $reqSN < 0) + then number($firstHit/pos-of-s) + else $reqSN + +(: 10 or more is an error :) +let $errorCode := + if (not($documentAvailable)) + then 10 + else if ($countPagesTemp != 0 and ($pn > $countPagesTemp or $pn <= 0)) + then 11 + else if ($countPagesTemp = 0) + then 1 (: if no page break is found then the document should have exactly one page :) + else if (not($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml" or $mode = "pureXml")) + then 12 + else 0 + +let $pb1 := + if ($errorCode = 0) + then subsequence($pageBreaks, $pn, 1) + else if ($errorCode = 1) + then subsequence(mpdl-lucene:getText($docbase, $document), 1, 1) + else () +let $pb2 := + if ($errorCode = 0) + then subsequence($pageBreaks, $pn + 1, 1) + else if ($errorCode = 1) + then subsequence(mpdl-lucene:getText($docbase, $document), 2, 1) + else () +let $pageHeader := string($pb1/@rhead) +let $pageNumberOrig := string($pb1/@o) + +let $documentIdentifier := + if ($docbase = 'archimedes') + then $metadata/locator + else if ($docbase = 'echo') + then $metadata/dcterms:identifier + else $metadata/dcterms:identifier +let $echoDocIdentifier := + if ($documentIdentifier != '') + then substring-before(substring-after($documentIdentifier, "ECHO:"), ".") + else '' +let $echoURLZogilib := "http://echo.mpiwg-berlin.mpg.de/zogilib" +let $nausikaaURLScaler := "http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler" +let $nausikaaURLDlInfo := "http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/dlInfo-xml.jsp" +let $nausikaaURLTexter := "http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/servlet/Texter" +let $echoImageDir := + if ($docbase = 'archimedes') + then string($metadata/echodir) + else if ($docbase = 'echo') + then string($metadata/echo:echodir) + else '' +let $imagesDocDirectory := + if ($echoImageDir != '') + then $echoImageDir + else if ($docbase = 'archimedes') + then concat("/permanent/archimedes/", $documentName) + else if ($docbase = 'echo') + then concat("/permanent/library/", $echoDocIdentifier) + else '' +let $imagesDocDirectoryIndexMetaUrl := + if ($mode = "image" or $mode = "text" or $mode = "textPollux" or $mode = "gis") + then concat($nausikaaURLTexter, "?fn=", $imagesDocDirectory, "/index.meta") + else () +let $digilibAvailable := mpdldoc:check-uri($imagesDocDirectoryIndexMetaUrl, ()) +let $imagesDocDirectoryIndexMeta := + if (($mode = "image" or $mode = "text" or $mode = "textPollux" or $mode = "gis") and $digilibAvailable) + then doc($imagesDocDirectoryIndexMetaUrl) + else () +let $pageImageDirectory := string($imagesDocDirectoryIndexMeta/resource/meta/texttool/image) +let $figuresImageDirectoryTemp := string($imagesDocDirectoryIndexMeta/resource/meta/texttool/figures) +let $figuresImageDirectory := + if ($figuresImageDirectoryTemp != '') + then $figuresImageDirectoryTemp + else concat(substring-before($pageImageDirectory, "pageimg"), "figures") +let $pageImageFileNameWithoutExtension := + if ($docbase = 'echo') + then concat("/", string($pb1/@file)) + else '' +let $imageFileName := + if ($reqPF = '') + then concat($imagesDocDirectory, "/", $pageImageDirectory, $pageImageFileNameWithoutExtension) + else $reqPF +let $imageEcho := {$echoURLZogilib}?fn={$imageFileName}&pn={$pn} +let $imageScaler := {$nausikaaURLScaler}?fn={$imageFileName}&pn={$pn} + +let $imageFileNameUrl := concat($nausikaaURLDlInfo, "?fn=", $imageFileName) +let $testImageResult := + if ($mode = 'image' and $digilibAvailable) + then doc($imageFileNameUrl) + else () +let $testImageResultParamImgFn := string($testImageResult//parameter[@name='img.fn']/@value) +let $imageIsAvailable := + if ($testImageResultParamImgFn = '' and $reqPF = '') + then 'false' + else 'true' + +let $positionOfFirstFigureAfterPB1 := + if ($docbase = 'archimedes') + then count($pb1/following::figure[1]/preceding::figure) + 1 + else if ($docbase = 'echo') + then count($pb1/following::echo:figure[1]/preceding::echo:figure) + 1 + else () + +let $pageFragmentTmp := + if ($mode = "image" or $errorCode > 9) + then () + else if ($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "xml" or $mode = "pureXml") + then util:get-fragment-between($pb1, $pb2, true()) + else () +(: replace the soft hyphen (Unicode character for 00AD) just before the line break by a normal hyphen :) +(: delete the hyphen just before the line break in case of options=withoutLBs :) +let $pageFragment := + if (($mode = "text" or $mode = "textPollux") and not(contains($options, "withoutLBs")) and contains($pageFragmentTmp, "­ 9) + then () + else if (($mode = "text" or $mode = "textPollux" or $mode = "gis") and $charNorm = "") + then mpdltext:normalizeChars('reg,norm', $language, $pageFragment) + else if (($mode = "xml" or $mode = "pureXml") and $charNorm = "") + then $pageFragment + else if (($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "xml" or $mode = "pureXml") and $charNorm != "") + then mpdltext:normalizeChars($charNorm, $language, $pageFragment) + else () +let $retPageFragment := + if ($mode = "image" or $errorCode > 9) + then () + else if ($mode = "text" or $mode = "gis" or $mode = "xml" or $mode = "pureXml") + then $pageFragmentNormalized + else if ($mode = "textPollux") + then mpdltext:dictionarize($pageFragmentNormalized, $language) + else () +let $returnPageFragmentTmp := util:parse($retPageFragment) (: returns a valid xml document for that string :) + +let $externalElementsTmpTmp := mpdltext:externalObject("read", "element", "") +let $externalElementsTmp := + if(not($externalElementsTmpTmp = "")) + then util:parse($externalElementsTmpTmp) + else () +let $externalElements := $externalElementsTmp/result/object +let $containsExternalElements := + if(not(empty($externalElements))) + then true() + else false() +let $returnPageFragmentTmpp := + if (contains($options, "withXmlNodeId") or $containsExternalElements) + then mpdl-text:insertNodeIdAttribute($returnPageFragmentTmp/*[1]) + else $returnPageFragmentTmp + +let $returnPageFragment := + if($containsExternalElements) + then mpdl-text:insert($returnPageFragmentTmpp/*[1], $externalElements) + else $returnPageFragmentTmpp + +let $pageFigureAnchors := $returnPageFragment//anchor[@type = 'figure'] +let $pageFigures := + for $pageFigureAnchor in $pageFigureAnchors + let $figureHref := string($pageFigureAnchor/@xlink:href) + let $pageFigureTmp := $document//echo:figure[@xlink:label = $figureHref] + let $pageFigure := subsequence($pageFigureTmp, 1, 1) + return + $pageFigure +let $pageHandwrittenAnchors := $returnPageFragment//anchor[@type = 'handwritten'] +let $pageHandwritten := + for $pageHandwrittenAnchor in $pageHandwrittenAnchors + let $handwrittenHref := string($pageHandwrittenAnchor/@xlink:href) + let $pageHandwrittenTmp := $document//echo:handwritten[@xlink:label = $handwrittenHref] + let $pageHandwritten := subsequence($pageHandwrittenTmp, 1, 1) + return + $pageHandwritten +let $pageTableAnchors := $returnPageFragment//anchor[@type = 'table'] +let $pageTables := + for $pageTableAnchor in $pageTableAnchors + let $tableHref := string($pageTableAnchor/@xlink:href) + let $pageTableTmp := $document//xhtml:table[@xlink:label = $tableHref] + let $pageTable := subsequence($pageTableTmp, 1, 1) + return + $pageTable +let $pageNoteAnchors := $returnPageFragment//anchor[@type = 'note'] +let $pageNotes := + if ($docbase = "echo") + then + for $pageNoteAnchor in $pageNoteAnchors + let $noteHref := string($pageNoteAnchor/@xlink:href) + let $pageNoteTmp := $document//echo:note[@xlink:label = $noteHref] + let $pageNote := subsequence($pageNoteTmp, 1, 1) + return + $pageNote + else + $returnPageFragment//note + +(: Metadata handling: only metadata of the selected document is scanned :) +let $identifier := $documentIdentifier +let $authors := mpdl-lucene:getElementsByAttr($metadata, $docbase, "author") +let $titles := mpdl-lucene:getElementsByAttr($metadata, $docbase, "title") +let $places := mpdl-lucene:getElementsByAttr($metadata, $docbase, "place") +let $date := mpdl-lucene:getElementsByAttr($metadata, $docbase, "date") +let $rights := mpdl-lucene:getElementsByAttr($metadata, $docbase, "rights") +let $accessRights := mpdl-lucene:getElementsByAttr($metadata, $docbase, "accessRights") +let $licenses := mpdl-lucene:getElementsByAttr($metadata, $docbase, "license") +let $file := mpdl-lucene:getElementsByAttr($metadata, $docbase, "file") +let $translator := mpdl-lucene:getElementsByAttr($metadata, $docbase, "translator") +let $version := mpdl-lucene:getElementsByAttr($metadata, $docbase, "version") + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $xmlResult := + if ($errorCode < 10) + then + + + {$mpdlDocUri} + {$docbase} + {$documentName} + {$language} + {$authors} + {$titles} + {$places} + {$date} + {$identifier} + {$rights} + {$accessRights} + {$licenses} + {$file} + {$translator} + {$version} + {$countPages} + + + {$mode} + {$pn} + {$sn} +

    {$pageHeader}
    + {$pageNumberOrig} + {$digilibAvailable} + {$imageIsAvailable} + {$imageFileName} + {$imageEcho} + {$imageScaler} + ?document={$documentName}&pn={$pn}&mode=xml + {$imagesDocDirectory}/{$pageImageDirectory} + {$imagesDocDirectory}/{$figuresImageDirectory} + {$positionOfFirstFigureAfterPB1} + {$pageFigures} + {$pageHandwritten} + {$pageTables} + {$pageNotes} + {$returnPageFragment} + {$charNorm} + {$options} + + + {$queryType} + {$query} + {$queryResult} + + {$neededTime} + + else if ($errorCode = 10) + then {$errorCode}Fulltext document: {$mpdlDocUri} is not available yet + else if ($errorCode = 11) + then {$errorCode}No result: Page {$pn} not found + else if ($errorCode = 12) + then {$errorCode}View mode {$mode} not available + else {$errorCode}undefined error: {$errorCode} + +let $declare := + if ($errorCode > 9 or $mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml") + then util:declare-option("exist:serialize", "method=xhtml media-type=text/html omit-xml-declaration=no indent=yes encoding=utf-8") + else if ($mode = "pureXml") + then util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") + else util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") +let $xslFilePath := + if($reqExport = "pdf") + then concat($presentationPath, "/pageFragmentHtml.xsl") + else if($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml") + then concat($presentationPath, "/pageHtml.xsl") + else concat($presentationPath, "/pageXml.xsl") + +let $titleStr := concat(string-join($authors, ', '), ". ", string-join($titles, ', '), ". ", string-join($places, ', '), " ", $date, ".") +let $tmpResult := + if ($errorCode < 10 and $reqExport = "pdf") + then mpdl-text:html2pdf($language, $xmlResult, $xslFilePath, $titleStr, $pn, $mode) + else if ($errorCode < 10 and not($reqExport = "pdf")) + then mpdl-text:transform($xmlResult, $xslFilePath) + else +
    {$xmlResult}
    (: error xml result :) +let $result := + if ($errorCode < 10 and $reqExport = "pdf") + then response:stream-binary($tmpResult, "application/pdf", concat($documentName, "-page", $pn, ".pdf")) + else $tmpResult + +let $setHeaderXmlFilename := + if ($mode = "pureXml" and $queryType = "xpath" and $query != "") + then response:set-header('Content-Disposition', concat('filename=', $documentName, '-xpath-result--', $query, '--')) + else if ($mode = "pureXml" and $queryType = "xquery" and $query != "") + then response:set-header('Content-Disposition', concat('filename=', 'xquery-result')) + else if ($mode = "pureXml") + then response:set-header('Content-Disposition', concat('filename=', $documentName, '-page', $pn)) + else () + +return $result \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/pq.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/pq.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,439 @@ +xquery version "1.0"; + +import module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time" at "util/time.xql"; +import module namespace functx = "http://www.functx.com" at "util/functx.xql"; +import module namespace mpdl-lucene = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/lucene/search" at "lucene/search.xql"; +import module namespace mpdl-text = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/text" at "text/all.xql"; + +declare namespace xlink="http://www.w3.org/1999/xlink"; +declare namespace request = "http://exist-db.org/xquery/request"; +declare namespace transform = "http://exist-db.org/xquery/transform"; +declare namespace util = "http://exist-db.org/xquery/util"; + +declare namespace dcterms="http://purl.org/dc/terms"; +declare namespace xhtml="http://www.w3.org/1999/xhtml"; +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; + + +let $mpdlDocUri := request:get-parameter("document", "") +let $queryType := request:get-parameter("query-type", "") +let $mode := request:get-parameter("mode", "image") +let $reqPN := number(request:get-parameter("pn", "-1")) +let $reqPF := request:get-parameter("pf", "") +let $reqSN := number(request:get-parameter("sn", "-1")) +let $query := request:get-parameter("query", "") +let $reqQueryResultPN := request:get-parameter("query-result-pn", "") +let $queryResultPN := + if ($reqQueryResultPN = '' or $reqQueryResultPN = '0') + then 1 + else number($reqQueryResultPN) +let $regCharNorm := request:get-parameter("characterNormalization", "") +let $tmpCharNorm := string-join($regCharNorm, ',') +let $charNorm := + if($tmpCharNorm = "regPlusNorm") + then "reg,norm" + else $tmpCharNorm +let $reqExport := request:get-parameter("export", "") +let $options := string(request:get-parameter("options", "")) + +let $presentationPath := "/db/mpdl/presentation" +(: e.g. mpdlCollectioName is derived from mpdlDocUri: /archimedes/la/yourDoc.xml :) +let $documentName := substring-before(substring-after(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/"), ".") +let $language := substring-before(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/") +let $docbase := substring-before(substring-after($mpdlDocUri, "/"), "/") +let $fullDocumentUri := + if ($queryType = 'fulltext' or $queryType = 'ftIndex') + then concat('/db/mpdl/documents/standard', $mpdlDocUri) + else if ($queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma' or $queryType = 'ftIndexMorph') + then concat('/db/mpdl/documents/morph', $mpdlDocUri) + else concat('/db/mpdl/documents/morph', $mpdlDocUri) +let $currentTimeBegin := util:system-time() +let $documentAvailable := doc-available($fullDocumentUri) +let $document := doc($fullDocumentUri) +let $metadata := + if ($docbase = 'archimedes') + then $document/archimedes/info + else if ($docbase = 'echo') + then $document/echo:echo/echo:metadata + else '' + +let $pageBreaks := + if ($docbase = 'archimedes') + then $document//pb + else if ($docbase = 'echo') + then $document//echo:pb + else $document//pb +let $countPagesTemp := count($pageBreaks) +let $countPages := + if ($countPagesTemp > 0) + then $countPagesTemp + else 1 + +(: xQuery inline execution does not work in module so it has to be done here :) +let $xQueryPageSize := 100 +let $xQueryResultEval := + if ($queryType = 'xpath' or $queryType = 'xquery' and $query != "") + then util:eval-inline($document, $query) + else () +let $xQueryFrom := ($queryResultPN * $xQueryPageSize) - $xQueryPageSize + 1 +let $xQueryTo := $queryResultPN * $xQueryPageSize +let $xQueryResultEntries := + for $entry at $pos in $xQueryResultEval + where $pos >= $xQueryFrom and $pos <= $xQueryTo + return $entry +let $xQuerySize := count($xQueryResultEval) +let $xQueryPages := + if ($xQuerySize = 0) + then 0 + else $xQuerySize idiv $xQueryPageSize + 1 +let $xQueryResult := + + {$xQuerySize} + {$xQueryPageSize} + {$xQueryPages} + {$queryResultPN} + {$xQueryResultEntries} + + +let $queryResult := + if (($queryType = 'fulltext' or $queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma') and $query != "") + then mpdl-lucene:search($docbase, $language, $document, $queryType, $query, $queryResultPN, 10) + else if (($queryType = 'ftIndex' or $queryType = 'ftIndexMorph') and $query != "") + then mpdl-text:indexTerms($docbase, $language, $document, $query, $queryResultPN, 100) + else if ($queryType = 'xpath' or $queryType = 'xquery' and $query != "") + then $xQueryResult + else if ($queryType = 'toc' or $queryType = 'figures') + then mpdl-text:get-toc($docbase, $queryType, $document, $queryResultPN, 100) + else if ($query = "") + then + + 0 + 0 + 0 + + + else () + +let $countHits := count($queryResult/result/hits/hit) +let $firstHit := $queryResult/result/hits/hit[1] +(: jump to first pn and sn hit in fulltext mode :) +let $pn := + if (($queryType = 'fulltext' or $queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma') and $countHits > 0 and $reqPN <= 0) + then number($firstHit/pn) + else if ($reqPN = -1) + then 1 + else $reqPN +let $sn := + if (($queryType = 'fulltext' or $queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma') and $countHits > 0 and $reqPN <= 0 and $reqSN < 0) + then number($firstHit/pos-of-s) + else $reqSN + +(: 10 or more is an error :) +let $errorCode := + if (not($documentAvailable)) + then 10 + else if ($countPagesTemp != 0 and ($pn > $countPagesTemp or $pn <= 0)) + then 11 + else if ($countPagesTemp = 0) + then 1 (: if no page break is found then the document should have exactly one page :) + else if (not($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml" or $mode = "pureXml")) + then 12 + else 0 + +let $pb1 := + if ($errorCode = 0) + then subsequence($pageBreaks, $pn, 1) + else if ($errorCode = 1) + then subsequence(mpdl-lucene:getText($docbase, $document), 1, 1) + else () +let $pb2 := + if ($errorCode = 0) + then subsequence($pageBreaks, $pn + 1, 1) + else if ($errorCode = 1) + then subsequence(mpdl-lucene:getText($docbase, $document), 2, 1) + else () +let $pageHeader := string($pb1/@rhead) +let $pageNumberOrig := string($pb1/@o) + +let $documentIdentifier := + if ($docbase = 'archimedes') + then $metadata/locator + else if ($docbase = 'echo') + then $metadata/dcterms:identifier + else $metadata/dcterms:identifier +let $echoDocIdentifier := + if ($documentIdentifier != '') + then substring-before(substring-after($documentIdentifier, "ECHO:"), ".") + else '' +let $echoURLZogilib := "http://echo.mpiwg-berlin.mpg.de/zogilib" +let $nausikaaURLScaler := "http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler" +let $nausikaaURLDlInfo := "http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/dlInfo-xml.jsp" +let $nausikaaURLTexter := "http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/servlet/Texter" +let $echoImageDir := + if ($docbase = 'archimedes') + then string($metadata/echodir) + else if ($docbase = 'echo') + then string($metadata/echo:echodir) + else '' +let $imagesDocDirectory := + if ($echoImageDir != '') + then $echoImageDir + else if ($docbase = 'archimedes') + then concat("/permanent/archimedes/", $documentName) + else if ($docbase = 'echo') + then concat("/permanent/library/", $echoDocIdentifier) + else '' +let $imagesDocDirectoryIndexMetaUrl := + if ($mode = "image" or $mode = "text" or $mode = "textPollux" or $mode = "gis") + then concat($nausikaaURLTexter, "?fn=", $imagesDocDirectory, "/index.meta") + else () +let $digilibAvailable := mpdldoc:check-uri($imagesDocDirectoryIndexMetaUrl, ()) +let $imagesDocDirectoryIndexMeta := + if (($mode = "image" or $mode = "text" or $mode = "textPollux" or $mode = "gis") and $digilibAvailable) + then doc($imagesDocDirectoryIndexMetaUrl) + else () +let $pageImageDirectory := string($imagesDocDirectoryIndexMeta/resource/meta/texttool/image) +let $figuresImageDirectoryTemp := string($imagesDocDirectoryIndexMeta/resource/meta/texttool/figures) +let $figuresImageDirectory := + if ($figuresImageDirectoryTemp != '') + then $figuresImageDirectoryTemp + else concat(substring-before($pageImageDirectory, "pageimg"), "figures") +let $pageImageFileNameWithoutExtension := + if ($docbase = 'echo') + then concat("/", string($pb1/@file)) + else '' +let $imageFileName := + if ($reqPF = '') + then concat($imagesDocDirectory, "/", $pageImageDirectory, $pageImageFileNameWithoutExtension) + else $reqPF +let $imageEcho := {$echoURLZogilib}?fn={$imageFileName}&pn={$pn} +let $imageScaler := {$nausikaaURLScaler}?fn={$imageFileName}&pn={$pn} + +let $imageFileNameUrl := concat($nausikaaURLDlInfo, "?fn=", $imageFileName) +let $testImageResult := + if ($mode = 'image' and $digilibAvailable) + then doc($imageFileNameUrl) + else () +let $testImageResultParamImgFn := string($testImageResult//parameter[@name='img.fn']/@value) +let $imageIsAvailable := + if ($testImageResultParamImgFn = '' and $reqPF = '') + then 'false' + else 'true' + +let $positionOfFirstFigureAfterPB1 := + if ($docbase = 'archimedes') + then count($pb1/following::figure[1]/preceding::figure) + 1 + else if ($docbase = 'echo') + then count($pb1/following::echo:figure[1]/preceding::echo:figure) + 1 + else () + +let $pageFragmentTmp := + if ($mode = "image" or $errorCode > 9) + then () + else if ($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "xml" or $mode = "pureXml") + then util:get-fragment-between($pb1, $pb2, true()) + else () +(: replace the soft hyphen (Unicode character for 00AD) just before the line break by a normal hyphen :) +(: delete the hyphen just before the line break in case of options=withoutLBs :) +let $pageFragment := + if (($mode = "text" or $mode = "textPollux") and not(contains($options, "withoutLBs")) and contains($pageFragmentTmp, "­ 9) + then () + else if (($mode = "text" or $mode = "textPollux" or $mode = "gis") and $charNorm = "") + then mpdltext:normalizeChars('reg,norm', $language, $pageFragment) + else if (($mode = "xml" or $mode = "pureXml") and $charNorm = "") + then $pageFragment + else if (($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "xml" or $mode = "pureXml") and $charNorm != "") + then mpdltext:normalizeChars($charNorm, $language, $pageFragment) + else () +let $retPageFragment := + if ($mode = "image" or $errorCode > 9) + then () + else if ($mode = "text" or $mode = "gis" or $mode = "xml" or $mode = "pureXml") + then $pageFragmentNormalized + else if ($mode = "textPollux") + then mpdltext:dictionarize($pageFragmentNormalized, $language) + else () +let $returnPageFragmentTmp := util:parse($retPageFragment) (: returns a valid xml document for that string :) + +let $externalElementsTmpTmp := mpdltext:externalObject("read", "element", "", $mpdlDocUri, string($pn), "", "", "") +let $externalElementsTmp := + if(not($externalElementsTmpTmp = "")) + then util:parse($externalElementsTmpTmp) + else () +let $externalElements := $externalElementsTmp/result/element +let $containsExternalElements := + if(not(empty($externalElements))) + then true() + else false() +(: let $bla := error(QName("Bla", "Bla"), util:serialize($externalElementsTmp, ())) :) +let $returnPageFragmentTmpp := + if (contains($options, "withXmlNodeId") or $containsExternalElements) + then mpdl-text:insertNodeIdAttribute($returnPageFragmentTmp/*[1]) + else $returnPageFragmentTmp +let $sentences := util:eval-inline($returnPageFragmentTmpp, ".//s") +let $s4NodeId := subsequence($sentences, 4, 1)/@xmlNodeId +let $s5NodeId := subsequence($sentences, 5, 1)/@xmlNodeId +let $testExternalObjects := + (This is a first test note, + This is a second test note) + +let $returnPageFragment := + if($containsExternalElements) + then mpdl-text:insert($returnPageFragmentTmpp/*[1], $externalElements) + else $returnPageFragmentTmpp + +let $pageFigureAnchors := $returnPageFragment//anchor[@type = 'figure'] +let $pageFigures := + for $pageFigureAnchor in $pageFigureAnchors + let $figureHref := string($pageFigureAnchor/@xlink:href) + let $pageFigureTmp := $document//echo:figure[@xlink:label = $figureHref] + let $pageFigure := subsequence($pageFigureTmp, 1, 1) + return + $pageFigure +let $pageHandwrittenAnchors := $returnPageFragment//anchor[@type = 'handwritten'] +let $pageHandwritten := + for $pageHandwrittenAnchor in $pageHandwrittenAnchors + let $handwrittenHref := string($pageHandwrittenAnchor/@xlink:href) + let $pageHandwrittenTmp := $document//echo:handwritten[@xlink:label = $handwrittenHref] + let $pageHandwritten := subsequence($pageHandwrittenTmp, 1, 1) + return + $pageHandwritten +let $pageTableAnchors := $returnPageFragment//anchor[@type = 'table'] +let $pageTables := + for $pageTableAnchor in $pageTableAnchors + let $tableHref := string($pageTableAnchor/@xlink:href) + let $pageTableTmp := $document//xhtml:table[@xlink:label = $tableHref] + let $pageTable := subsequence($pageTableTmp, 1, 1) + return + $pageTable +let $pageNoteAnchors := $returnPageFragment//anchor[@type = 'note'] +let $pageNotes := + if ($docbase = "echo") + then + for $pageNoteAnchor in $pageNoteAnchors + let $noteHref := string($pageNoteAnchor/@xlink:href) + let $pageNoteTmp := $document//echo:note[@xlink:label = $noteHref] + let $pageNote := subsequence($pageNoteTmp, 1, 1) + return + $pageNote + else + $returnPageFragment//note + +(: Metadata handling: only metadata of the selected document is scanned :) +let $identifier := $documentIdentifier +let $authors := mpdl-lucene:getElementsByAttr($metadata, $docbase, "author") +let $titles := mpdl-lucene:getElementsByAttr($metadata, $docbase, "title") +let $places := mpdl-lucene:getElementsByAttr($metadata, $docbase, "place") +let $date := mpdl-lucene:getElementsByAttr($metadata, $docbase, "date") +let $rights := mpdl-lucene:getElementsByAttr($metadata, $docbase, "rights") +let $accessRights := mpdl-lucene:getElementsByAttr($metadata, $docbase, "accessRights") +let $licenses := mpdl-lucene:getElementsByAttr($metadata, $docbase, "license") +let $file := mpdl-lucene:getElementsByAttr($metadata, $docbase, "file") +let $translator := mpdl-lucene:getElementsByAttr($metadata, $docbase, "translator") +let $version := mpdl-lucene:getElementsByAttr($metadata, $docbase, "version") + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $xmlResult := + if ($errorCode < 10) + then + + + {$mpdlDocUri} + {$docbase} + {$documentName} + {$language} + {$authors} + {$titles} + {$places} + {$date} + {$identifier} + {$rights} + {$accessRights} + {$licenses} + {$file} + {$translator} + {$version} + {$countPages} + + + {$mode} + {$pn} + {$sn} +
    {$pageHeader}
    + {$pageNumberOrig} + {$digilibAvailable} + {$imageIsAvailable} + {$imageFileName} + {$imageEcho} + {$imageScaler} + ?document={$documentName}&pn={$pn}&mode=xml + {$imagesDocDirectory}/{$pageImageDirectory} + {$imagesDocDirectory}/{$figuresImageDirectory} + {$positionOfFirstFigureAfterPB1} + {$pageFigures} + {$pageHandwritten} + {$pageTables} + {$pageNotes} + {$returnPageFragment} + {$charNorm} + {$options} +
    + + {$queryType} + {$query} + {$queryResult} + + {$neededTime} +
    + else if ($errorCode = 10) + then {$errorCode}Fulltext document: {$mpdlDocUri} is not available yet + else if ($errorCode = 11) + then {$errorCode}No result: Page {$pn} not found + else if ($errorCode = 12) + then {$errorCode}View mode {$mode} not available + else {$errorCode}undefined error: {$errorCode} + +let $declare := + if ($errorCode > 9 or $mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml") + then util:declare-option("exist:serialize", "method=xhtml media-type=text/html omit-xml-declaration=no indent=yes encoding=utf-8") + else if ($mode = "pureXml") + then util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") + else util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8") +let $xslFilePath := + if($reqExport = "pdf") + then concat($presentationPath, "/pageFragmentHtml.xsl") + else if($mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml") + then concat($presentationPath, "/pageHtml.xsl") + else concat($presentationPath, "/pageXml.xsl") + +let $titleStr := concat(string-join($authors, ', '), ". ", string-join($titles, ', '), ". ", string-join($places, ', '), " ", $date, ".") +let $tmpResult := + if ($errorCode < 10 and $reqExport = "pdf") + then mpdl-text:html2pdf($language, $xmlResult, $xslFilePath, $titleStr, $pn, $mode) + else if ($errorCode < 10 and not($reqExport = "pdf")) + then mpdl-text:transform($xmlResult, $xslFilePath) + else +
    {$xmlResult}
    (: error xml result :) +let $result := + if ($errorCode < 10 and $reqExport = "pdf") + then response:stream-binary($tmpResult, "application/pdf", concat($documentName, "-page", $pn, ".pdf")) + else $tmpResult + +let $setHeaderXmlFilename := + if ($mode = "pureXml" and $queryType = "xpath" and $query != "") + then response:set-header('Content-Disposition', concat('filename=', $documentName, '-xpath-result--', $query, '--')) + else if ($mode = "pureXml" and $queryType = "xquery" and $query != "") + then response:set-header('Content-Disposition', concat('filename=', 'xquery-result')) + else if ($mode = "pureXml") + then response:set-header('Content-Disposition', concat('filename=', $documentName, '-page', $pn)) + else () + +return $result \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/presentation/functions-functx.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/presentation/functions-functx.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + (...) + + + + + + + + + (...) + + + + + + + + + + + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/presentation/functions-mpdl.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/presentation/functions-mpdl.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Could not fetch figure by nausikaa2.rz-berlin.mpg.de: please try again later + + + figure: {$figureNumber} + + + figure: {$figureNumber} + + + Figure: {$fullFigureFileName} not scanned + + + + +
    +
    + +
    + + + +
    +
    + + + + + +
    + Handwritten: {$href} not scanned +
    + +

    +

    +
    + + +
    \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/presentation/functions-text.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/presentation/functions-text.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (...) + + + + + + + + + + + + + + + (...) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/presentation/functions-util.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/presentation/functions-util.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,693 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    +
    + + + +
    +
    + +
    +
    +
    +
    + + + + +
    +
    + + + + + + + + + + + + + + + +
    + Page image: {$linkImageScaler} +
    +
    + +
    +










    + Page image:
    +
    + , page +

    + not scanned +
    +
    + +
    +










    + Could not fetch:
    +
    + , page +

    + from nausikaa2.rz-berlin.mpg.de: please try again later +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + +
      + +
    +
    + +
      + +
    +
    + +
      + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + +

    + + + + + + + + + + + + + + + +

    +
    +
    +
    + +
    +
    + + + + + +

    + + + + + + + + + + + + + + + +

    +
    +
    +
    +
    + + +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    +
    + + + +

    + + + + +

    +
    + + + + + + + + +
    + +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + +

    + + +

    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Anchor of type: , href: + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + +
    diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/presentation/pageHtml.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/presentation/pageHtml.css Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,245 @@ +/* general */ +.it { font-style:italic } /* DESpecs: _ _ and attribute "it" */ +.it span.it { font-style:normal } /* DESpecs: _ _ within a paragraph already in italics */ +.bf { font-weight:bold } /* DESpecs: */ +.sc { font-variant:small-caps } /* DESpecs: */ +.sub { vertical-align:sub; font-size:.8em } /* DESpecs: <_> */ /* line-height:1em; ? */ +.super { vertical-align:super; font-size:.8em } /* DESpecs: <^> */ +.sm { font-size:smaller } /* DESpecs: , if within

    */ +.ul { text-decoration:underline } /* DESpecs:

      */ +.ol { text-decoration:overline } /* DESpecs:
        */ +.st { text-decoration:line-through } /* DESpecs: */ +.red { color:red } /* DESpecs: */ +.sp { letter-spacing:0.3em } /* DESpecs: */ /* "font-stretch:wider;" is deprecated */ +.center { text-align:center } +.fr { font-family:'Lucida blackletter'} /* preliminary representation of Fraktur */ + +/* unused */ +.setoff { margin-left:2cm; margin-right:2cm } + +/* xml presentation */ +span.xml.elementName { font-weight:bold;color:purple; } +span.xml.attributeName { font-weight:bold; } +span.xml.attributeValue { color:blue; } +ul.xml.element { margin-left:0px;padding-left:8px } +ul.xml.element.highlight { background-color:#D3D3D3; } /* LightGrey */ + +/* drop cap (Initiale) */ +span.dc { + float: left; + font-family: Georgia; + font-size: 250%; + line-height: 0.8em; + text-transform: uppercase; /* immer als Großbuchstabe */ + margin-right: 10px; + padding-top: 1px; +} + +/* variables and numbers */ +span.var { font-style:italic; } +span.var.segment { font-style:italic; text-decoration:overline; } +span.var.line { font-style:italic; text-decoration:underline; } +span.var.gnomon { font-style:italic; text-decoration:line-through; } +span.num { color:maroon } + +/* foreign languages */ +span.foreign { color:green; } +span.foreign a:link { color:green; } +span.foreign a:visited { color:green; } +span.foreign.el span.foreign.grc span.foreign.greek { color:green; } +span.foreign.en span.foreign.english { color:green; } +span.foreign.fr span.foreign.french { color:green; } +span.foreign.la span.foreign.latin { color:green; } +/* ..... */ + + +/* indentation at the beginning of a paragraph: */ +span.sc { font-weight:bold; } +span.sc.it {font-weight:bold; font-style:italic; } + +/* regularized words */ +span.reg { color:purple; } + +/* ref */ +span.ref { font-style:italic; } + +/* quotes */ +div.q { margin-left:10px; font-style:italic; } +div.quote { margin-left:10px; font-style:italic; } +div.blockquote { margin-left:10px; font-style:normal; } +div.set-off { margin-left:10px; font-style:italic; } + +/* notes */ +span.note { font-style:italic; } + +/* GIS elements */ +span.place { background-color:#87F717; color:black; } /* Lawn green */ +span.person { background-color:#87F717; color:black; } /* Lawn green */ +span.time { background-color:#87F717; color:black; } /* Lawn green */ +span.event { background-color:#87F717; color:black; } /* Lawn green */ + +/* preliminary representations of single/double/wavy/circled lines in Chinese text */ +span.sl { text-decoration:underline; } /* DESpecs for Chinese: */ +span.dl { text-decoration:underline; } /* DESpecs for Chinese:
        */ +span.wl { text-decoration:underline; } /* DESpecs for Chinese: */ +span.cl { text-decoration:underline; } /* DESpecs for Chinese: */ + +/* sentence */ +span.s.highlight { background-color:#D3D3D3; } /* LightGrey */ +span.s:hover { background-color:#D3D3D3; } /* LightGrey */ + +/* highlighting */ +span.hit.highlight { background-color:#77DD77; } /* pastell green */ + +/* Links +a:link {text-decoration: none;} +a:visited {text-decoration: none} +a:active {text-decoration: none} +a:hover {text-decoration: underline; color: red;} + */ + +/* table */ +table { margin-left:30px; } + +table.toc { width:100%; margin-left:1px; } + +/* page splittings: hr etc. */ +hr.notesBottom { + border:none; + border-top:2px dashed black; + height:2px; + color:#000000; + background:transparent; +} + +div.handwritten { + margin-left:10%; +} + +/* divs */ +div.float.none { + margin-left:10%; +} +div.float.right { + float:right; + clear:both; + margin-right:10% +} + +/* toc elements */ +div.toc.float.right { + text-align:center; + vertical-align:top; + top:10%; + clear:right; + font-style:normal; +} +div.toc.float.right a:link, a:visited { + text-decoration: none; + font-style: normal; +} +div.toc.one { + clear: left; + text-align: left; + vertical-align:top; + float:left; + margin-left:2%; + width:75%; +} +div.toc.two { + clear:left; + text-align: left; + vertical-align:top; + float:left; + margin-left:2%; + width:75%; +} +div.toc.three { + clear:left; + text-align: left; + vertical-align:top; + float:left; + margin-left:2%; + width:75%; +} +div.toc.four div.toc.five div.toc.six div.toc.seven { + clear:left; + text-align: left; + vertical-align:top; + float:left; + margin-left:2%; + width:75%; +} + + +/* page styling for generating PDF documents with Flying Saucer */ +div.pageNumber { + display:none; +} +div.pageNumberOrig { + display:none; +} +div.countPages { + display:none; +} +div.countPlaces { + display:none; +} +div.countTocEntries { + display:none; +} +div.countFigureEntries { + display:none; +} +div.pageHeaderTitle { + font-weight:bold; + text-align:center; +} +body { + counter-reset: pn; +} +div.page:before { + float:right; + font:11pt sans-serif; + font-weight:bold; + content:"[Page " counter(pn) "]"; + counter-increment:pn; + page:pdfPage; + clear:both; +} +div.page { + page-break-after:always; + page:pdfPage; + clear:both; +} +@page pdfPage { + size:A4; + margin-top:0.7cm; + margin-bottom:0.7cm; + margin-left:0.7cm; + margin-right:0.7cm; + padding:0.2cm; + border:thin solid #808080; + @top-left { font: 11pt sans-serif; padding-left: 0.2cm; padding-right: 1cm; font-weight:bold;}; + @top-right { font: 11pt sans-serif; white-space: nowrap; font-weight:bold;}; + @bottom-left { font: 11pt sans-serif; white-space: nowrap; font-weight:bold;}; + @bottom-right { font: 11pt sans-serif; white-space: nowrap; content: counter(page);}; +} + +div.tocPage { + page-break-after:always; + page:tocPage; +} +@page tocPage { + size:A4; + margin-top:0.7cm; + margin-bottom:0.7cm; + margin-left:0.7cm; + margin-right:0.7cm; + padding:0.2cm; + border:thin solid #808080; + @top-left { font: 11pt sans-serif; padding-left: 0.2cm; padding-right: 1cm; font-weight:bold;}; + @top-right { font: 11pt sans-serif; white-space: nowrap; font-weight:bold;}; + @bottom-left { font: 11pt sans-serif; white-space: nowrap; font-weight:bold;}; + @bottom-right { font: 11pt sans-serif; white-space: nowrap; content: counter(page);}; +} diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/presentation/pageHtml.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/presentation/pageHtml.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,1223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + . + , + . + + + + <xsl:value-of select="$bookTitle"/> + + + + +

        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        + + + + + + + + + + + + + + + + + + + + + +
        + + + + + + +
        + + + + + + + + + + + + +
        + + +
        /
        Page:
        +


        + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        + + + + + + + + + + + +
        +
        + + + + + + + + + +
        + + + +
        +
        + +

        Download
        Download PDF

        +
        + + + + + + + + + + +

        Download
        Download XML

        Download
        Download PDF

        +
        + + + + + + + + + + + +
        +
        + Page image: {$linkImageScaler} +
        +

        Download
        Download PDF

        +
        + +
        +










        + Page image:
        +
        + , page +

        + not scanned +
        +
        + +
        +










        + Could not fetch:
        +
        + , page +

        + from nausikaa2.rz-berlin.mpg.de: please try again later +
        +
        + +
        +
        + + Table of contents + + + Figures + + +
        + + + + + + + + + + + + + + + + +
        +
        + +
        + + + + + + + + + + + + + + +
        + + + Info +
        + +
        +
        + + + + + + + + +
        +
        + + + + + + + +
        + +
        +
        +
        +
        + +
        + + + + + + + + + +
        +
        + +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        + + + sentence hits + + + entries beginning with: ""
        +
        + + element hits + +
        /
        Page:
        + + + + + + + + + + + +
        + + Morphological expansion: see hereMorphological expansion: see here
        +
        +
        + + + + + + + + + + + + + + + + + + + + + + + + + +
        +
        + + + + +
        +
        +
        + + + +
        +
        +
        + + + + + + + + + + +
        . + + + + + + + + + + Page , Sentence + + + Page , Sentence / Page , continuation of the sentence + + + :
        + + +
        +
        + + + + + + + + + + + + + Lin Yutang + + + + + + + + + + + + + + + + Echo + + + + + Pollux + Pollux + + + + + Wiki + Wiki + + + + + + + + + + + + + +
        . + () [][][] +
        +
        + + + + + + + + + + + + +

        Download
        Download

        +
        +
        +
        + + +
        + Your query delivers an error: + +
        + +
        + No results +
        +
        +
        +
        + Elapsed time: ms, Back to query page, see the XQuery source and XSL source of this page +
        + + +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + +
          + +
        +
        + +
          + +
        +
        + +
          + +
        +
        +
        +
        + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        +
        + + + + + + +

        + + + + + + + + + + + + + + + +

        +
        +
        +
        + +
        +
        + + + + + +

        + + + + + + + + + + + + + + + +

        +
        +
        +
        +
        + + +

        +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        + + + +
        +
        + + + +

        + + + + +

        +
        + + + + + + + + +
        + +
        + + +
        +
        + + + + + + + + + + + + + + + + + + + +

        + + +

        +
        + +
        +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        +
        + + +
        +
        + + +
        +
        + + +
        +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Anchor of type: , href: + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + +
        diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/presentation/pageXml.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/presentation/pageXml.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/presentation/queryHtml.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/presentation/queryHtml.xsl Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        + + + +
        + + Morphological expansion: see here + + + Morphological expansion: see here + +
        +
        +
        + + + + + + + + + + + + + + + +
        + + + + +
        +
        + + + +
        +
        +
        + + + + +
        + +
        + + +
        +
        +
        +
        + + + + + + + + + + + Lin Yutang + + Echo + + + + + Pollux + Pollux + + + + + Wiki + Wiki + + + + + + + + + +
        + + () [][][] +
        +
        +
        + + +
        +
        + +
        +
        + + Download +
        +
        +
        +
        +
        +
        + + +
        + Your query delivers an error: + +
        +
        + +
        + No results +
        +
        +
        +
        +
        + + + + + + + + + + + + + <></> + + + </> + + + +
        +
        + + + ="" + + +
        diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/query.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/query.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,241 @@ +xquery version "1.0"; + +declare namespace request="http://exist-db.org/xquery/request"; + +let $attrQueryAuthor := "Monte" +let $attrQueryTitle := "Mech*" +let $ftQuery := "quantitas" +let $ftMorphQuery := "quantitas" + +return + + +MPDL project + + + +
        + + + + + + + + + + + + + + +
        + MPDL prototype Info MPDL + + Dedicated to Dr. Malcolm Hyman
        † September 4, 2009 +
        + powered by eXist + + Release 1.4
        + Nov, 2009
        +
        +
        + + + + + + + + + + + + + + + + + +
        + + + + + + + + + + + + +
        Documents: + Archimedes DTD
        + (until 2008) +
        + + + Echo Schema
        + (since 2009) +
        + + Info Document bases
        +
        + + + + + + + + + + + + + + + + +
        + + + + + + + Info Attribute search +
        + + + + + +
        + + + +
        +
        + + + + + +
        +
        +
        + + + + + +
        + Document contains + + + Info fulltext search +
        +
        + + + + + + + +
        + Document contains morphological + + + + Info morphological search +
        +
        +
        +

        + See the eXist XQuery documentation and the XQuery source of this page, if you find a bug let us know +
        Last MPDL software update: January, 2011 +

        + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/scheduler/get-jobs.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/scheduler/get-jobs.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,91 @@ +xquery version "1.0"; + +declare namespace request="http://exist-db.org/xquery/request"; +declare namespace util = "http://exist-db.org/xquery/util"; + +let $jobId := request:get-parameter("id", "all") + +let $result := mpdldoc:get-jobs($jobId) + +let $resultHtml := + for $operation in $result//mpdl-doc-operation + let $operationName := $operation/name + let $jobId := $operation/job-id + let $srcUrl := $operation/src/url + let $source := + if ($operationName = 'delete') + then () + else if (starts-with($srcUrl, 'file:')) + then + + Source +
          +
        • Upload file name: {$operation/src/upload-file-name}
        • +
        +
        + else + + Source +
          +
        • Url: {$operation/src/url}
        • +
        +
        + let $destUrl := + if ($operationName = 'create' or $operationName = 'update') + then + +
      1. Link to eSciDoc: {$operation/dest/escidoc-url}
      2. +
      3. Link to eXist: {$operation/dest/exist-url}
      4. +
        + else if ($operationName = 'updateExist') + then + +
      5. Link to eXist: {$operation/dest/exist-url}
      6. +
        + else () + let $errorMessage := $operation/status/error-message + let $errorLIEntry := + if ($errorMessage = 'no error') + then
      7. Error: {$errorMessage}
      8. + else
      9. Error: {$errorMessage}
      10. + let $operationHtmlTableData := + + + Refresh: operation status

        + Operation: {$operation/name}

        + Job-Id: {$operation/job-id}

        + Job status +

          +
        • Started: {$operation/status/started}
        • +
        • Finished: {$operation/status/finished}
        • +
        • Description: {$operation/status/description}
        • + {$errorLIEntry} +
        + {$source} + Destination +
          +
        • Document base: {$operation/dest/doc-base}
        • +
        • Language: {$operation/dest/language}
        • +
        • Document name: {$operation/dest/file-name}
        • + {$destUrl} +
        + Description: {$operation/description}

        +


        + +
        + return {$operationHtmlTableData} + +let $title := "Document operation status" +return + + +{$title} + + +

        {$title}

        + + {$resultHtml} +
        + See the XQuery source of this page, if you find a bug let us know + + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/sitemap.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/sitemap.xml Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,13 @@ + + +http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Alvarus_1509.xml&mode=text&pn=1 +http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Alvarus_1509.xml&mode=text&pn=2 +http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Alvarus_1509.xml&mode=text&pn=3 +http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Alvarus_1509.xml&mode=text&pn=4 +http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Alvarus_1509.xml&mode=text&pn=5 +http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Alvarus_1509.xml&mode=text&pn=6 +http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Alvarus_1509.xml&mode=text&pn=7 +http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Alvarus_1509.xml&mode=text&pn=8 +http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Alvarus_1509.xml&mode=text&pn=9 +http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Alvarus_1509.xml&mode=text&pn=10 + \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/text/all.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/text/all.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,333 @@ +xquery version "1.0"; + +module namespace mpdl-text = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/text"; + +import module namespace functx = "http://www.functx.com" at "../util/functx.xql"; + +declare namespace text = "http://exist-db.org/xquery/text"; +declare namespace util = "http://exist-db.org/xquery/util"; +declare namespace local = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/local"; + +declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/"; +declare namespace dcterms="http://purl.org/dc/terms"; + +declare function mpdl-text:insertNodeIdAttribute($element as element()) { + element {node-name($element)} + {$element/@*, attribute { "xmlNodeId" } { util:node-id($element) }, + for $child at $pos in $element/node() + return if ($child instance of element()) + then mpdl-text:insertNodeIdAttribute($child) + else $child + } +}; + +declare function mpdl-text:insertMyNodeIdAttribute($element as element()) { + mpdl-text:insertMyNodeIdAttribute($element, "1") +}; +declare function mpdl-text:insertMyNodeIdAttribute($element as element(), $myNodeId as xs:string) { + element {node-name($element)} + {$element/@*, attribute { "xmlNodeId" } { $myNodeId }, + for $child at $pos in $element/node() + return + if ($child instance of element()) + then mpdl-text:insertMyNodeIdAttribute($child, concat($myNodeId, ".", $pos)) + else $child + } +}; + +declare function mpdl-text:insert($fragment as element(), $externalObjects as element()*) { + let $firstObject := $externalObjects[1] + let $xmlNodeId := $firstObject/@xmlNodeId + let $posNode := $fragment//*[@xmlNodeId = $xmlNodeId] + let $before := $firstObject/@before + let $boolBefore := + if ($before = "true") + then true() + else false() + let $charPosStr := $firstObject/@charPos + let $charPos := + if($charPosStr != "" and not(empty($charPosStr))) + then number($charPosStr) + else -1 + let $newNode := $firstObject/content + let $size := count($externalObjects) + let $otherObjects := + if ($size > 1) + then subsequence($externalObjects, 2, $size) + else () + let $insertedFragment := mpdl-text:insert($fragment, $posNode, $boolBefore, $charPos, $newNode) + let $result := + if ($size >= 1) + then + mpdl-text:insert($insertedFragment, $otherObjects) + else + $fragment + return $result +}; + +declare function mpdl-text:insert($element as element(), $node, $before, $charPos, $newNode) { + if ($element = $node and $before and $charPos = -1) + then + ($newNode, + element {node-name($node)} + {$node/@*, + for $child in $node/node() + return if ($child instance of element()) + then mpdl-text:insert($child, $node, $before, $charPos, $newNode) + else $child + }) + else if ($element = $node and not($before) and $charPos = -1) + then + (element {node-name($node)} + {$node/@*, + for $child in $node/node() + return if ($child instance of element()) + then mpdl-text:insert($child, $node, $before, $charPos, $newNode) + else $child + }, $newNode) + else if ($element = $node and $charPos >= 0) + then + util:parse(mpdltext:insertAtCharPos(util:serialize($node, ()), util:serialize($newNode, ()), $charPos)) + else + element {node-name($element)} + {$element/@*, + for $child in $element/node() + return if ($child instance of element()) + then mpdl-text:insert($child, $node, $before, $charPos, $newNode) + else $child + } +}; + +declare function mpdl-text:indexTerms($mpdlCollectionName, $language, $document, $indexTermsStartStr, $pn as xs:int, $pageSize as xs:int) as node()* { + let $index := + if ($mpdlCollectionName = 'archimedes') + then $document/archimedes/text + else if ($mpdlCollectionName = 'echo') + then $document/echo:echo/echo:text + else $document/archimedes/text + let $from := ($pn * $pageSize) - $pageSize + 1 + let $to := $pn * $pageSize + let $maxTo := 10000 + let $callback := util:function(QName("http://www.mpiwg-berlin.mpg.de/ns/mpdl/local", "local:termEntries"), 2) + let $indexResult := text:index-terms($index, $indexTermsStartStr, $callback, $maxTo) + let $count := count($indexResult) + let $pages := + if ($count = 0) + then 0 + else $count idiv $pageSize + 1 + let $withPolluxKeys := 'true' + let $resultEntries := + for $entry at $pos in $indexResult + let $term := $entry/term + let $lexEntryKeys := + if ($withPolluxKeys = 'true') + then mpdltext:get-lex-entry-keys-by-form-name($language, $term) + else '' + let $lemmasWithOR := mpdltext:get-lemmasstr-by-form-name($language, $term) + where $pos >= $from and $pos <= $to + return + + {$entry/term} + {$lexEntryKeys} + {$lemmasWithOR} + {$entry/frequency} + {$entry/documents} + {$entry/position} + {$entry/rank} + + let $callbackBig5 := + if ($language = "zh") + then util:function(QName("http://www.mpiwg-berlin.mpg.de/ns/mpdl/local", "local:termEntriesInBig5"), 2) + else () + let $indexResultBig5 := + if ($language = "zh") + then text:index-terms($index, $indexTermsStartStr, $callbackBig5, $maxTo) + else () + let $resultEntriesBig5 := + if ($language = "zh") + then + for $entry at $pos in $indexResultBig5 + where $pos >= $from and $pos <= $to + return $entry + else () + + let $result := + + {$count} + {$pageSize} + {$pages} + {$pn} + {$resultEntries} + {$resultEntriesBig5} + + return $result +}; + +declare function local:termEntries($term as xs:string, $data as xs:int+) { + let $result := + + {$term} + {$data[1]} + {$data[2]} + {$data[3]} + {$data[4]} + + return $result +}; + +declare function local:termEntriesInBig5($term as xs:string, $data as xs:int+) { + let $encodedTerm := mpdltext:encode-big5($term) + let $result := + + {$encodedTerm} + + return $result +}; + +declare function mpdl-text:get-toc($docBase, $queryType, $document, $pn as xs:int, $pageSize as xs:int) { + let $from := ($pn * $pageSize) - $pageSize + 1 + let $to := $pn * $pageSize + let $tocEntriesAll := + if ($docBase = 'echo' and $queryType = 'toc') + then $document//echo:div[@type = 'section' or @type = 'chapter'] + else if ($docBase = 'echo' and $queryType = 'figures') + then $document//echo:figure + else if ($docBase = 'archimedes' and $queryType = 'figures') + then $document//figure + else () + let $tocEntriesAllTmp := + for $entry at $pos in $tocEntriesAll + let $pb := + if ($docBase = 'echo') + then $entry/preceding::echo:pb[1] + else $entry/preceding::pb[1] + let $pageNum := + if ($docBase = 'echo') + then count($pb/preceding::echo:pb) + 1 + else count($pb/preceding::pb) + 1 + let $level := + if ($queryType = 'toc') + then number($entry/@level) + else 1 + let $figureCaption := + if ($docBase = 'echo' and $queryType = 'figures' and not(empty($entry/echo:caption))) + then concat(': ', string-join($entry/echo:caption/text(), ' ')) + else '' + let $figureDescription := + if ($docBase = 'echo' and $queryType = 'figures' and not(empty($entry/echo:description))) + then concat(': ', string-join($entry/echo:description/text(), ' ')) + else '' + let $figureVariables := + if ($docBase = 'echo' and $queryType = 'figures' and not(empty($entry/echo:variables))) + then concat(' (Variables: ', string-join($entry/echo:variables/text(), ' '), ')') + else '' + let $figureAllDesc := + if ($docBase = 'echo' and $queryType = 'figures') + then concat($figureCaption, $figureDescription, $figureVariables) + else '' + let $content := + if ($docBase = 'echo' and $queryType = 'toc') + then string-join($entry/echo:head, ' ') + else if ($queryType = 'figures') + then concat('Figure', $figureAllDesc) + else () + return + + {$pageNum} + {$level} + {$content} + + let $tocEntriesAllTmpWithLevels := mpdltext:generate-toc-levels($tocEntriesAllTmp)/toc-entries/toc-entry + let $tocEntries := + for $entry at $pos in $tocEntriesAllTmpWithLevels + where $pos >= $from and $pos <= $to + return $entry + let $size := count($tocEntriesAll) + let $pages := + if ($size = 0) + then 0 + else $size idiv $pageSize + 1 + let $result := + + {$size} + {$pageSize} + {$pages} + {$pn} + {$tocEntries} + + return $result +}; + +declare function mpdl-text:getEchoArchivePath($mpdlDocUri) { + let $documentName := substring-before(substring-after(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/"), ".") + let $language := substring-before(substring-after(substring-after($mpdlDocUri, "/"), "/"), "/") + let $docbase := substring-before(substring-after($mpdlDocUri, "/"), "/") + let $fullDocumentUri := concat('/db/mpdl/documents/standard', $mpdlDocUri) + let $document := doc($fullDocumentUri) + let $metadata := + if ($docbase = 'archimedes') + then $document/archimedes/info + else if ($docbase = 'echo') + then $document/echo:echo/echo:metadata + else '' + let $documentIdentifier := + if ($docbase = 'archimedes') + then $metadata/locator + else if ($docbase = 'echo') + then $metadata/dcterms:identifier + else $metadata/dcterms:identifier + let $echoDocIdentifier := + if ($documentIdentifier != '') + then substring-before(substring-after($documentIdentifier, "ECHO:"), ".") + else '' + let $nausikaaURLTexter := "http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/servlet/Texter" + let $echoImageDir := + if ($docbase = 'archimedes') + then string($metadata/echodir) + else if ($docbase = 'echo') + then string($metadata/echo:echodir) + else '' + let $imagesDocDirectory := + if ($echoImageDir != '') + then $echoImageDir + else if ($docbase = 'archimedes') + then concat("/permanent/archimedes/", $documentName) + else if ($docbase = 'echo') + then concat("/permanent/library/", $echoDocIdentifier) + else '' + let $imagesDocDirectoryIndexMetaUrl := concat($nausikaaURLTexter, "?fn=", $imagesDocDirectory, "/index.meta") + let $digilibAvailable := mpdldoc:check-uri($imagesDocDirectoryIndexMetaUrl, 2000) + let $imagesDocDirectoryIndexMeta := + if ($digilibAvailable) + then doc($imagesDocDirectoryIndexMetaUrl) + else "XXXXDigilibNotAvailableXXXX" + let $archivePath := + if ($digilibAvailable) + then string($imagesDocDirectoryIndexMeta/resource/archive-path) + else $imagesDocDirectoryIndexMeta + return $archivePath +}; + +declare function mpdl-text:transform($inputXml, $xslFileName) { + let $pageXslDoc := doc($xslFileName) + let $result := transform:transform($inputXml, $pageXslDoc, ()) + return $result +}; + +declare function mpdl-text:html2pdf($language, $inputXml, $xslFileName, $title, $pageNumber, $mode) { + let $pageXslDoc := doc($xslFileName) + let $htmlPageFragment := transform:transform($inputXml, $pageXslDoc, ()) + let $topLeftStr := $title + let $topRightStr := concat("Page ", $pageNumber, " (" counter(page) ")") + let $bottomLeftStr := concat("View mode: ", $mode) + let $currentTime := current-dateTime() + let $year := year-from-dateTime($currentTime) + let $month := month-from-dateTime($currentTime) + let $day := day-from-dateTime($currentTime) + let $hours := hours-from-dateTime($currentTime) + let $minutes := minutes-from-dateTime($currentTime) + let $dateStr := concat("", $day, ".", $month, ".", $year, " ", $hours, ":", $minutes) + let $bottomRightStr := $dateStr + let $pdfResult := mpdldoc:html2pdf($htmlPageFragment, $language, $topLeftStr, $topRightStr, $bottomLeftStr, $bottomRightStr) + return $pdfResult +}; \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/util/functx.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/util/functx.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,62 @@ +xquery version "1.0"; + +module namespace functx = "http://www.functx.com"; + +declare function functx:path-to-node-with-pos( $node as node()? ) as xs:string { + string-join( + for $ancestor in $node/ancestor-or-self::* + let $sibsOfSameName := $ancestor/../*[name() = name($ancestor)] + return + concat(name($ancestor), + if (count($sibsOfSameName) <= 1) + then '' + else concat('[', functx:index-of-node($sibsOfSameName, $ancestor),']')) + , '/') + }; + +declare function functx:index-of-node( $nodes as node()*, $nodeToFind as node() ) as xs:integer* { + for $seq in (1 to count($nodes)) + return $seq[$nodes[$seq] is $nodeToFind] +}; + +declare function functx:substring-before-last( $arg as xs:string?, $delim as xs:string ) as xs:string { + if (matches($arg, functx:escape-for-regex($delim))) + then replace($arg, + concat('^(.*)', functx:escape-for-regex($delim),'.*'), + '$1') + else '' +}; + +declare function functx:substring-after-last( $arg as xs:string?, $delim as xs:string ) as xs:string { + replace ($arg,concat('^.*',functx:escape-for-regex($delim)),'') +}; + +declare function functx:escape-for-regex( $arg as xs:string? ) as xs:string { + replace($arg, + '(\.|\[|\]|\\|\||\-|\^|\$|\?|\*|\+|\{|\}|\(|\))','\\$1') +}; + +declare function functx:trim($arg as xs:string?) as xs:string { + replace(replace($arg,'\s+$',''),'^\s+','') +}; + + declare function functx:value-intersect + ( $arg1 as xs:anyAtomicType* , + $arg2 as xs:anyAtomicType* ) as xs:anyAtomicType* { + + distinct-values($arg1[.=$arg2]) +}; + +declare function functx:value-except + ( $arg1 as xs:anyAtomicType* , + $arg2 as xs:anyAtomicType* ) as xs:anyAtomicType* { + + distinct-values($arg1[not(.=$arg2)]) +}; + +declare function functx:value-union + ( $arg1 as xs:anyAtomicType* , + $arg2 as xs:anyAtomicType* ) as xs:anyAtomicType* { + + distinct-values(($arg1, $arg2)) +}; \ No newline at end of file diff -r 2396a569e446 -r 5589d865af7a software/eXist/webapp/mpdl/util/time.xql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/util/time.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,7 @@ +xquery version "1.0"; + +module namespace mpdl-time = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/util/time"; + +declare function mpdl-time:duration-as-ms($t) { + round((minutes-from-duration($t) * 60 + seconds-from-duration($t)) * 1000 ) +};