changeset 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 59ff47d1e237
children fba5577e49d9
files software/eXist/webapp/mpdl/_stuff/tmp/mathML.html software/eXist/webapp/mpdl/attribute-query-result.xql software/eXist/webapp/mpdl/doc/doc-operation-exist.xql software/eXist/webapp/mpdl/info.xql software/eXist/webapp/mpdl/interface/doc-query.xql software/eXist/webapp/mpdl/interface/echo/echoDocuView.xql software/eXist/webapp/mpdl/interface/lt/wordInfo.xql software/eXist/webapp/mpdl/interface/page-fragment.xql software/eXist/webapp/mpdl/interface/queryResult.xql software/eXist/webapp/mpdl/interface/xpath.xql software/eXist/webapp/mpdl/interface/xquery.xql software/eXist/webapp/mpdl/lucene/search.xql software/eXist/webapp/mpdl/page-query-result.xql software/eXist/webapp/mpdl/presentation/functions-mpdl.xsl software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl software/eXist/webapp/mpdl/presentation/pageHtml.css software/eXist/webapp/mpdl/presentation/pageHtml.xsl software/eXist/webapp/mpdl/query.xql software/eXist/webapp/mpdl/text/all.xql
diffstat 19 files changed, 800 insertions(+), 185 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/eXist/webapp/mpdl/_stuff/tmp/mathML.html	Fri Mar 11 13:34:02 2011 +0100
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html
+  PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
+         "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+  <head>
+    <meta name="language" content="en-US"/>
+    <meta name="description" content="Example of MathML embedded in an XHTML file"/>
+    <meta name="keywords" content="Example of MathML embedded in an XHTML file"/>
+    <title>Example of MathML embedded in an XHTML file</title>
+  </head>
+  <body>
+    <h1>Example of MathML embedded in an XHTML file</h1>
+
+
+    <p>
+      Given the quadratic equation
+      <math xmlns="http://www.w3.org/1998/Math/MathML">
+        <mrow>
+          <mi>a</mi>
+          <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
+          <msup>
+            <mi>x</mi>
+            <mn>2</mn>
+          </msup>
+          <mo>+</mo>
+          <mi>b</mi>
+          <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
+          <mi>x</mi>
+          <mo>+</mo>
+          <mi>c</mi>
+        </mrow>
+      </math>
+      , the roots are given by
+      <math xmlns="http://www.w3.org/1998/Math/MathML">
+        <mrow>
+          <mi>x</mi>
+          <mo>=</mo>
+          <mfrac>
+            <mrow>
+              <mo form="prefix">&#x2212;<!-- &minus; --></mo>
+              <mi>b</mi>
+              <mo>&#x00B1;<!-- &PlusMinus; --></mo>
+              <msqrt>
+                <msup>
+                  <mi>b</mi>
+                  <mn>2</mn>
+                </msup>
+                <mo>&#x2212;<!-- &minus; --></mo>
+                <mn>4</mn>
+                <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
+                <mi>a</mi>
+                <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
+                <mi>c</mi>
+              </msqrt>
+            </mrow>
+            <mrow>
+              <mn>2</mn>
+              <mo>&#x2062;<!-- &InvisibleTimes; --></mo>
+              <mi>a</mi>
+            </mrow>
+          </mfrac>
+        </mrow>
+      </math>
+      .
+    </p>
+
+  </body>
+</html>
--- a/software/eXist/webapp/mpdl/attribute-query-result.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/attribute-query-result.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -7,6 +7,8 @@
 declare namespace request="http://exist-db.org/xquery/request";
 
 declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/";
+declare namespace TEI="http://www.tei-c.org/ns/1.0";
+
 declare namespace dc="http://purl.org/dc/elements/1.1/";
 declare namespace dct="http://purl.org/dc/terms/1.0/";
 declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
@@ -43,28 +45,47 @@
 
 let $docBaseArch := "archimedes"
 let $docBaseEcho := "echo"
+let $docBaseTei := "tei"
 let $fulltextMorphArchDocPath := concat($docPathMorph, "/", $docBaseArch, "/", $language)
 let $fulltextMorphEchoDocPath := concat($docPathMorph, "/", $docBaseEcho, "/", $language)
+let $fulltextMorphTeiDocPath := concat($docPathMorph, "/", $docBaseTei, "/", $language)
 let $fulltextMorphCollection := 
-  if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho))
+  if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei))
+  then collection($fulltextMorphArchDocPath, $fulltextMorphEchoDocPath, $fulltextMorphTeiDocPath)
+  else if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)))
   then collection($fulltextMorphArchDocPath, $fulltextMorphEchoDocPath)
-  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)))
+  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei))
+  then collection($fulltextMorphArchDocPath, $fulltextMorphTeiDocPath)
+  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei))
+  then collection($fulltextMorphEchoDocPath, $fulltextMorphTeiDocPath)
+  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and not(contains($docbase, $docBaseTei)))
   then collection($fulltextMorphArchDocPath)
-  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho))
+  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)))
   then collection($fulltextMorphEchoDocPath)
+  else if(not(contains($docbase, $docBaseArch)) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei))
+  then collection($fulltextMorphTeiDocPath)
   else ()
 
 let $fulltextStandardArchDocPath := concat($docPathStandard, "/", $docBaseArch)
 let $fulltextStandardEchoDocPath := concat($docPathStandard, "/", $docBaseEcho)
+let $fulltextStandardTeiDocPath := concat($docPathStandard, "/", $docBaseTei)
 let $fulltextStandardCollectionStr := 
-  if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho))
+  if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei))
+  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardEchoDocPath, "', '", $fulltextStandardTeiDocPath, "')")
+  else if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)))
   then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardEchoDocPath, "')")
-  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)))
+  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei))
+  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardTeiDocPath, "')")
+  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei))
+  then concat("collection('", $fulltextStandardEchoDocPath, "', '", $fulltextStandardTeiDocPath, "')")
+  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and not(contains($docbase, $docBaseTei)))
   then concat("collection('", $fulltextStandardArchDocPath, "')")
-  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho))
+  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)))
   then concat("collection('", $fulltextStandardEchoDocPath, "')")
+  else if(not(contains($docbase, $docBaseArch)) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei))
+  then concat("collection('", $fulltextStandardTeiDocPath, "')")
   else ""
-let $metadataStr := concat("(", $fulltextStandardCollectionStr, "/archimedes/info", "|" , $fulltextStandardCollectionStr, "/echo:echo/echo:metadata", ")")
+let $metadataStr := concat("(", $fulltextStandardCollectionStr, "/archimedes/info", "|" , $fulltextStandardCollectionStr, "/echo:echo/echo:metadata", "|" , $fulltextStandardCollectionStr, "/TEI:TEI/TEI:teiHeader", ")")
 let $fulltextStandardCollection := 
   if($fulltextStandardCollectionStr != "")
   then util:eval($fulltextStandardCollectionStr)
--- a/software/eXist/webapp/mpdl/doc/doc-operation-exist.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/doc/doc-operation-exist.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -114,6 +114,7 @@
           <select>
             <option value ="archimedes">Archimedes</option>
             <option value ="echo">Echo</option>
+            <option value ="tei">TEI</option>
           </select>
 let $docBaseOptionsSelected :=
   for $option in $docBaseOptions/option
@@ -175,7 +176,7 @@
   if ($error = 'no')
   then 
     <div>
-    <table align="middle" width="100%">
+    <table align="middle" width="100%" rules="all" border="1" cellpadding="15">
       <colgroup>
         <col width="50%"/>
         <col width="50%"/>
@@ -184,9 +185,28 @@
       <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>Operation</b></td></tr>
+          <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(&quot;../info.xql?info=docInterfaceDestDocName&quot;, &quot;InfoWindow&quot;, &quot;menubar=no,width=500,height=500,toolbar=no&quot;);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(&quot;../info.xql?info=docInterfaceSource&quot;, &quot;InfoWindow&quot;, &quot;menubar=no,width=500,height=500,toolbar=no&quot;);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>
@@ -195,26 +215,6 @@
               <a href="../info.xql?info=docInterfaceOperation" onclick="window.open(&quot;../info.xql?info=docInterfaceOperation&quot;, &quot;InfoWindow&quot;, &quot;menubar=no,width=500,height=500,toolbar=no&quot;);return false"><img src="../images/info.png" valign="bottom" width="18" height="18" border="0" alt="Info document interface operation"/></a>
             </td>
           </tr>
-          <tr><td><br/></td></tr>
-          <tr><td><b>Source <a href="../info.xql?info=docInterfaceSource" onclick="window.open(&quot;../info.xql?info=docInterfaceSource&quot;, &quot;InfoWindow&quot;, &quot;menubar=no,width=500,height=500,toolbar=no&quot;);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>Destination</b></td></tr>
-          <tr>
-            <td>Document base: 
-              {$docBaseSelectBoxDest}
-            </td>
-          </tr>
-          <tr>
-            <td>Language: 
-              {$languageSelectBoxDest}
-            </td>
-          </tr>
-          <tr><td>Document name: <input type="text" size="40" name="fileName" value=""/> <a href="../info.xql?info=docInterfaceDestDocName" onclick="window.open(&quot;../info.xql?info=docInterfaceDestDocName&quot;, &quot;InfoWindow&quot;, &quot;menubar=no,width=500,height=500,toolbar=no&quot;);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>
         </table>
         </form>
       </td>
@@ -253,7 +253,7 @@
 <body>
   <h1>{$title}</h1>
   {$resultHtml}
-  <hr/>
+  <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>
\ No newline at end of file
--- a/software/eXist/webapp/mpdl/info.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/info.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -33,7 +33,7 @@
   else if ($info = 'malcolm')
   then (<h2><img alt="Malcolm Hyman" align="right" src="images/malcolm.jpg" width="30%" height="30%"/>Dr. Malcolm Hyman<br/> † September 4, 2009</h2>, <h3>In memoriam</h3>, '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.', <h3>His homepages</h3>, <ul><li><a href="http://archimedes.fas.harvard.edu/mdh">Harvard University, Department of the Classics</a></li><li><a href="http://www.mpiwg-berlin.mpg.de/en/staff/members/hyman">Max Planck Institute for the History of Science</a></li><li><a href="http://www.harvardscience.harvard.edu/directory/researchers/malcolm-hyman">HarvardScience</a></li></ul>)
   else if ($info = 'docBases')
-  then (<b>Archimedes DTD (until 2008): </b>, 'more than 120 documents (4KB - 18MB), coming from Echo collections &quot;Archimedes&quot; and &quot;Historical Travel Guides&quot;, languages: latin, italian, english, german, french, dutch, greek, arabic, chinese', <br/>, <br/>, <b>Echo Schema (since2009): </b>, 'planned more than 100 documents in different languages')
+  then (<b>Archimedes DTD (until 2008): </b>, 'more than 120 documents (4KB - 18MB), coming from Echo collections &quot;Archimedes&quot; and &quot;Historical Travel Guides&quot;, languages: latin, italian, english, german, french, dutch, greek, arabic, chinese', <br/>, <br/>, <b>Echo Schema (since 2009): </b>, 'planned more than 100 documents in different languages', <br/>, <br/>, <b>TEI Schema (since 2011): </b>, 'different languages, mainly by external document providers')
   else if ($info = 'attr')
   then ('Attribute search is case sensitive.', <p/>, 'Query syntax see: ', <a href="http://lucene.apache.org/java/2_3_2/queryparsersyntax.html">Lucene query syntax</a>, '.')
   else if ($info = 'fulltextMorph')
@@ -53,7 +53,7 @@
   else if ($info = 'docInterfaceOperation')
   then (<p><b>MPDL document interface: Operation</b><br/> 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.</p>)
   else if ($info = 'docInterfaceSource')
-  then (<p><b>MPDL document interface: Source document</b><br/> The source document has to be a valid XML-document against either the Echo schema (see the <a href="http://mpdl-proto.mpiwg-berlin.mpg.de/exist/rest/db/mpdl/schema/echo/echo.rnc">Echo Relax NG Schema</a>) or against the Archimedes document format</p>)
+  then (<p><b>MPDL document interface: Source document</b><br/> The source document has to be a valid XML-document against either the <a href="http://mpdl-proto.mpiwg-berlin.mpg.de/exist/rest/db/mpdl/schema/echo/echo.rnc">Echo Schema</a> or against the <a href="http://mpdl-proto.mpiwg-berlin.mpg.de/exist/rest/db/mpdl/schema/tei/teilite.rnc">TEI Lite schema</a> or against the Archimedes document format</p>)
   else if ($info = 'docInterfaceDestDocName')
   then (<p><b>MPDL document interface: Destination document name</b> <ul><li>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).</li> <li>always needs the extension &quot;.xml&quot;.</li><li>example: &quot;Benedetti_1585.xml&quot;</li></ul></p>)
   else ()
--- a/software/eXist/webapp/mpdl/interface/doc-query.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/interface/doc-query.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -41,12 +41,6 @@
 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
--- a/software/eXist/webapp/mpdl/interface/echo/echoDocuView.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/interface/echo/echoDocuView.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -6,7 +6,7 @@
 
 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 $echoURLDocuView := concat("http://mpdl-dev.mpiwg-berlin.mpg.de/ECHOdocuView?url=", $echoArchivePath, "&amp;optionToggle=1")
 let $urlDocuViewer := <a href="{$echoURLDocuView}">redirect to Echo</a>
 let $diglibAvailable := 
   if ($echoArchivePath = "XXXXDigilibNotAvailableXXXX")
--- a/software/eXist/webapp/mpdl/interface/lt/wordInfo.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/interface/lt/wordInfo.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -7,7 +7,7 @@
 
 (: TODO: Verlinkung von lemma, form, weiteren Einheiten in den Infos auf mpdl-proto (HTML und XML) :)
 
-let $type :=  request:get-parameter("type", "all")
+let $type :=  request:get-parameter("type", "compact")
 let $language := request:get-parameter("language", "")
 let $word := request:get-parameter("word", "")
 let $placeHref := request:get-parameter("placeHref", "")
@@ -21,7 +21,10 @@
   then ("no lemmas found for your query")
   else 
     for $lemma in $lemmas/lemmas/lemma
-      let $lemmaText := concat($lemma/lemma-name, " (", $lemma/provider, ")")
+      let $lemmaText := 
+        if ($type = "compact")
+        then $lemma/lemma-name
+        else concat($lemma/lemma-name, " (", $lemma/provider, ")")
       let $orderedFormsStrTmp :=
         for $form in $lemma/forms/form
           let $formStr := concat($form/form-name, " (", $form/provider, ")")
@@ -35,12 +38,18 @@
         then concat("http://www.perseus.tufts.edu/hopper/morph?l=", $lemma/lemma-name, "&amp;la=greek")
         else ""
       let $lemmaLi := 
-        if ($language = "ar" or $language = "el" or $language = "la")
+        if (($type = "all" or $type = "morph") and ($language = "ar" or $language = "el" or $language = "la"))
         then 
-          <li><b>Lemma: </b>{$lemmaText} (see this entry in <a href="{$remotePerseusLink}">www.perseus.tufts.edu</a>)
+          <li><b>Lemma: </b>{$lemmaText} (external link to <a href="{$remotePerseusLink}">www.perseus.tufts.edu</a>)
             <ul>{$orderedFormsStr}</ul>
           </li>
-        else 
+        else if ($type ="compact" and ($language = "ar" or $language = "el" or $language = "la"))
+        then
+          <li><b>Lemma: </b>{$lemmaText} (external link to <a href="{$remotePerseusLink}">www.perseus.tufts.edu</a>)</li>
+        else if ($type ="compact")
+        then
+          <li><b>Lemma: </b>{$lemmaText}</li>
+        else
           <li><b>Lemma: </b>{$lemmaText}
             <ul>{$orderedFormsStr}</ul>
           </li>
@@ -81,7 +90,7 @@
 let $lemmasStrTokenized := tokenize($lemmasStr, " ")
 
 let $dictionariesLocal := 
-  if ($type = "all" or $type = "dict")
+  if ($type = "all" or $type = "compact" or $type = "dict")
   then mpdltext:get-lex-entries-by-lucene-query($language, $lemmasStr)
   else ()
 let $dictionariesRemoteTmp := 
@@ -133,9 +142,21 @@
   then
     <lexica>
       <lexicon>
+        <name>ctp</name>
+        <description>Chinese Text Project</description>
+      </lexicon>
+      <lexicon>
         <name>linyutan</name>
         <description>Lin Yutang</description>
       </lexicon>
+      <lexicon>
+        <name>chinese-unicode</name>
+        <description>Unicode</description>
+      </lexicon>
+      <lexicon>
+        <name>chinese-wiktionary</name>
+        <description>Wiktionary</description>
+      </lexicon>
     </lexica>
   else ()
 
@@ -165,6 +186,12 @@
           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, "&amp;category=wholerecord")
+          else if ($lexName = "ctp")
+          then concat("http://ctext.org/dictionary.pl?if=en&amp;char=", $l)
+          else if ($lexName = "chinese-wiktionary")
+          then concat("http://en.wiktionary.org/wiki/", $l)
+          else if ($lexName = "chinese-unicode")
+          then concat("http://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=", $l)
           else ""
         let $lexiconEntry :=
           <entry>
@@ -299,35 +326,35 @@
   else ()
 
 let $dict := 
-  if (not(empty($retDictionaries)) and ($type = "all" or $type = "dict") and $output = "html")
+  if (not(empty($retDictionaries)) and ($type = "all" or $type = "compact" or $type = "dict") and $output = "html")
   then 
     <p>
       <h3>Dictionary</h3>
       <ul>{$retDictionaries}</ul>
     </p>
-  else if (empty($retDictionaries) and ($type = "all" or $type = "dict") and $output = "html")
+  else if (empty($retDictionaries) and ($type = "all" or $type = "compact" or $type = "dict") and $output = "html")
   then
     <p>
       <h3>Dictionary</h3>
       <ul>No information available</ul>
     </p>
-  else if (not(empty($retDictionaries)) and ($type = "all" or $type = "dict") and $output = "xml")
+  else if (not(empty($retDictionaries)) and ($type = "all" or $type = "compact" or $type = "dict") and $output = "xml")
   then $retDictionaries
   else ()
 let $morph := 
-  if (not(empty($htmlOrderedLemmas)) and ($type = "all" or $type = "morph") and $output = "html")
+  if ($language != "zh" and not(empty($htmlOrderedLemmas)) and ($type = "all" or $type = "compact" or $type = "morph") and $output = "html")
   then 
     <p>
       <h3>Morphology</h3>
       <ul>{$htmlOrderedLemmas}</ul>
     </p>
-  else if (empty($htmlOrderedLemmas) and ($type = "all" or $type = "morph") and $output = "html")
+  else if ($language != "zh" and empty($htmlOrderedLemmas) and ($type = "all" or $type = "compact" or $type = "morph") and $output = "html")
   then
     <p>
       <h3>Morphology</h3>
       <ul>No information available</ul>
     </p>
-  else if (not(empty($htmlOrderedLemmas)) and ($type = "all" or $type = "morph") and $output = "xml")
+  else if ($language != "zh" and not(empty($htmlOrderedLemmas)) and ($type = "all" or $type = "compact" or $type = "morph") and $output = "xml")
   then <morphologyEntries>{$xmlOrderedLemmas}</morphologyEntries>
   else if ($type = "morph" and $output = "string")
   then $lemmasStrWithoutWord
@@ -343,13 +370,13 @@
   then <wikiEntries>{$wikiArticles}</wikiEntries>
   else ()
 let $place := 
-  if (not(empty($places)) and ($type = "all" or $type = "place") and $output = "html")
+  if (not(empty($places)) and ($type = "all" or $type = "compact" or $type = "place") and $output = "html")
   then 
     <p>
       <h3>Place</h3>
       <ul>{$places}</ul>
     </p>
-  else if (not(empty($places)) and ($type = "all" or $type = "place") and $output = "xml")
+  else if (not(empty($places)) and ($type = "all" or $type = "compact" or $type = "place") and $output = "xml")
   then <placeEntries>{$places}</placeEntries>
   else ()
 
@@ -363,7 +390,7 @@
 
 let $queryResultHeaderStr := <h2>Word information for: {$word}</h2>
 let $commentExternalLinks := 
-   "[* no guarantee for external links]"
+   "[* external links may not function]"
 
 let $retXmlResult :=
   <word>
--- a/software/eXist/webapp/mpdl/interface/page-fragment.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/interface/page-fragment.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -13,6 +13,7 @@
 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/";
+declare namespace TEI="http://www.tei-c.org/ns/1.0";
 
 let $mpdlDocUri := request:get-parameter("document", "")
 let $mode := request:get-parameter("mode", "image")
@@ -44,6 +45,8 @@
   then $document/archimedes/info
   else if ($docbase = 'echo')
   then $document/echo:echo/echo:metadata
+  else if ($docbase = 'tei')
+  then $document/TEI:TEI/TEI:teiHeader
   else ''
 
 let $pageBreaks := 
@@ -51,6 +54,8 @@
   then $document//pb
   else if ($docbase = 'echo')
   then $document//echo:pb
+  else if ($docbase = 'tei')
+  then $document//TEI:pb
   else $document//pb
 let $countPagesTemp := count($pageBreaks)
 let $countPages := 
@@ -117,6 +122,8 @@
   then $metadata/locator
   else if ($docbase = 'echo')
   then $metadata/dcterms:identifier
+  else if ($docbase = 'tei')
+  then $metadata/TEI:fileDesc/TEI:publicationStmt/TEI:idno
   else $metadata/dcterms:identifier
 let $echoDocIdentifier := 
   if ($documentIdentifier != '')
@@ -139,6 +146,8 @@
   then concat("/permanent/archimedes/", $documentName)
   else if ($docbase = 'echo')
   then concat("/permanent/library/", $echoDocIdentifier)
+  else if ($docbase = 'tei')
+  then $documentIdentifier
   else ''
 let $imagesDocDirectoryIndexMetaUrl := 
   if ($mode = "image" or $mode = "text" or $mode = "textPollux" or $mode = "gis")
@@ -158,6 +167,8 @@
 let $pageImageFileNameWithoutExtension := 
   if ($docbase = 'echo')
   then concat("/", string($pb1/@file))
+  else if ($docbase = 'tei')
+  then concat("/", string($pb1/@facs))
   else ''
 let $imageFileName :=
   if ($reqPF = '')
@@ -182,6 +193,8 @@
   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 if ($docbase = 'tei')
+  then count($pb1/following::TEI:figure[1]/preceding::TEI:figure) + 1
   else ()
 
 let $pageFragmentTmp := 
--- a/software/eXist/webapp/mpdl/interface/queryResult.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/interface/queryResult.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -6,11 +6,12 @@
 declare namespace request="http://exist-db.org/xquery/request";
 
 declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/";
+declare namespace TEI="http://www.tei-c.org/ns/1.0";
+
 declare namespace dc="http://purl.org/dc/elements/1.1/";
 declare namespace dct="http://purl.org/dc/terms/1.0/";
 declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
 
-
 let $queryType := request:get-parameter("queryType", "")
 let $docbase := request:get-parameter("docbase", "")
 let $output := request:get-parameter("output", "html")
@@ -41,29 +42,51 @@
 
 let $docBaseArch := "archimedes"
 let $docBaseEcho := "echo"
+let $docBaseTei := "tei"
 let $fulltextMorphArchDocPath := concat($docPathMorph, "/", $docBaseArch, "/", $language)
 let $fulltextMorphEchoDocPath := concat($docPathMorph, "/", $docBaseEcho, "/", $language)
+let $fulltextMorphTeiDocPath := concat($docPathMorph, "/", $docBaseTei, "/", $language)
 let $fulltextMorphCollection := 
-  if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho))
+  if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei))
+  then collection($fulltextMorphArchDocPath, $fulltextMorphEchoDocPath, $fulltextMorphTeiDocPath)
+  else if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)))
   then collection($fulltextMorphArchDocPath, $fulltextMorphEchoDocPath)
-  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)))
+  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei))
+  then collection($fulltextMorphArchDocPath, $fulltextMorphTeiDocPath)
+  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei))
+  then collection($fulltextMorphEchoDocPath, $fulltextMorphTeiDocPath)
+  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and not(contains($docbase, $docBaseTei)))
   then collection($fulltextMorphArchDocPath)
-  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho))
+  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)))
   then collection($fulltextMorphEchoDocPath)
+  else if(not(contains($docbase, $docBaseArch)) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei))
+  then collection($fulltextMorphTeiDocPath)
   else ()
 
 let $fulltextStandardArchDocPath := concat($docPathStandard, "/", $docBaseArch)
 let $fulltextStandardEchoDocPath := concat($docPathStandard, "/", $docBaseEcho)
+let $fulltextStandardTeiDocPath := concat($docPathStandard, "/", $docBaseTei)
 let $fulltextStandardCollectionStr := 
-  if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho))
+  if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei))
+  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardEchoDocPath, "', '", $fulltextStandardTeiDocPath, "')")
+  else if(contains($docbase, $docBaseArch) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)))
   then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardEchoDocPath, "')")
-  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)))
+  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei))
+  then concat("collection('", $fulltextStandardArchDocPath, "', '", $fulltextStandardTeiDocPath, "')")
+  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and contains($docbase, $docBaseTei))
+  then concat("collection('", $fulltextStandardEchoDocPath, "', '", $fulltextStandardTeiDocPath, "')")
+  else if(contains($docbase, $docBaseArch) and not(contains($docbase, $docBaseEcho)) and not(contains($docbase, $docBaseTei)))
   then concat("collection('", $fulltextStandardArchDocPath, "')")
-  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho))
+  else if(not(contains($docbase, $docBaseArch)) and contains($docbase, $docBaseEcho) and not(contains($docbase, $docBaseTei)))
   then concat("collection('", $fulltextStandardEchoDocPath, "')")
+  else if(not(contains($docbase, $docBaseArch)) and not(contains($docbase, $docBaseEcho)) and contains($docbase, $docBaseTei))
+  then concat("collection('", $fulltextStandardTeiDocPath, "')")
+  else ""
+let $metadataStr := concat("(", $fulltextStandardCollectionStr, "/archimedes/info", "|" , $fulltextStandardCollectionStr, "/echo:echo/echo:metadata", "|" , $fulltextStandardCollectionStr, "/TEI:TEI/TEI:teiHeader", ")")
+let $fulltextStandardCollection := 
+  if($fulltextStandardCollectionStr != "")
+  then util:eval($fulltextStandardCollectionStr)
   else ()
-let $metadataStr := concat("(", $fulltextStandardCollectionStr, "/archimedes/info", "|" , $fulltextStandardCollectionStr, "/echo:echo/echo:metadata", ")")
-let $fulltextStandardCollection := util:eval($fulltextStandardCollectionStr)
 
 let $isAttributeSearch :=
   if ($queryType = "attribute")
--- a/software/eXist/webapp/mpdl/interface/xpath.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/interface/xpath.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -3,6 +3,7 @@
 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/";
+declare namespace TEI="http://www.tei-c.org/ns/1.0";
 
 (: ToDo wenn eine pn gegeben ist, wird momentan der namespace ignoriert  :)
 let $mpdlDocUri := request:get-parameter("document", "")
@@ -21,6 +22,8 @@
   then $document//pb
   else if ($docbase = 'echo' and $pn != -1)
   then $document//echo:pb
+  else if ($docbase = 'tei')
+  then $document//TEI:pb
   else $document//pb
 let $countPBs := count($pageBreaks)
 let $pb1 := subsequence($pageBreaks, $pn, 1)
--- a/software/eXist/webapp/mpdl/interface/xquery.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/interface/xquery.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -3,6 +3,7 @@
 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/";
+declare namespace TEI="http://www.tei-c.org/ns/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  :)
@@ -24,6 +25,8 @@
   then $document//pb
   else if ($docbase = 'echo')
   then $document//echo:pb
+  else if ($docbase = 'tei')
+  then $document//TEI:pb
   else $document//pb
 let $countPBs := count($pageBreaks)
 let $pb1 := subsequence($pageBreaks, $pn, 1)
--- a/software/eXist/webapp/mpdl/lucene/search.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/lucene/search.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -7,6 +7,7 @@
 declare namespace ft = "http://exist-db.org/xquery/lucene";
 
 declare namespace echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/";
+declare namespace TEI="http://www.tei-c.org/ns/1.0";
 
 declare namespace dc="http://purl.org/dc/elements/1.1/";
 declare namespace dcterms="http://purl.org/dc/terms";
@@ -15,7 +16,7 @@
   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)]
+    then $mpdlCollection/.[ft:query(archimedes/text, $queryStr) or ft:query(echo:echo/echo:text, $queryStr) or ft:query(TEI:TEI/TEI:text, $queryStr)]
     else
       <result>
         <error>{$luceneParseResult}</error>
@@ -41,6 +42,8 @@
     then $document//pb
     else if ($mpdlCollectionName = 'echo') 
     then $document//echo:pb
+    else if ($mpdlCollectionName = 'tei') 
+    then $document//TEI:pb
     else $document//pb
   let $luceneParseResult := mpdltext:lucene-parse-query($queryStr)
   let $t := 
@@ -50,6 +53,8 @@
     then $document//s[ft:query(., $query)]
     else if ($mpdlCollectionName = 'echo')
     then $document//echo:s[ft:query(., $query)]
+    else if ($mpdlCollectionName = 'tei')
+    then $document//TEI:s[ft:query(., $query)]
     else $document//s[ft:query(., $query)]
   let $from := ($pn * $pageSize) - $pageSize + 1
   let $to := $pn * $pageSize
@@ -73,6 +78,8 @@
         then count($pb/following::s[. << $s]) + 1
         else if ($mpdlCollectionName = 'echo')
         then count($pb/following::echo:s[. << $s]) + 1
+        else if ($mpdlCollectionName = 'tei')
+        then count($pb/following::TEI:s[. << $s]) + 1
         else count($pb/following::s[. << $s]) + 1
       let $position := $from - 1 + $pos
       let $resultElem := 
@@ -202,6 +209,8 @@
     then $doc/archimedes/info
     else if ($docBase = 'echo')
     then $doc/echo:echo/echo:metadata
+    else if ($docBase = 'tei')
+    then $doc/TEI:TEI/TEI:teiHeader
     else ()
   return $result	
 };
@@ -212,6 +221,8 @@
     then $doc/archimedes/text
     else if ($docBase = 'echo')
     then $doc/echo:echo/echo:text
+    else if ($docBase = 'tei')
+    then $doc/TEI:TEI/TEI:text
     else ()
   return $result	
 };
@@ -230,6 +241,7 @@
 declare function mpdl-lucene:getAttrQueryStr($attribute, $attrValue) {
   let $attrArch := mpdl-lucene:getElemNameByAttr("archimedes", $attribute)
   let $attrEcho := mpdl-lucene:getElemNameByAttr("echo", $attribute)
+  let $attrTei := mpdl-lucene:getElemNameByAttr("tei", $attribute)
   let $attrArchRelQueryStr :=
     if ($attribute = "date")
     then concat($attrArch, " = '", $attrValue, "'")
@@ -238,13 +250,25 @@
     if ($attribute = "date")
     then concat($attrEcho, " = '", $attrValue, "'")
     else concat("ft:query(", $attrEcho, ", '", $attrValue, "')")
+  let $attrTeiRelQueryStr :=
+    if ($attribute = "date")
+    then concat($attrTei, " = '", $attrValue, "'")
+    else concat("ft:query(", $attrTei, ", '", $attrValue, "')")
   let $result := 
-    if ($attrArch != "" and $attrEcho != "")
+    if ($attrArch != "" and $attrEcho != "" and $attrTei != "")
+    then concat($attrArchRelQueryStr, " or ",  $attrEchoRelQueryStr, " or ",  $attrTeiRelQueryStr)
+    else if ($attrArch != "" and $attrEcho != "" and $attrTei = "")
     then concat($attrArchRelQueryStr, " or ",  $attrEchoRelQueryStr)
-    else if ($attrArch = "" and $attrEcho != "")
+    else if ($attrArch != "" and $attrEcho = "" and $attrTei != "")
+    then concat($attrArchRelQueryStr, " or ",  $attrTeiRelQueryStr)
+    else if ($attrArch = "" and $attrEcho != "" and $attrTei != "")
+    then concat($attrEchoRelQueryStr, " or ",  $attrTeiRelQueryStr)
+    else if ($attrArch != "" and $attrEcho = "" and $attrTei = "")
+    then $attrArchRelQueryStr
+    else if ($attrArch = "" and $attrEcho != "" and $attrTei = "")
     then $attrEchoRelQueryStr
-    else if ($attrArch != "" and $attrEcho = "")
-    then $attrArchRelQueryStr
+    else if ($attrArch = "" and $attrEcho = "" and $attrTei != "")
+    then $attrTeiRelQueryStr
     else ""
   return $result
 };
@@ -252,55 +276,80 @@
 declare function mpdl-lucene:getElemNameByAttr($docBase, $attribute) {
   let $docBaseArch := "archimedes"
   let $docBaseEcho := "echo"
+  let $docBaseTei := "tei"
   let $result :=
     if ($docBase = $docBaseArch and $attribute = "author")
     then "author"
     else if ($docBase = $docBaseEcho and $attribute = "author")
     then "dcterms:creator"
+    else if ($docBase = $docBaseTei and $attribute = "author")
+    then "TEI:fileDesc/TEI:titleStmt/TEI:author"
     else if ($docBase = $docBaseArch and $attribute = "title")
     then "title"
     else if ($docBase = $docBaseEcho and $attribute = "title")
     then "dcterms:title"
+    else if ($docBase = $docBaseTei and $attribute = "title")
+    then "TEI:fileDesc/TEI:titleStmt/TEI:title"
     else if ($docBase = $docBaseArch and $attribute = "place")
     then "place"
     else if ($docBase = $docBaseEcho and $attribute = "place")
     then ""
+    else if ($docBase = $docBaseTei and $attribute = "place")
+    then "TEI:fileDesc/TEI:publicationStmt/TEI:pubPlace"
     else if ($docBase = $docBaseArch and $attribute = "date")
     then "date"
     else if ($docBase = $docBaseEcho and $attribute = "date")
     then "dcterms:date"
+    else if ($docBase = $docBaseTei and $attribute = "date")
+    then "TEI:fileDesc/TEI:publicationStmt/TEI:date"
     else if ($docBase = $docBaseArch and $attribute = "language")
     then "lang"
     else if ($docBase = $docBaseEcho and $attribute = "language")
     then "dcterms:language"
+    else if ($docBase = $docBaseTei and $attribute = "language")
+    then "TEI:profileDesc/TEI:langUsage/TEI:language/@ident"
     else if ($docBase = $docBaseArch and $attribute = "identifier")
     then "locator"
     else if ($docBase = $docBaseEcho and $attribute = "identifier")
     then "dcterms:identifier"
+    else if ($docBase = $docBaseTei and $attribute = "identifier")
+    then "identifier"
     else if ($docBase = $docBaseArch and $attribute = "rights")
     then ""
     else if ($docBase = $docBaseEcho and $attribute = "rights")
     then "dcterms:rights"
+    else if ($docBase = $docBaseTei and $attribute = "rights")
+    then "rights"
     else if ($docBase = $docBaseArch and $attribute = "license")
     then ""
     else if ($docBase = $docBaseEcho and $attribute = "license")
     then "dcterms:license"
+    else if ($docBase = $docBaseTei and $attribute = "license")
+    then ""
     else if ($docBase = $docBaseArch and $attribute = "accessRights")
     then ""
     else if ($docBase = $docBaseEcho and $attribute = "accessRights")
     then "dcterms:accessRights"
+    else if ($docBase = $docBaseTei and $attribute = "accessRights")
+    then "accessRights"
     else if ($docBase = $docBaseArch and $attribute = "file")
     then "cvs_file"
     else if ($docBase = $docBaseEcho and $attribute = "file")
     then ""
+    else if ($docBase = $docBaseTei and $attribute = "file")
+    then ""
     else if ($docBase = $docBaseArch and $attribute = "translator")
     then "translator"
     else if ($docBase = $docBaseEcho and $attribute = "translator")
     then ""
+    else if ($docBase = $docBaseTei and $attribute = "translator")
+    then ""
     else if ($docBase = $docBaseArch and $attribute = "version")
     then "cvs_version"
     else if ($docBase = $docBaseEcho and $attribute = "version")
     then ""
+    else if ($docBase = $docBaseTei and $attribute = "version")
+    then ""
     else ""
     
   return $result
@@ -309,6 +358,7 @@
 declare function mpdl-lucene:getElementsByAttr($metadata, $docBase, $attribute) {
   let $docBaseArch := "archimedes"
   let $docBaseEcho := "echo"
+  let $docBaseTei := "tei"
   let $result :=
     if ($docBase = $docBaseArch and $attribute = "author")
     then 
@@ -318,6 +368,10 @@
     then 
       for $elem in $metadata/dcterms:creator
       return <author>{$elem}</author>
+    else if ($docBase = $docBaseTei and $attribute = "author")
+    then 
+      for $elem in $metadata/TEI:fileDesc/TEI:titleStmt/TEI:author
+      return <author>{$elem}</author>
     else if ($docBase = $docBaseArch and $attribute = "title")
     then 
       for $elem in $metadata/title
@@ -326,6 +380,10 @@
     then 
       for $elem in $metadata/dcterms:title
       return <title>{$elem}</title>
+    else if ($docBase = $docBaseTei and $attribute = "title")
+    then 
+      for $elem in $metadata/TEI:fileDesc/TEI:titleStmt/TEI:title
+      return <title>{$elem}</title>
     else if ($docBase = $docBaseArch and $attribute = "place")
     then 
       for $elem in $metadata/place
@@ -340,10 +398,16 @@
     then 
       for $elem in $metadata/dcterms:date
       return <date>{$elem}</date>
+    else if ($docBase = $docBaseTei and $attribute = "date")
+    then 
+      for $elem in $metadata/TEI:fileDesc/TEI:publicationStmt/TEI:date
+      return <date>{$elem}</date>
     else if ($docBase = $docBaseArch and $attribute = "language")
     then $metadata/lang
     else if ($docBase = $docBaseEcho and $attribute = "language")
     then $metadata/dcterms:language
+    else if ($docBase = $docBaseTei and $attribute = "language")
+    then $metadata/TEI:profileDesc/TEI:langUsage/TEI:language/@ident
     else if ($docBase = $docBaseArch and $attribute = "identifier")
     then $metadata/locator
     else if ($docBase = $docBaseEcho and $attribute = "identifier")
@@ -354,12 +418,16 @@
     then 
       for $elem in $metadata/dcterms:rights
       return <rights>{$elem}</rights>
+    else if ($docBase = $docBaseTei and $attribute = "rights")
+    then $metadata/TEI:fileDesc/TEI:publicationStmt/TEI:availability
     else if ($docBase = $docBaseArch and $attribute = "accessRights")
     then ()
     else if ($docBase = $docBaseEcho and $attribute = "accessRights")
     then 
       for $elem in $metadata/dcterms:accessRights
       return <rights>{$elem}</rights>
+    else if ($docBase = $docBaseTei and $attribute = "accessRights")
+    then $metadata/TEI:fileDesc/TEI:publicationStmt/TEI:availability/@status
     else if ($docBase = $docBaseArch and $attribute = "license")
     then ()
     else if ($docBase = $docBaseEcho and $attribute = "license")
--- a/software/eXist/webapp/mpdl/page-query-result.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/page-query-result.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -13,6 +13,7 @@
 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/";
+declare namespace TEI="http://www.tei-c.org/ns/1.0";
 
 let $mpdlDocUri := request:get-parameter("document", "")
 let $queryType := request:get-parameter("query-type", "")
@@ -54,6 +55,8 @@
   then $document/archimedes/info
   else if ($docbase = 'echo')
   then $document/echo:echo/echo:metadata
+  else if ($docbase = 'tei')
+  then $document/TEI:TEI/TEI:teiHeader
   else ''
 
 let $pageBreaks := 
@@ -61,6 +64,8 @@
   then $document//pb
   else if ($docbase = 'echo')
   then $document//echo:pb
+  else if ($docbase = 'tei')
+  then $document//TEI:pb
   else $document//pb
 let $countPagesTemp := count($pageBreaks)
 let $countPages := 
@@ -69,7 +74,7 @@
   else 1
 
 (: xQuery inline execution does not work in module so it has to be done here  :) 
-let $xQueryPageSize := 100
+let $xQueryPageSize := 1000
 let $xQueryResultEval := 
   if ($queryType = 'xpath' or $queryType = 'xquery' and $query != "")
   then util:eval-inline($document, $query)
@@ -159,6 +164,8 @@
   then $metadata/locator
   else if ($docbase = 'echo')
   then $metadata/dcterms:identifier
+  else if ($docbase = 'tei')
+  then $metadata/TEI:fileDesc/TEI:publicationStmt/TEI:idno
   else $metadata/dcterms:identifier
 let $echoDocIdentifier := 
   if ($documentIdentifier != '')
@@ -181,6 +188,8 @@
   then concat("/permanent/archimedes/", $documentName)
   else if ($docbase = 'echo')
   then concat("/permanent/library/", $echoDocIdentifier)
+  else if ($docbase = 'tei')
+  then $documentIdentifier
   else ''
 let $imagesDocDirectoryIndexMetaUrl := 
   if ($mode = "image" or $mode = "text" or $mode = "textPollux" or $mode = "gis")
@@ -200,6 +209,8 @@
 let $pageImageFileNameWithoutExtension := 
   if ($docbase = 'echo')
   then concat("/", string($pb1/@file))
+  else if ($docbase = 'tei')
+  then concat("/", string($pb1/@facs))
   else ''
 let $imageFileName :=
   if ($reqPF = '')
@@ -224,6 +235,8 @@
   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 if ($docbase = 'tei')
+  then count($pb1/following::TEI:figure[1]/preceding::TEI:figure) + 1
   else ()
 
 let $pageFragmentTmp := 
@@ -411,7 +424,7 @@
   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)
+  then mpdl-text:transform($xmlResult, $xslFilePath) 
   else 
     <div>{$xmlResult}</div>  (:  error xml result  :)
 let $result :=
--- a/software/eXist/webapp/mpdl/presentation/functions-mpdl.xsl	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/presentation/functions-mpdl.xsl	Fri Mar 11 13:34:02 2011 +0100
@@ -72,12 +72,12 @@
   </xsl:variable>
   <xsl:variable name="figureText" select="concat('[Figure: ', $figureNumber, ']')"/>
   <div class="{$class}" style="{$style}">
-    <xsl:if test="not(empty($figureCaption))"><xsl:sequence select="$figureCaption"/><br/></xsl:if>
+    <xsl:if test="$figureCaption != ''"><xsl:sequence select="$figureCaption"/><br/></xsl:if>
     <xsl:sequence select="$figureContent"/>
     <br/>
     <xsl:value-of select="$figureText"/>
-    <xsl:if test="not(empty($figureDescription))"><xsl:value-of select="': '"/><xsl:sequence select="$figureDescription"/></xsl:if>
-    <xsl:if test="not(empty($figureVariables))"><xsl:value-of select="'(Variables: '"/><xsl:sequence select="$figureVariables"/><xsl:value-of select="')'"/></xsl:if>
+    <xsl:if test="$figureDescription != ''"><xsl:value-of select="': '"/><xsl:sequence select="$figureDescription"/></xsl:if>
+    <xsl:if test="$figureVariables != ''"><xsl:value-of select="'(Variables: '"/><xsl:sequence select="$figureVariables"/><xsl:value-of select="')'"/></xsl:if>
   </div>
 </xsl:function>
 
--- a/software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl	Fri Mar 11 13:34:02 2011 +0100
@@ -11,7 +11,8 @@
   xmlns:dc="http://purl.org/dc/elements/1.1/" 
   xmlns:dcterms="http://purl.org/dc/terms"
   xmlns:echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/" 
-  xmlns:mml="http://www.w3.org/1998/Math/MathML" 
+  xmlns:m="http://www.w3.org/1998/Math/MathML" 
+  xmlns:svg="http://www.w3.org/2000/svg" 
   xmlns:xhtml="http://www.w3.org/1999/xhtml">
 
 <xsl:import href="/db/mpdl/presentation/functions-mpdl.xsl" />
@@ -224,32 +225,45 @@
 <xsl:template match="text" mode="text">
   <xsl:apply-templates mode="text"/>
   <!--   Notes                      -->
-  <xsl:if test="$collectionName = 'archimedes' and count($notes/*) > 0">
+  <xsl:variable name="countEmptyPlaces" select="count($notes/note[empty(@place)])"/>
+  <xsl:variable name="countBottomPlaces" select="count($notes/note[contains(@place, 'bottom')])"/>
+  <xsl:if test="($collectionName = 'archimedes' or $collectionName = 'tei') and count($notes/*) > 0">
     <div>
-      <hr class="notesBottom"/>
+      <xsl:choose>
+        <xsl:when test="$countBottomPlaces > 0 or $countEmptyPlaces > 0">
+          <hr class="notesBottom"/>
+        </xsl:when>
+        <xsl:otherwise></xsl:otherwise>
+      </xsl:choose>
       <xsl:for-each select="$notes/note">
         <xsl:variable name="notePos" select="position()"/>
+        <xsl:variable name="place" select="@place"/>
         <xsl:variable name="label" select="$notePos"/>
         <xsl:variable name="uid" select="@uid"/>
         <xsl:variable name="modificationDate" select="@modificationDate"/>
         <xsl:variable name="noteWithoutNamespace" select="mpdl-util:copyWithoutNamespace(.)"/>
-        <p>
-          <a>
-            <xsl:attribute name="name"><xsl:value-of select="concat('note-', $pageNumber, '-', $label)"/></xsl:attribute>
-            <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', 'note-', $pageNumber, '-', $label, 'ref')"/></xsl:attribute>
-            <xsl:value-of select="concat('[↑ note-', $pageNumber, '-', $label, ']')"/>
-          </a>
-          <xsl:value-of select="': '"/>
-          <xsl:choose>
-            <xsl:when test="$uid = '' or empty($uid)">
-              <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
-            </xsl:when>
-            <xsl:otherwise>
-              <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
-              <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/>
-            </xsl:otherwise>
-          </xsl:choose>
-        </p>
+        <xsl:choose>
+          <xsl:when test="$place = '' or empty($place) or $place = 'bottom'">
+            <p>
+              <a>
+                <xsl:attribute name="name"><xsl:value-of select="concat('note-', $pageNumber, '-', $label)"/></xsl:attribute>
+                <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', 'note-', $pageNumber, '-', $label, 'ref')"/></xsl:attribute>
+                <xsl:value-of select="concat('[↑ note-', $pageNumber, '-', $label, ']')"/>
+              </a>
+              <xsl:value-of select="': '"/>
+              <xsl:choose>
+                <xsl:when test="$uid = '' or empty($uid)">
+                  <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
+                </xsl:when>
+                <xsl:otherwise>
+                  <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
+                  <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/>
+                </xsl:otherwise>
+              </xsl:choose>
+            </p>
+          </xsl:when>
+          <xsl:otherwise></xsl:otherwise>
+        </xsl:choose>
       </xsl:for-each>
     </div>
   </xsl:if>
@@ -290,18 +304,153 @@
 <!-- TEI: segmentation   -->
 <xsl:template match="seg" mode="text">
   <span class="seg">
-    <xsl:if test="not(empty(@xlink:href))">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<!-- TEI: choice   -->
+<xsl:template match="choice" mode="text">
+  <xsl:if test="not(empty(orig))">
+    <xsl:apply-templates select="orig" mode="text"/>
+  </xsl:if>
+  <xsl:if test="not(empty(abbr))">
+    <xsl:apply-templates select="abbr" mode="text"/>
+  </xsl:if>
+  <xsl:if test="not(empty(am))">
+    <xsl:apply-templates select="am" mode="text"/>
+  </xsl:if>
+  <xsl:if test="not(empty(sic))">
+    <xsl:apply-templates select="sic" mode="text"/>
+  </xsl:if>
+</xsl:template>
+
+<!-- TEI: hi (highlighted)  -->
+<xsl:template match="hi" mode="text">
+  <xsl:choose>
+    <xsl:when test="@rend = 'initial'">
+      <span class="dc-unmodified"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="@rend"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- TEI: name (of type: place, person, ...)   -->
+<xsl:template match="name" mode="text">
+  <xsl:choose>
+    <xsl:when test="@type = 'place'">
+      <span class="place" title="Place"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="@type = 'person'">
+      <span class="person" title="Person"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="@type = 'org'">
+      <span class="organization" title="Organization"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="@type"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- TEI: place, person, ...)   -->
+<xsl:template match="placeName" mode="text">
+  <span class="place" title="Place: {@type}"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+<xsl:template match="persName" mode="text">
+  <span class="person" title="Person"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+
+<!-- TEI: term    -->
+<xsl:template match="term" mode="text">
+  <span class="term" title="Terminology entry"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+
+<!-- TEI: line    -->
+<xsl:template match="lg" mode="text">
+  <div class="lg"><xsl:apply-templates mode="text"/></div>
+</xsl:template>
+
+<xsl:template match="l" mode="text">
+  <span class="l"><xsl:apply-templates mode="text"/></span><br/>
+</xsl:template>
+
+<!-- TEI: reference    -->
+<xsl:template match="ref" mode="text">
+  <span class="ref">
+    <xsl:if test="not(empty(@target))">
       <a>
-        <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
+        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
         <xsl:apply-templates mode="text"/>
       </a>
     </xsl:if>
-    <xsl:if test="empty(@xlink:href)">
+    <xsl:if test="empty(@target)">
       <xsl:apply-templates mode="text"/>
     </xsl:if>
   </span>
 </xsl:template>
 
+<!-- TEI: table    -->
+<xsl:template match="table" mode="text">
+  <table>
+    <xsl:if test="not(empty(head))">
+      <caption align="top"><xsl:apply-templates mode="text" select="head"/></caption>
+    </xsl:if>
+    <xsl:apply-templates mode="text" select="row"/>
+  </table>
+</xsl:template>
+
+<xsl:template match="row" mode="text">
+  <xsl:choose>
+    <xsl:when test="@role = 'label'">
+      <tr style="font-weight:bold;"><xsl:apply-templates mode="text"/></tr>
+    </xsl:when>
+    <xsl:when test="@role = 'data' or empty(@role)">
+      <tr><xsl:apply-templates mode="text"/></tr>
+    </xsl:when>
+    <xsl:otherwise>
+      <tr><xsl:apply-templates mode="text"/></tr>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="cell" mode="text">
+  <xsl:choose>
+    <xsl:when test="@role = 'label' and empty(@cols)">
+      <td style="font-weight:bold;"><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:when test="@role = 'label' and not(empty(@cols))">
+      <td colspan="{@cols}" style="font-weight:bold;"><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:when test="(@role = 'data' or empty(@role)) and empty(@cols)">
+      <td><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:when test="(@role = 'data' or empty(@role)) and not(empty(@cols))">
+      <td colspan="{@cols}"><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:otherwise>
+      <td><xsl:apply-templates mode="text"/></td>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- TEI: MathML    -->
+<xsl:template match="m:*" mode="text">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="text"/>
+  </xsl:element>
+</xsl:template>
+
+<!-- TEI: SVG    -->
+<xsl:template match="svg:*" mode="text">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="text"/>
+  </xsl:element>
+</xsl:template>
+
 <xsl:template match="div" mode="text">
   <xsl:variable name="type" select="@type"/>
   <xsl:variable name="level" select="@level"/>
@@ -367,11 +516,12 @@
 </xsl:template>
 
 <xsl:template match="expan" mode="text">
-  <xsl:apply-templates mode="text"/><xsl:text> </xsl:text>
+  <xsl:apply-templates mode="text"/>
 </xsl:template>
 
 <xsl:template match="note" mode="text">
   <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
+  <xsl:variable name="place" select="@place"/>
   <xsl:variable name="notePos" select="count(preceding::note[. >> $topPB]) + 1"/>
   <xsl:variable name="href" select="concat('note-', $pageNumber, '-', $notePos)"/>
   <xsl:choose>
@@ -389,7 +539,27 @@
         <span class="note"><xsl:apply-templates mode="text"/></span>
       </p>
     </xsl:when>
-    <xsl:otherwise></xsl:otherwise>
+    <xsl:when test="$collectionName = 'tei'">
+      <xsl:choose>
+        <xsl:when test="contains($place, 'margin')">
+          <span>    
+            <xsl:attribute name="class"><xsl:value-of select="concat('note ', $place)"/></xsl:attribute>
+            <xsl:apply-templates mode="text"/>
+          </span>
+        </xsl:when>
+        <xsl:otherwise>
+          <a>
+            <xsl:attribute name="name"><xsl:value-of select="concat($href, 'ref')"/></xsl:attribute>
+            <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $href)"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'super'"/></xsl:attribute>
+            <xsl:value-of select="concat(' ↓ (', $href, ') ')"/>
+          </a>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="note"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
 
@@ -421,21 +591,6 @@
   <xsl:if test="$collectionName = 'archimedes'"><xsl:apply-templates mode="text"/></xsl:if>
 </xsl:template>
 
-<!-- TEI: reference    -->
-<xsl:template match="ref" mode="text">
-  <span class="ref">
-    <xsl:if test="not(empty(@target))">
-      <a>
-        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
-        <xsl:apply-templates mode="text"/>
-      </a>
-    </xsl:if>
-    <xsl:if test="empty(@target)">
-      <xsl:apply-templates mode="text"/>
-    </xsl:if>
-  </span>
-</xsl:template>
-
 <xsl:template match="foreign" mode="text">
   <xsl:variable name="lang" select="@lang"/>
   <xsl:variable name="xmllang" select="@xml:lang"/>
@@ -453,7 +608,7 @@
 </xsl:template>
 
 <xsl:template match="q" mode="text">
-  <div class="q"><xsl:apply-templates mode="text"/></div>
+  <span class="q"><xsl:apply-templates mode="text"/></span>
 </xsl:template>
 
 <xsl:template match="quote" mode="text">
@@ -518,9 +673,24 @@
           <xsl:otherwise><xsl:value-of select="$firstFigurePosition + count(./preceding::echo:figure[empty(@xlink:label)]) + count(./preceding::echo:anchor[@type = 'figure'])"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
-      <xsl:variable name="figureCaption" select="string-join($figure/echo:caption/text(), ' ')"/>
-      <xsl:variable name="figureDescription" select="string-join($figure/echo:description/text(), ' ')"/>
-      <xsl:variable name="figureVariables" select="string-join($figure/echo:variables/text(), ' ')"/>
+      <xsl:variable name="figureCaption">
+        <xsl:choose>
+          <xsl:when test="not(empty($figure/echo:caption))"><xsl:value-of select="string-join($figure/echo:caption/text(), ' ')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="figureDescription">
+        <xsl:choose>
+          <xsl:when test="not(empty($figure/echo:description))"><xsl:value-of select="string-join($figure/echo:description/text(), ' ')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="figureVariables">
+        <xsl:choose>
+          <xsl:when test="not(empty($figure/echo:variables))"><xsl:value-of select="string-join($figure/echo:variables/text(), ' ')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
       <xsl:sequence select="mpdl:showFigure($digilibAvailable, $figureFileName, $figureNumber, $figureCaption, $figureDescription, $figureVariables, 'float right')"/>
     </xsl:when>
     <xsl:when test="$type = 'handwritten'">
@@ -567,13 +737,20 @@
       <xsl:variable name="baseUrlLex" select="'http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/'"/>
       <xsl:variable name="wordLanguage" select="string-join(w[1]/@lang, '')"/>
       <xsl:variable name="form" select="string-join(w/@form, '')"/>
-      <xsl:variable name="wordStr" select="string-join(w, '')"/>
+      <xsl:variable name="wordStr">
+        <xsl:if test="not(empty(w))">
+          <xsl:value-of select="string-join(w, '')"/>
+        </xsl:if>
+        <xsl:if test="empty(w)">
+          <xsl:value-of select="."/>
+        </xsl:if>
+      </xsl:variable>
       <xsl:variable name="lexHref">
         <xsl:if test="not(empty(w))">
           <xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html', '&amp;placeHref=', encode-for-uri($href))"/>
         </xsl:if>
         <xsl:if test="empty(w)">
-          <xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?type=place', '&amp;output=html', '&amp;placeHref=', encode-for-uri($href))"/>
+          <xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?type=place', '&amp;language=', $language, '&amp;word=', $wordStr, '&amp;output=html', '&amp;placeHref=', encode-for-uri($href))"/>
         </xsl:if>
       </xsl:variable>
       <span class="place">
@@ -609,11 +786,6 @@
   </span>
 </xsl:template>
 
-<!-- MML   -->
-<xsl:template match="mml:*" mode="text">
-  <xsl:copy-of select="."/>
-</xsl:template>
-    
 <!-- XHTML: remove the xhtml namespace   -->
 <xsl:template match="xhtml:*" mode="text">
   <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
@@ -637,6 +809,7 @@
         <xsl:choose>
           <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="replace(./@xlink:href, '/', '.')"/></xsl:when>
           <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="./image/@file"/></xsl:when>
+          <xsl:when test="$collectionName = 'tei'"><xsl:value-of select="@facs"/></xsl:when>
           <xsl:otherwise><xsl:value-of select="./image/@file"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
@@ -644,6 +817,7 @@
         <xsl:choose>
           <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure)"/></xsl:when>
           <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:when>
+          <xsl:when test="$collectionName = 'tei'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure)"/></xsl:when>
           <xsl:otherwise><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
--- a/software/eXist/webapp/mpdl/presentation/pageHtml.css	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/presentation/pageHtml.css	Fri Mar 11 13:34:02 2011 +0100
@@ -34,6 +34,14 @@
    margin-right: 10px;
    padding-top: 1px;
 }
+span.dc-unmodified {
+   float: left;
+   font-family: Georgia;
+   font-size: 250%;
+   line-height: 0.8em; 
+   margin-right: 10px;
+   padding-top: 1px;
+}
 
 /* variables and numbers */
 span.var { font-style:italic; }
@@ -56,27 +64,30 @@
 /* indentation at the beginning of a paragraph: <emph class="sc it"> */
 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; }
+span.q     { 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; }
 
+/* terminology     */
+span.term { color:purple; }  /* Blue   */
+
 /* notes     */
 span.note { font-style:italic; }
+span.note.margin.left { position:absolute; left:2em; font-style:normal; }
+span.note.margin.right { position:absolute; left:30em; font-style:normal; } 
 
 /* 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   */
+span.place { color:#0000FF; }  /* Blue   */
+span.person  { color:#0000FF; }  /* Blue   */
+span.organization  { color:#0000FF; }  /* Blue   */
+span.time  { color:#0000FF; }  /* Blue   */
+span.event  { color:#0000FF; }  /* Blue  */
 
 /* preliminary representations of single/double/wavy/circled lines in Chinese text */
 span.sl { text-decoration:underline; }        /* DESpecs for Chinese: <sl> */
--- a/software/eXist/webapp/mpdl/presentation/pageHtml.xsl	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/presentation/pageHtml.xsl	Fri Mar 11 13:34:02 2011 +0100
@@ -11,7 +11,8 @@
   xmlns:dc="http://purl.org/dc/elements/1.1/" 
   xmlns:dcterms="http://purl.org/dc/terms"
   xmlns:echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/" 
-  xmlns:mml="http://www.w3.org/1998/Math/MathML" 
+  xmlns:m="http://www.w3.org/1998/Math/MathML" 
+  xmlns:svg="http://www.w3.org/2000/svg" 
   xmlns:xhtml="http://www.w3.org/1999/xhtml">
 
 <xsl:import href="/db/mpdl/presentation/functions-mpdl.xsl" />
@@ -750,32 +751,45 @@
 <xsl:template match="text" mode="text">
   <xsl:apply-templates mode="text"/>
   <!--   Notes                      -->
-  <xsl:if test="$collectionName = 'archimedes' and count($notes/*) > 0">
+  <xsl:variable name="countEmptyPlaces" select="count($notes/note[empty(@place)])"/>
+  <xsl:variable name="countBottomPlaces" select="count($notes/note[contains(@place, 'bottom')])"/>
+  <xsl:if test="($collectionName = 'archimedes' or $collectionName = 'tei') and count($notes/*) > 0">
     <div>
-      <hr class="notesBottom"/>
+      <xsl:choose>
+        <xsl:when test="$countBottomPlaces > 0 or $countEmptyPlaces > 0">
+          <hr class="notesBottom"/>
+        </xsl:when>
+        <xsl:otherwise></xsl:otherwise>
+      </xsl:choose>
       <xsl:for-each select="$notes/note">
         <xsl:variable name="notePos" select="position()"/>
+        <xsl:variable name="place" select="@place"/>
         <xsl:variable name="label" select="$notePos"/>
         <xsl:variable name="uid" select="@uid"/>
         <xsl:variable name="modificationDate" select="@modificationDate"/>
         <xsl:variable name="noteWithoutNamespace" select="mpdl-util:copyWithoutNamespace(.)"/>
-        <p>
-          <a>
-            <xsl:attribute name="name"><xsl:value-of select="concat('note-', $pageNumber, '-', $label)"/></xsl:attribute>
-            <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', 'note-', $pageNumber, '-', $label, 'ref')"/></xsl:attribute>
-            <xsl:value-of select="concat('[↑ note-', $pageNumber, '-', $label, ']')"/>
-          </a>
-          <xsl:value-of select="': '"/>
-          <xsl:choose>
-            <xsl:when test="$uid = '' or empty($uid)">
-              <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
-            </xsl:when>
-            <xsl:otherwise>
-              <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
-              <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/>
-            </xsl:otherwise>
-          </xsl:choose>
-        </p>
+        <xsl:choose>
+          <xsl:when test="$place = '' or empty($place) or $place = 'bottom'">
+            <p>
+              <a>
+                <xsl:attribute name="name"><xsl:value-of select="concat('note-', $pageNumber, '-', $label)"/></xsl:attribute>
+                <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', 'note-', $pageNumber, '-', $label, 'ref')"/></xsl:attribute>
+                <xsl:value-of select="concat('[↑ note-', $pageNumber, '-', $label, ']')"/>
+              </a>
+              <xsl:value-of select="': '"/>
+              <xsl:choose>
+                <xsl:when test="$uid = '' or empty($uid)">
+                  <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
+                </xsl:when>
+                <xsl:otherwise>
+                  <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
+                  <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/>
+                </xsl:otherwise>
+              </xsl:choose>
+            </p>
+          </xsl:when>
+          <xsl:otherwise></xsl:otherwise>
+        </xsl:choose>
       </xsl:for-each>
     </div>
   </xsl:if>
@@ -816,18 +830,153 @@
 <!-- TEI: segmentation   -->
 <xsl:template match="seg" mode="text">
   <span class="seg">
-    <xsl:if test="not(empty(@xlink:href))">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<!-- TEI: choice   -->
+<xsl:template match="choice" mode="text">
+  <xsl:if test="not(empty(orig))">
+    <xsl:apply-templates select="orig" mode="text"/>
+  </xsl:if>
+  <xsl:if test="not(empty(abbr))">
+    <xsl:apply-templates select="abbr" mode="text"/>
+  </xsl:if>
+  <xsl:if test="not(empty(am))">
+    <xsl:apply-templates select="am" mode="text"/>
+  </xsl:if>
+  <xsl:if test="not(empty(sic))">
+    <xsl:apply-templates select="sic" mode="text"/>
+  </xsl:if>
+</xsl:template>
+
+<!-- TEI: hi (highlighted)  -->
+<xsl:template match="hi" mode="text">
+  <xsl:choose>
+    <xsl:when test="@rend = 'initial'">
+      <span class="dc-unmodified"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="@rend"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- TEI: name (of type: place, person, ...)   -->
+<xsl:template match="name" mode="text">
+  <xsl:choose>
+    <xsl:when test="@type = 'place'">
+      <span class="place" title="Place"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="@type = 'person'">
+      <span class="person" title="Person"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="@type = 'org'">
+      <span class="organization" title="Organization"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="@type"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- TEI: place, person, ...)   -->
+<xsl:template match="placeName" mode="text">
+  <span class="place" title="Place: {@type}"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+<xsl:template match="persName" mode="text">
+  <span class="person" title="Person"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+
+<!-- TEI: term    -->
+<xsl:template match="term" mode="text">
+  <span class="term" title="Terminology entry"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+
+<!-- TEI: line    -->
+<xsl:template match="lg" mode="text">
+  <div class="lg"><xsl:apply-templates mode="text"/></div>
+</xsl:template>
+
+<xsl:template match="l" mode="text">
+  <span class="l"><xsl:apply-templates mode="text"/></span><br/>
+</xsl:template>
+
+<!-- TEI: reference    -->
+<xsl:template match="ref" mode="text">
+  <span class="ref">
+    <xsl:if test="not(empty(@target))">
       <a>
-        <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
+        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
         <xsl:apply-templates mode="text"/>
       </a>
     </xsl:if>
-    <xsl:if test="empty(@xlink:href)">
+    <xsl:if test="empty(@target)">
       <xsl:apply-templates mode="text"/>
     </xsl:if>
   </span>
 </xsl:template>
 
+<!-- TEI: table    -->
+<xsl:template match="table" mode="text">
+  <table>
+    <xsl:if test="not(empty(head))">
+      <caption align="top"><xsl:apply-templates mode="text" select="head"/></caption>
+    </xsl:if>
+    <xsl:apply-templates mode="text" select="row"/>
+  </table>
+</xsl:template>
+
+<xsl:template match="row" mode="text">
+  <xsl:choose>
+    <xsl:when test="@role = 'label'">
+      <tr style="font-weight:bold;"><xsl:apply-templates mode="text"/></tr>
+    </xsl:when>
+    <xsl:when test="@role = 'data' or empty(@role)">
+      <tr><xsl:apply-templates mode="text"/></tr>
+    </xsl:when>
+    <xsl:otherwise>
+      <tr><xsl:apply-templates mode="text"/></tr>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="cell" mode="text">
+  <xsl:choose>
+    <xsl:when test="@role = 'label' and empty(@cols)">
+      <td style="font-weight:bold;"><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:when test="@role = 'label' and not(empty(@cols))">
+      <td colspan="{@cols}" style="font-weight:bold;"><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:when test="(@role = 'data' or empty(@role)) and empty(@cols)">
+      <td><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:when test="(@role = 'data' or empty(@role)) and not(empty(@cols))">
+      <td colspan="{@cols}"><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:otherwise>
+      <td><xsl:apply-templates mode="text"/></td>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- TEI: MathML    -->
+<xsl:template match="m:*" mode="text">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="text"/>
+  </xsl:element>
+</xsl:template>
+
+<!-- TEI: SVG    -->
+<xsl:template match="svg:*" mode="text">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="text"/>
+  </xsl:element>
+</xsl:template>
+
 <xsl:template match="div" mode="text">
   <xsl:variable name="type" select="@type"/>
   <xsl:variable name="level" select="@level"/>
@@ -893,11 +1042,12 @@
 </xsl:template>
 
 <xsl:template match="expan" mode="text">
-  <xsl:apply-templates mode="text"/><xsl:text> </xsl:text>
+  <xsl:apply-templates mode="text"/>
 </xsl:template>
 
 <xsl:template match="note" mode="text">
   <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
+  <xsl:variable name="place" select="@place"/>
   <xsl:variable name="notePos" select="count(preceding::note[. >> $topPB]) + 1"/>
   <xsl:variable name="href" select="concat('note-', $pageNumber, '-', $notePos)"/>
   <xsl:choose>
@@ -915,7 +1065,27 @@
         <span class="note"><xsl:apply-templates mode="text"/></span>
       </p>
     </xsl:when>
-    <xsl:otherwise></xsl:otherwise>
+    <xsl:when test="$collectionName = 'tei'">
+      <xsl:choose>
+        <xsl:when test="contains($place, 'margin')">
+          <span>    
+            <xsl:attribute name="class"><xsl:value-of select="concat('note ', $place)"/></xsl:attribute>
+            <xsl:apply-templates mode="text"/>
+          </span>
+        </xsl:when>
+        <xsl:otherwise>
+          <a>
+            <xsl:attribute name="name"><xsl:value-of select="concat($href, 'ref')"/></xsl:attribute>
+            <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $href)"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'super'"/></xsl:attribute>
+            <xsl:value-of select="concat(' ↓ (', $href, ') ')"/>
+          </a>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="note"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
 
@@ -947,21 +1117,6 @@
   <xsl:if test="$collectionName = 'archimedes'"><xsl:apply-templates mode="text"/></xsl:if>
 </xsl:template>
 
-<!-- TEI: reference    -->
-<xsl:template match="ref" mode="text">
-  <span class="ref">
-    <xsl:if test="not(empty(@target))">
-      <a>
-        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
-        <xsl:apply-templates mode="text"/>
-      </a>
-    </xsl:if>
-    <xsl:if test="empty(@target)">
-      <xsl:apply-templates mode="text"/>
-    </xsl:if>
-  </span>
-</xsl:template>
-
 <xsl:template match="foreign" mode="text">
   <xsl:variable name="lang" select="@lang"/>
   <xsl:variable name="xmllang" select="@xml:lang"/>
@@ -979,7 +1134,7 @@
 </xsl:template>
 
 <xsl:template match="q" mode="text">
-  <div class="q"><xsl:apply-templates mode="text"/></div>
+  <span class="q"><xsl:apply-templates mode="text"/></span>
 </xsl:template>
 
 <xsl:template match="quote" mode="text">
@@ -1044,9 +1199,24 @@
           <xsl:otherwise><xsl:value-of select="$firstFigurePosition + count(./preceding::echo:figure[empty(@xlink:label)]) + count(./preceding::echo:anchor[@type = 'figure'])"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
-      <xsl:variable name="figureCaption" select="string-join($figure/echo:caption/text(), ' ')"/>
-      <xsl:variable name="figureDescription" select="string-join($figure/echo:description/text(), ' ')"/>
-      <xsl:variable name="figureVariables" select="string-join($figure/echo:variables/text(), ' ')"/>
+      <xsl:variable name="figureCaption">
+        <xsl:choose>
+          <xsl:when test="not(empty($figure/echo:caption))"><xsl:value-of select="string-join($figure/echo:caption/text(), ' ')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="figureDescription">
+        <xsl:choose>
+          <xsl:when test="not(empty($figure/echo:description))"><xsl:value-of select="string-join($figure/echo:description/text(), ' ')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="figureVariables">
+        <xsl:choose>
+          <xsl:when test="not(empty($figure/echo:variables))"><xsl:value-of select="string-join($figure/echo:variables/text(), ' ')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
       <xsl:sequence select="mpdl:showFigure($digilibAvailable, $figureFileName, $figureNumber, $figureCaption, $figureDescription, $figureVariables, 'float right')"/>
     </xsl:when>
     <xsl:when test="$type = 'handwritten'">
@@ -1092,13 +1262,20 @@
     <xsl:when test="$mode = 'textPollux'">
       <xsl:variable name="wordLanguage" select="string-join(w[1]/@lang, '')"/>
       <xsl:variable name="form" select="string-join(w/@form, '')"/>
-      <xsl:variable name="wordStr" select="string-join(w, '')"/>
+      <xsl:variable name="wordStr">
+        <xsl:if test="not(empty(w))">
+          <xsl:value-of select="string-join(w, '')"/>
+        </xsl:if>
+        <xsl:if test="empty(w)">
+          <xsl:value-of select="."/>
+        </xsl:if>
+      </xsl:variable>
       <xsl:variable name="lexHref">
         <xsl:if test="not(empty(w))">
           <xsl:value-of select="concat('interface/lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html', '&amp;placeHref=', encode-for-uri($href))"/>
         </xsl:if>
         <xsl:if test="empty(w)">
-          <xsl:value-of select="concat('interface/lt/wordInfo.xql?type=place', '&amp;output=html', '&amp;placeHref=', encode-for-uri($href))"/>
+          <xsl:value-of select="concat('interface/lt/wordInfo.xql?type=place', '&amp;language=', $language, '&amp;word=', $wordStr, '&amp;output=html', '&amp;placeHref=', encode-for-uri($href))"/>
         </xsl:if>
       </xsl:variable>
       <span class="place">
@@ -1134,11 +1311,6 @@
   </span>
 </xsl:template>
 
-<!-- MML   -->
-<xsl:template match="mml:*" mode="text">
-  <xsl:copy-of select="."/>
-</xsl:template>
-    
 <!-- XHTML: remove the xhtml namespace   -->
 <xsl:template match="xhtml:*" mode="text">
   <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
@@ -1162,6 +1334,7 @@
         <xsl:choose>
           <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="replace(./@xlink:href, '/', '.')"/></xsl:when>
           <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="./image/@file"/></xsl:when>
+          <xsl:when test="$collectionName = 'tei'"><xsl:value-of select="@facs"/></xsl:when>
           <xsl:otherwise><xsl:value-of select="./image/@file"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
@@ -1169,6 +1342,7 @@
         <xsl:choose>
           <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure)"/></xsl:when>
           <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:when>
+          <xsl:when test="$collectionName = 'tei'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure)"/></xsl:when>
           <xsl:otherwise><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
@@ -1194,7 +1368,6 @@
 </xsl:template>
 
 
-
 <!-- textPollux links                           -->
 <xsl:template match="w" mode="text">
   <xsl:variable name="wordLanguage" select="@lang"/>
--- a/software/eXist/webapp/mpdl/query.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/query.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -89,6 +89,13 @@
         <td valign="top">
           <text style="margin-left:1px;"></text><input type="checkbox" name="docbase" value="echo" checked="checked"/>
         </td>
+        <td>
+          <text style="margin-left:20px;">TEI Schema</text><br/>
+          <text style="margin-left:20px;">(since 2011)</text>
+        </td>
+        <td valign="top">
+          <text style="margin-left:1px;"></text><input type="checkbox" name="docbase" value="tei" checked="checked"/>
+        </td>
         <td valign="top"><text style="margin-left:40px;"></text><button type="submit" name="browseQuery" onclick="document.getElementById('ietype').value='browse';">Browse</button></td>
         <td valign="top"><a href="info.xql?info=docBases" onclick="window.open(&quot;info.xql?info=docBases&quot;, &quot;InfoWindow&quot;, &quot;menubar=no,width=500,height=500,toolbar=no&quot;);return false"><img src="images/info.png" valign="bottom" width="15" height="15" border="0" alt="Info Document bases"/></a></td>
       </tr>
@@ -235,7 +242,7 @@
   <hr/>
   <p/>
   See the <a href="/exist/xquery.xml">eXist XQuery documentation</a> and the <a href="query.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>
-  <br/>Last MPDL software update: January, 2011
+  <br/>Last MPDL software update: March, 2011
 </form>
 </body>
 </html>
\ No newline at end of file
--- a/software/eXist/webapp/mpdl/text/all.xql	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/text/all.xql	Fri Mar 11 13:34:02 2011 +0100
@@ -9,6 +9,8 @@
 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 TEI="http://www.tei-c.org/ns/1.0";
+
 declare namespace dcterms="http://purl.org/dc/terms";
 
 declare function mpdl-text:insertNodeIdAttribute($element as element()) {
@@ -41,6 +43,8 @@
     then $document/archimedes/text
     else if ($mpdlCollectionName = 'echo') 
     then $document/echo:echo/echo:text 
+    else if ($mpdlCollectionName = 'tei') 
+    then $document/TEI:TEI/TEI:text 
     else $document/archimedes/text
   let $from := ($pn * $pageSize) - $pageSize + 1
   let $to := $pn * $pageSize
@@ -131,16 +135,22 @@
     then $document//echo:figure
     else if ($docBase = 'archimedes' and $queryType = 'figures') 
     then $document//figure
+    else if ($docBase = 'tei' and $queryType = 'figures') 
+    then $document//TEI:figure
     else ()
   let $tocEntriesAllTmp := 
     for $entry at $pos in $tocEntriesAll
       let $pb := 
         if ($docBase = 'echo')
         then $entry/preceding::echo:pb[1]
+        else if ($docBase = 'tei')
+        then $entry/preceding::TEI:pb[1]
         else $entry/preceding::pb[1]
       let $pageNum := 
         if ($docBase = 'echo')
         then count($pb/preceding::echo:pb) + 1
+        else if ($docBase = 'tei')
+        then count($pb/preceding::TEI:pb) + 1
         else count($pb/preceding::pb) + 1
       let $level := 
         if ($queryType = 'toc')
@@ -206,12 +216,16 @@
     then $document/archimedes/info
     else if ($docbase = 'echo')
     then $document/echo:echo/echo:metadata
+    else if ($docbase = 'tei')
+    then $document/TEI:TEI/TEI:teiHeader
     else ''
   let $documentIdentifier :=
     if ($docbase = 'archimedes')
     then $metadata/locator
     else if ($docbase = 'echo')
     then $metadata/dcterms:identifier
+    else if ($docbase = 'tei')
+    then $metadata/TEI:fileDesc/TEI:publicationStmt/TEI:idno
     else $metadata/dcterms:identifier
   let $echoDocIdentifier := 
     if ($documentIdentifier != '') 
@@ -231,6 +245,8 @@
     then concat("/permanent/archimedes/", $documentName)
     else if ($docbase = 'echo')
     then concat("/permanent/library/", $echoDocIdentifier)
+    else if ($docbase = 'tei')
+    then $documentIdentifier
     else ''
   let $imagesDocDirectoryIndexMetaUrl  := concat($nausikaaURLTexter, "?fn=", $imagesDocDirectory, "/index.meta")
   let $digilibAvailable := mpdldoc:check-uri($imagesDocDirectoryIndexMetaUrl, 2000)