Mercurial > hg > mpdl-group
view software/eXist/webapp/mpdl/doc/doc-operation-exist.xql @ 11:d6f528ad5d96
TEI Unterst?tzung, Fehlerbehebungen, externe Objekte
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 11 Mar 2011 13:34:02 +0100 |
parents | 5589d865af7a |
children | 469d927b9ca7 |
line wrap: on
line source
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 := <script type="text/javascript"> <!-- function DocumentSelection() { var existIdentifier = document.docBaseList.doc[document.docBaseList.doc.selectedIndex].value; var existLink = "http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=".concat(existIdentifier); var existIdentifierSplit = existIdentifier.split("/"); var docBase = existIdentifierSplit[1]; var language = existIdentifierSplit[2]; var fileName = existIdentifierSplit[3]; document.formDocOperation.docBase.value = docBase; document.formDocOperation.language.value = language; document.formDocOperation.fileName.value = fileName; document.getElementById("existLink").href = existLink; document.getElementById("existLink").firstChild.nodeValue = existIdentifier; document.formDocOperation.srcLocalFileName.value = ""; document.formDocOperation.srcUrl.value = ""; } function OperationSelection() { if (document.formDocOperation.operation.selectedIndex == 1) { document.formDocOperation.srcLocalFileName.value = ""; document.formDocOperation.srcUrl.value = ""; } } function LocalFileNameSelection() { var srcLocalFileName = document.formDocOperation.srcLocalFileName.value; document.formDocOperation.fileName.value = srcLocalFileName; document.formDocOperation.srcUrl.value = ""; document.getElementById("existLink").href = ""; document.getElementById("existLink").firstChild.nodeValue = ""; } function UrlSelection() { var srcUrl = document.formDocOperation.srcUrl.value; var startPos = srcUrl.lastIndexOf("/"); var endPos = srcUrl.length; var fileName = srcUrl.substring(startPos + 1, endPos); document.formDocOperation.fileName.value = fileName; document.formDocOperation.srcLocalFileName.value = ""; document.getElementById("existLink").href = ""; document.getElementById("existLink").firstChild.nodeValue = ""; } function ResetSrcLocalFileName() { document.formDocOperation.srcLocalFileName.value = ""; document.formDocOperation.srcUrl.value = ""; document.formDocOperation.fileName.value = ""; } function DocBaseRefreshDest() { var docBase = document.formDocOperation.docBase[document.formDocOperation.docBase.selectedIndex].value; DocBaseRefresh(docBase); } function DocBaseRefreshList() { var docBase = document.docBaseList.docBase[document.docBaseList.docBase.selectedIndex].value; DocBaseRefresh(docBase); } function DocBaseRefresh(docBase) { document.docBaseList.docBase.value = docBase; for (i = 0; i < document.docBaseList.doc.length; i++) document.docBaseList.doc[i].selected = false; document.docBaseList.submit(); } function LanguageRefreshDest() { var lang = document.formDocOperation.language[document.formDocOperation.language.selectedIndex].value; LanguageRefresh(lang); } function LanguageRefreshList() { var lang = document.docBaseList.language[document.docBaseList.language.selectedIndex].value; LanguageRefresh(lang); } function LanguageRefresh(language) { document.docBaseList.language.value = language; for (i = 0; i < document.docBaseList.doc.length; i++) document.docBaseList.doc[i].selected = false; document.docBaseList.submit(); } --> </script> let $eSciDocCookieId := session:get-attribute("eSciDocCookieId") let $docBaseOptions := <select> <option value ="archimedes">Archimedes</option> <option value ="echo">Echo</option> <option value ="tei">TEI</option> </select> 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 := <select name="docBase" onchange="DocBaseRefreshDest()">{$docBaseOptionsSelected}</select> let $docBaseSelectBoxList := <select name="docBase" onchange="DocBaseRefreshList()">{$docBaseOptionsSelected}</select> let $languageOptions := <select> <option value = "ar">Arabic</option> <option value = "zh">Chinese</option> <option value = "nl">Dutch</option> <option value = "en">English</option> <option value = "fr">French</option> <option value = "de">German</option> <option value = "el">Greek</option> <option value = "it">Italian</option> <option value = "la">Latin</option> </select> 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 := <select name="language" onchange="LanguageRefreshDest()">{$languageOptionsSelected}</select> let $languageSelectBoxList := <select name="language" onchange="LanguageRefreshList()">{$languageOptionsSelected}</select> let $docsSelectBoxOptions := for $docFileName at $pos in $docFileNames let $existIdentifier := concat("/", $docBase, "/", $language, "/", $docFileName) let $option := <option value ="{$existIdentifier}">{$docFileName}</option> order by $docFileName return $option let $docsSelectBox := <select name="doc" style="width: 100%;" size="20" onclick="DocumentSelection()"> {$docsSelectBoxOptions} </select> let $error := if ($eSciDocCookieId = '' or empty($eSciDocCookieId)) then <bla>No login context available. Please <a href="login-exist.xql">login</a> before you do an operation</bla> else "no" let $resultHtml := if ($error = 'no') then <div> <table align="middle" width="100%" rules="all" border="1" cellpadding="15"> <colgroup> <col width="50%"/> <col width="50%"/> </colgroup> <tr> <td valign="top"> <form name="formDocOperation" action="{session:encode-url(xs:anyURI('doc-operation-result-exist.xql'))}" method="post" enctype="multipart/form-data"> <table> <tr><td><b>Destination</b></td></tr> <tr> <td> Document base: {$docBaseSelectBoxDest} Language: {$languageSelectBoxDest} </td> </tr> <tr><td><br/></td></tr> <tr><td>Document name: <input type="text" size="40" name="fileName" value=""/> <a href="../info.xql?info=docInterfaceDestDocName" onclick="window.open("../info.xql?info=docInterfaceDestDocName", "InfoWindow", "menubar=no,width=500,height=500,toolbar=no");return false"><img src="../images/info.png" valign="bottom" width="18" height="18" border="0" alt="Info document interface source"/></a></td></tr> <tr><td>Document link: <a id="existLink" href=""></a></td></tr> <tr><td><br/></td></tr> <tr><td><b>Source <a href="../info.xql?info=docInterfaceSource" onclick="window.open("../info.xql?info=docInterfaceSource", "InfoWindow", "menubar=no,width=500,height=500,toolbar=no");return false"><img src="../images/info.png" valign="bottom" width="18" height="18" border="0" alt="Info document interface source"/></a></b></td></tr> <tr><td>Local file: <input type="file" size="40" name="srcLocalFileName" onchange="LocalFileNameSelection()" maxlength="10000000" accept="text/xml" value="srcLocalFileName"/> <input type="button" name="resetSrcLocalFileName" value="Reset" onclick="ResetSrcLocalFileName()"/></td></tr> <tr><td><text style="margin-left:10px;"></text>or</td></tr> <tr><td>Url: <input type="text" size="40" name="srcUrl" onchange="UrlSelection()" value=""/></td></tr> <tr><td><br/></td></tr> <tr> <td> <b>Operation</b><br/> <select name="operation" onchange="OperationSelection()"> <option value ="updateExist" selected="true">Create/Update</option> <option value ="deleteExist">Delete</option> </select> <input type="submit" name="performOperation" value="Execute"/> <a href="../info.xql?info=docInterfaceOperation" onclick="window.open("../info.xql?info=docInterfaceOperation", "InfoWindow", "menubar=no,width=500,height=500,toolbar=no");return false"><img src="../images/info.png" valign="bottom" width="18" height="18" border="0" alt="Info document interface operation"/></a> </td> </tr> </table> </form> </td> <td valign="top"> <form name="docBaseList" action="doc-operation-exist.xql" method="get"> <table> <tr> <td> <b>Documents</b><br/> <br/> Document base: {$docBaseSelectBoxList} Language: {$languageSelectBoxList} </td> </tr> <tr><td>{$docsSelectBox}</td></tr> </table> </form> </td> </tr> </table> </div> else <div><b>Error in operation:</b> {$error}</div> let $title := "MPDL: eXist document interface" return <html> <head> <title>{$title}</title> {$javascriptHtml} </head> <body> <h1>{$title}</h1> {$resultHtml} <br/> See the <a href="doc-operation-exist.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>