Mercurial > hg > mpdl-group
diff software/eXist/webapp/mpdl/lt/lex.xql @ 7:5589d865af7a
Erstellung XQL/XSL Applikation
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 08 Feb 2011 15:16:46 +0100 |
parents | |
children |
line wrap: on
line diff
--- /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 <bla><text>[<i>Remark: lexical entry in lexicon has no valid XML, so only the Betacode text version of the entry could be displayed</i>]</text><p></p>{$lexEntryOriginalContent}</bla> + return <li>{($lexEntryContentParsed)}</li> + let $lexiconLi := + <li><b>{$lexDescription}</b> + <ul>{$liLexEntryContent}</ul> + </li> + return $lexiconLi + +let $queryResultHeaderStr := + if ($formName != '') + then <h3>Mpdl-Pollux: Result of your query: Language={$language}, Form={$formName}</h3> + else <h3>Mpdl-Pollux: Result of your query: Language={$language}, Query={$luceneQuery}</h3> + +let $currentTimeEnd := util:system-time() +let $neededTime := mpdl-time:duration-as-ms($currentTimeEnd - $currentTimeBegin) + +let $retHtmlResult := + <html> + <head> + <title>Mpdl-Pollux</title> + </head> + <body> + {$queryResultHeaderStr} + <table align="right"> + <td align="right">[<i>This is a MPDL <a href="http://archimedes.fas.harvard.edu/pollux">Pollux</a> service</i>] <a href="../info.xql?info=pollux" onclick="window.open("../info.xql?info=pollux", "InfoWindow", "menubar=no,width=500,height=500,toolbar=no");return false"><img src="../images/info.png" valign="bottom" width="15" height="15" border="0" alt="MPDL Pollux service"/></a></td> + </table> + <text> </text> + <p/> + {$htmlLexica} + <hr/> + <p/> + Elapsed time: {$neededTime} ms, see the <a href="/exist/xquery.xml">XQuery documentation</a> and the <a href="lex.xql?_source=yes">XQuery source</a> of this page, if you find a bug <a href="https://itgroup.mpiwg-berlin.mpg.de:8080/tracs/mpdl-project-software/newticket">let us know</a> + </body> + </html> + +return $retHtmlResult \ No newline at end of file