changeset 25:e9fe3186670c default tip

letzter Stand eingecheckt
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 21 May 2013 10:19:32 +0200
parents e845310098ba
children
files software/mpdl-services-new/mpiwg-mpdl-cms-web/.classpath software/mpdl-services-new/mpiwg-mpdl-cms-web/.externalToolBuilders/mpiwg-mpdl-cms-web-build.launch software/mpdl-services-new/mpiwg-mpdl-cms-web/.project software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/.jsdtscope software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.core.resources.prefs software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.jdt.core.prefs software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.wst.common.component software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.wst.common.project.facet.core.xml software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.wst.jsdt.ui.superType.container software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.wst.jsdt.ui.superType.name software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.wst.ws.service.policy.prefs software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/META-INF/MANIFEST.MF software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/classes/constants.properties software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/berkeley-db-3.3.82.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-codec-1.3.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-collections-3.2.1.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-collections-LICENSE.txt software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-collections-NOTICE.txt software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-httpclient-3.1.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-httpclient-LICENSE.txt software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-httpclient-NOTICE.txt software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-io-2.0.1.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-lang3-3.0.1.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-logging-LICENSE.txt software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-logging-NOTICE.txt software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/core-renderer.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/httpclient-4.1.2.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/httpcore-4.1.2.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/iText-2.0.8.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/json_simple-1.1.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/lucene-core-3.5.0.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/lucene-highlighter-3.5.0-javadoc.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/lucene-highlighter-3.5.0.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/lucene-memory-3.5.0.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/lucene-queries-3.5.0.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/microsoft-translator-java-api-0.4.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/mpiwg-mpdl-cms-web.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/mpiwg-mpdl-cms.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/mpiwg-mpdl-lt.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/mpiwg-mpdl-xml.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/quartz-1.6.5.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/quartz-LICENSE.txt software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/saxon.txt software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/saxon9-dom.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/saxon9-s9api.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/saxon9.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/web.xml software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/cms-services.html software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/getDictionaryEntries.css software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/page.css software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageNorm.css software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageNormDict.css software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageOrig.css software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageOrigDict.css software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageReg.css software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageRegDict.css software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/2downarrow.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/2leftarrow.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/2rightarrow.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/2uparrow.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/book-pointer.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/book.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/camera.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/copyleft.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/dictionary.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/dictionaryMorph.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/dot.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/download.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/echo.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/figures.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/help.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/image.jpg software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/imageU.jpg software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/info.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/left.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/link.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/linkback.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/linkext.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/linkto.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/malcolm.jpg software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/malcolm.tif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/pirate-joey.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/right.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/search.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/searchMorph.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/searchStructural.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/searchXPath.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/slime_logo.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/text.jpg software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/textPollux.jpg software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/textPolluxU.jpg software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/textU.jpg software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/toc.gif software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/treecheckbox.png software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/xml.jpg software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/xmlU.jpg software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/index.html software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/lt-services.html software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/query/index.html software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/query/info.html software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/xsl/generateId.xsl software/mpdl-services-new/mpiwg-mpdl-cms-web/build/build.xml software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/exception/ApplicationException.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/DocumentOperation.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocInfo.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocument.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocumentJobs.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetPage.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetToken.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/MoreLikeThis.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/MpiwgMpdlCmsWebServletContextListener.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/QueryDocument.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/QueryDocuments.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/XQueryDocument.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetDictionaryEntries.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetForms.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetLemmas.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/MpiwgMpdlLtWebServletContextListener.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Normalize.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Tokenize.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Transcode.class software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/util/ServletUtil.class software/mpdl-services-new/mpiwg-mpdl-cms-web/conf/constants-thrax.properties software/mpdl-services-new/mpiwg-mpdl-cms-web/conf/constants.properties software/mpdl-services-new/mpiwg-mpdl-cms-web/dist-remote/mpiwg-mpdl-cms-web.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/dist-remote/mpiwg-mpdl-cms-web.war software/mpdl-services-new/mpiwg-mpdl-cms-web/dist/mpiwg-mpdl-cms-web.jar software/mpdl-services-new/mpiwg-mpdl-cms-web/dist/mpiwg-mpdl-cms-web.war software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/exception/ApplicationException.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/DocumentOperation.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocInfo.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocument.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocumentJobs.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetPage.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetToken.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/MoreLikeThis.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/MpiwgMpdlCmsWebServletContextListener.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/QueryDocument.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/QueryDocuments.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/XQueryDocument.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetDictionaryEntries.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetForms.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetLemmas.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/MpiwgMpdlLtWebServletContextListener.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Normalize.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Tokenize.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Transcode.java software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/util/ServletUtil.java software/mpdl-services-new/mpiwg-mpdl-cms/.classpath software/mpdl-services-new/mpiwg-mpdl-cms/.externalToolBuilders/mpiwg-mpdl-cms-build.launch software/mpdl-services-new/mpiwg-mpdl-cms/.project software/mpdl-services-new/mpiwg-mpdl-cms/.settings/org.eclipse.core.resources.prefs software/mpdl-services-new/mpiwg-mpdl-cms/bin/constants.properties software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/CollectionReader.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManager.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManagerResultWrapper.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/Document.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/DocumentHandler.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/Hits.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/MetadataRecord.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandler.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandlerUserAgent.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/Token.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/general/Constants.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/harvester/PathExtractor.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/lucene/IndexHandler.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainScheduler.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainSchedulerListener.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocJob.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocOperation.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/quartz.properties software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/test/TestLocal.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler$Element.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/HighlightContentHandler.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/PageTransformer.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/QueryTransformer.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/TocTransformer.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/XslResourceTransformer.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/chars.xsl software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageArchimedes.xsl software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEcho.xsl software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageTei.xsl software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXhtml.xsl software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXml.xsl software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/queryDocument.xsl software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/replaceAnchor.xsl software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/toc.xsl software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/tocOut.xsl software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/translator/MicrosoftTranslator.class software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/exception/ApplicationException.class software/mpdl-services-new/mpiwg-mpdl-cms/build/build.xml software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/constants.properties software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/CollectionReader.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManager.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManagerResultWrapper.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/Document.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/DocumentHandler.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/Hits.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/MetadataRecord.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandler.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandlerUserAgent.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/Token.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/general/Constants.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/harvester/PathExtractor.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/lucene/IndexHandler.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainScheduler.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainSchedulerListener.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocJob.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocOperation.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/quartz.properties software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/test/TestLocal.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler$1.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler$Element.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/HighlightContentHandler.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/HighlightTransformer.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/PageTransformer.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/QueryTransformer.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/ReplaceAnchorTransformer.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/TocTransformer.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/XslResourceTransformer.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/chars.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/highlight.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageArchimedes.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEcho.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEchoSpan.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageTei.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXhtml.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXml.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/queryDocument.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/replaceAnchor.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/toc.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/tocHtml.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/tocOut.xsl software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/translator/MicrosoftTranslator.class software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/exception/ApplicationException.class software/mpdl-services-new/mpiwg-mpdl-cms/dist/mpiwg-mpdl-cms.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-codec-1.3.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-collections-3.2.1.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-collections-LICENSE.txt software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-collections-NOTICE.txt software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-httpclient-3.1.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-httpclient-LICENSE.txt software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-httpclient-NOTICE.txt software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-io-2.0.1.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-lang3-3.0.1.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-logging-1.1.1.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-logging-LICENSE.txt software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-logging-NOTICE.txt software/mpdl-services-new/mpiwg-mpdl-cms/lib/core-renderer.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/httpclient-4.1.2.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/httpcore-4.1.2.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/iText-2.0.8.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/json_simple-1.1.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-core-3.5.0-javadoc.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-core-3.5.0-sources.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-core-3.5.0.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-highlighter-3.5.0-javadoc.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-highlighter-3.5.0.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-memory-3.5.0.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-queries-3.5.0.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/microsoft-translator-java-api-0.4.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/mpiwg-mpdl-lt.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/mpiwg-mpdl-xml.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/quartz-1.6.5.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/quartz-LICENSE.txt software/mpdl-services-new/mpiwg-mpdl-cms/lib/saxon.txt software/mpdl-services-new/mpiwg-mpdl-cms/lib/saxon9-dom.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/saxon9-s9api.jar software/mpdl-services-new/mpiwg-mpdl-cms/lib/saxon9.jar software/mpdl-services-new/mpiwg-mpdl-cms/src/constants.properties software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/CollectionReader.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManager.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManagerResultWrapper.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/Document.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/DocumentHandler.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/Hits.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/MetadataRecord.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandler.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandlerUserAgent.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/Token.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/general/Constants.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/harvester/PathExtractor.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/lucene/IndexHandler.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainScheduler.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainSchedulerListener.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocJob.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocOperation.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/quartz.properties software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/test/TestLocal.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/HighlightContentHandler.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/PageTransformer.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/QueryTransformer.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/TocTransformer.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/XslResourceTransformer.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/chars.xsl software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageArchimedes.xsl software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEcho.xsl software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageTei.xsl software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXhtml.xsl software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXml.xsl software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/queryDocument.xsl software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/replaceAnchor.xsl software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/toc.xsl software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/tocOut.xsl software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/translator/MicrosoftTranslator.java software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/exception/ApplicationException.java
diffstat 310 files changed, 20095 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.classpath	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/1.6.0 (MacOS X Default)">
+		<attributes>
+			<attribute name="owner.project.facets" value="java"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
+		<attributes>
+			<attribute name="owner.project.facets" value="jst.web"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/mpiwg-mpdl-xml"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/mpiwg-mpdl-lt"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/mpiwg-mpdl-cms"/>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.externalToolBuilders/mpiwg-mpdl-cms-web-build.launch	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
+<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="mpiwg-mpdl-cms-web"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/mpiwg-mpdl-cms-web/build/build.xml}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value=""/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+</launchConfiguration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.project	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>mpiwg-mpdl-cms-web</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.common.project.facet.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+			<triggers>full,incremental,</triggers>
+			<arguments>
+				<dictionary>
+					<key>LaunchConfigHandle</key>
+					<value>&lt;project&gt;/.externalToolBuilders/mpiwg-mpdl-cms-web-build.launch</value>
+				</dictionary>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+	</natures>
+</projectDescription>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/.jsdtscope	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="WebContent"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+		<attributes>
+			<attribute name="hide" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+	<classpathentry kind="output" path=""/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.core.resources.prefs	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+#Mon Sep 24 15:59:11 CEST 2012
+eclipse.preferences.version=1
+encoding//src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/DocumentOperation.java=UTF-8
+encoding//src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocInfo.java=UTF-8
+encoding//src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocument.java=UTF-8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.jdt.core.prefs	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,12 @@
+#Mon Sep 12 15:41:45 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.wst.common.component	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+    <wb-module deploy-name="mpiwg-mpdl-xml-web">
+        <wb-resource deploy-path="/" source-path="/WebContent"/>
+        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+        <wb-resource deploy-path="/WEB-INF/lib" source-path="/WebContent/WEB-INF/lib"/>
+        <property name="java-output-path" value="/mpiwg-mpdl-xml-web/build/classes"/>
+        <property name="context-root" value="mpiwg-mpdl-xml-web"/>
+    </wb-module>
+</project-modules>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.wst.common.project.facet.core.xml	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+  <runtime name="Apache Tomcat v6.0"/>
+  <fixed facet="jst.web"/>
+  <fixed facet="wst.jsdt.web"/>
+  <fixed facet="java"/>
+  <installed facet="java" version="1.6"/>
+  <installed facet="jst.web" version="2.5"/>
+  <installed facet="wst.jsdt.web" version="1.0"/>
+</faceted-project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.wst.jsdt.ui.superType.container	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.wst.jsdt.ui.superType.name	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,1 @@
+Window
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/.settings/org.eclipse.wst.ws.service.policy.prefs	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,3 @@
+#Mon Sep 12 15:41:45 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.wst.ws.service.policy.projectEnabled=false
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/META-INF/MANIFEST.MF	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/classes/constants.properties	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+documentsDir=/Users/jwillenborg/mpdl/data/xml/documents
+luceneDocumentsDir=/Users/jwillenborg/mpdl/data/xml/lucene/documents
+luceneNodesDir=/Users/jwillenborg/mpdl/data/xml/lucene/nodes
+dataDir=/Users/jwillenborg/mpdl/data/lt
+confDir=/Users/jwillenborg/mpdl/data/collectionConfs
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/berkeley-db-3.3.82.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-codec-1.3.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-collections-3.2.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-collections-LICENSE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-collections-NOTICE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+Apache Commons Collections
+Copyright 2001-2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-httpclient-3.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-httpclient-LICENSE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,176 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-httpclient-NOTICE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+Apache Jakarta HttpClient
+Copyright 1999-2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-io-2.0.1.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-lang3-3.0.1.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-logging-LICENSE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/commons-logging-NOTICE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,6 @@
+Apache Commons Logging
+Copyright 2003-2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/core-renderer.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/httpclient-4.1.2.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/httpcore-4.1.2.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/iText-2.0.8.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/json_simple-1.1.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/lucene-core-3.5.0.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/lucene-highlighter-3.5.0-javadoc.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/lucene-highlighter-3.5.0.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/lucene-memory-3.5.0.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/lucene-queries-3.5.0.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/microsoft-translator-java-api-0.4.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/mpiwg-mpdl-cms-web.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/mpiwg-mpdl-cms.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/mpiwg-mpdl-lt.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/mpiwg-mpdl-xml.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/quartz-1.6.5.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/quartz-LICENSE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/saxon.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,3 @@
+Saxon:
+
+Release 9.1.0.5 (free version): releases < 9.1.0.7 support saxon extension functions
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/saxon9-dom.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/saxon9-s9api.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib/saxon9.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/WEB-INF/web.xml	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
+  <display-name>mpiwg-mpdl-cms-web</display-name>
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+  </welcome-file-list>
+  <servlet>
+    <description>GetDocument</description>
+    <display-name>GetDocument</display-name>
+    <servlet-name>GetDocument</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.GetDocument</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>GetDocument</servlet-name>
+    <url-pattern>/doc/GetDocument</url-pattern>
+  </servlet-mapping> 
+  <servlet>
+    <description>DocumentOperation</description>
+    <display-name>DocumentOperation</display-name>
+    <servlet-name>DocumentOperation</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.DocumentOperation</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>DocumentOperation</servlet-name>
+    <url-pattern>/doc/DocumentOperation</url-pattern>
+  </servlet-mapping> 
+  <servlet>
+    <description>GetPage</description>
+    <display-name>GetPage</display-name>
+    <servlet-name>GetPage</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.GetPage</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>GetPage</servlet-name>
+    <url-pattern>/query/GetPage</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>QueryDocuments</description>
+    <display-name>QueryDocuments</display-name>
+    <servlet-name>QueryDocuments</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.QueryDocuments</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>QueryDocuments</servlet-name>
+    <url-pattern>/query/QueryDocuments</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>QueryDocument</description>
+    <display-name>QueryDocument</display-name>
+    <servlet-name>QueryDocument</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.QueryDocument</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>QueryDocument</servlet-name>
+    <url-pattern>/query/QueryDocument</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>XQueryDocument</description>
+    <display-name>XQueryDocument</display-name>
+    <servlet-name>XQueryDocument</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.XQueryDocument</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>XQueryDocument</servlet-name>
+    <url-pattern>/query/XQueryDocument</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>MoreLikeThis</description>
+    <display-name>MoreLikeThis</display-name>
+    <servlet-name>MoreLikeThis</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.MoreLikeThis</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>MoreLikeThis</servlet-name>
+    <url-pattern>/query/MoreLikeThis</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>GetToken</description>
+    <display-name>GetToken</display-name>
+    <servlet-name>GetToken</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.GetToken</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>GetToken</servlet-name>
+    <url-pattern>/query/GetToken</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>GetDocInfo</description>
+    <display-name>GetDocInfo</display-name>
+    <servlet-name>GetDocInfo</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.GetDocInfo</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>GetDocInfo</servlet-name>
+    <url-pattern>/query/GetDocInfo</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>GetDocumentJobs</description>
+    <display-name>GetDocumentJobs</display-name>
+    <servlet-name>GetDocumentJobs</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.GetDocumentJobs</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>GetDocumentJobs</servlet-name>
+    <url-pattern>/doc/GetDocumentJobs</url-pattern>
+  </servlet-mapping>
+  
+  <servlet>
+    <description>GetDictionaryEntries</description>
+    <display-name>GetDictionaryEntries</display-name>
+    <servlet-name>GetDictionaryEntries</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.lt.GetDictionaryEntries</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>GetDictionaryEntries</servlet-name>
+    <url-pattern>/lt/GetDictionaryEntries</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>GetLemmas</description>
+    <display-name>GetLemmas</display-name>
+    <servlet-name>GetLemmas</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.lt.GetLemmas</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>GetLemmas</servlet-name>
+    <url-pattern>/lt/GetLemmas</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>GetForms</description>
+    <display-name>GetForms</display-name>
+    <servlet-name>GetForms</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.lt.GetForms</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>GetForms</servlet-name>
+    <url-pattern>/lt/GetForms</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>Tokenize</description>
+    <display-name>Tokenize</display-name>
+    <servlet-name>Tokenize</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.lt.Tokenize</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>Tokenize</servlet-name>
+    <url-pattern>/text/Tokenize</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>Normalize</description>
+    <display-name>Normalize</display-name>
+    <servlet-name>Normalize</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.lt.Normalize</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>Normalize</servlet-name>
+    <url-pattern>/text/Normalize</url-pattern>
+  </servlet-mapping>
+  <servlet>
+    <description>Transcode</description>
+    <display-name>Transcode</display-name>
+    <servlet-name>Transcode</servlet-name>
+    <servlet-class>de.mpg.mpiwg.berlin.mpdl.servlets.lt.Transcode</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>Transcode</servlet-name>
+    <url-pattern>/text/Transcode</url-pattern>
+  </servlet-mapping>
+  
+  <listener>
+    <listener-class>de.mpg.mpiwg.berlin.mpdl.servlets.cms.MpiwgMpdlCmsWebServletContextListener</listener-class>
+  </listener>
+
+</web-app>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/cms-services.html	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,563 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <title>Max Planck Institute for the History of Science - CMS Services</title>
+  </head>
+<body>
+<h2>Max Planck Institute for the History of Science - CMS Services</h2>
+
+<ul>
+  <li><b>Url: /mpiwg-mpdl-cms-web/doc/GetDocument</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>id (required)
+            <ul>
+              <li>identifier of the document (e.g. "/tei/de/dt-ptolemaeus-tei-merge2.xml")</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>Link to document job</li>
+          <li>Example: <a href="doc/GetDocument?id=/tei/de/dt-ptolemaeus-tei-merge2.xml">Get test document</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/doc/DocumentOperation</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>srcUrl (optional)
+            <ul>
+              <li>url of the source document (if operation is create)</li>
+            </ul>
+          </li>
+          <li>docId (required)
+            <ul>
+              <li>document identifier of the document (e.g. "/tei/de/dt-ptolemaeus-tei-merge2.xml")</li>
+            </ul>
+          </li>
+          <li>elementNames (optional)
+            <ul>
+              <li>list of xml element names which should be indexed</li>
+              <li>default: "s head caption variables description"</li>
+            </ul>
+          </li>
+          <li>operation (required)
+            <ul>
+              <li>create (if docId already exists then it is updated)</li>
+              <li>delete</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>xml</li>
+              <li>html</li>
+              <li>string</li>
+              <li>default: xml</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>Link to document job</li>
+          <li>Example: <a href="doc/DocumentOperation?srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/getDoc?doc=/tei/de/dt-ptolemaeus-tei-merge2.xml&docId=/tei/de/dt-ptolemaeus-tei-merge2.xml&operation=create">Create test document</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/query/GetPage</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>docId (required)
+            <ul>
+              <li>document identifier of the document (e.g. "/tei/de/dt-ptolemaeus-tei-merge2.xml")</li>
+            </ul>
+          </li>
+          <li>page (optional)
+            <ul>
+              <li>page number in document</li>
+              <li>default: 1</li>
+            </ul>
+          </li>
+          <li>normalization (optional)
+            <ul>
+              <li>orig (original)</li>
+              <li>reg (regularized)</li>
+              <li>norm (regularized and normalized)</li>
+              <li>default: norm</li>
+            </ul>
+          </li>
+          <li>highlightQuery (optional)
+            <ul>
+              <li>Lucene query string for which words should be highlighted</li>
+              <li>default: empty</li>
+            </ul>
+          </li>
+          <li>highlightQueryType (optional)
+            <ul>
+              <li>form (form)</li>
+              <li>morph (morphological)</li>
+              <li>default: form</li>
+            </ul>
+          </li>
+          <li>highlightElem (optional)
+            <ul>
+              <li>element name which should be highlighted</li>
+              <li>default: empty</li>
+            </ul>
+          </li>
+          <li>highlightElemPos (optional)
+            <ul>
+              <li>element position which should be highlighted</li>
+              <li>default: 1</li>
+            </ul>
+          </li>
+          <li>mode (optional)
+            <ul>
+              <li>untokenized</li>
+              <li>tokenized (page result is enriched with word elements: e.g. &lt;w lang="deu" form="satz" formRegularized="satz" formNormalized="satz" forms="satz, sätze, satzes" lemmas="satz"&gt;Satz&lt;/w&gt;)</li>
+              <li>default: untokenized</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>html</li>
+              <li>xml (pure xml)</li>
+              <li>xmlDisplay (xml like display through html)</li>
+              <li>default: html</li>
+            </ul>
+          </li>
+          <li>cssUrl (optional)
+            <ul>
+              <li>url of css file</li>
+              <li>default: <a href="css/page.css">/mpiwg-mpdl-cms-web/css/page.css</a></li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>Document page</li>
+          <li>Example: <a href="query/GetPage?docId=/echo/la/Benedetti_1585_163127KK.xml&page=13">Page 13 in Benedetti document</a></li>
+          <li>Example: <a href="query/GetPage?docId=/echo/la/Benedetti_1585_163127KK.xml&page=13&mode=tokenized">Page 13 in Benedetti document, tokenized</a></li>
+          <li>Example: <a href="query/GetPage?docId=/echo/la/Benedetti_1585_163127KK.xml&page=13&highlightElem=s&highlightElemPos=1">Page 13 in Benedetti document, first sentence highlighted</a></li>
+          <li>Example: <a href="query/GetPage?docId=/echo/la/Benedetti_1585_163127KK.xml&page=13&outputFormat=xmlDisplay&highlightElem=s&highlightElemPos=1">Page 13 in Benedetti document, first sentence highlighted (XML output)</a></li>
+          <li>Example: <a href="query/GetPage?docId=/echo/la/Benedetti_1585_163127KK.xml&page=13&normalization=reg&highlightQuery=tokenReg:relatiuum">Page 13 in Benedetti document, regularized form "relatiuum" is highlighted</a></li>
+          <li>Example: <a href="query/GetPage?docId=/echo/la/Benedetti_1585_163127KK.xml&page=13&highlightQueryType=norm&highlightQuery=tokenMorph:praeclarus&language=lat">Page 13 in Benedetti document, morphological forms of "praeclarus" are highlighted</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/query/QueryDocuments</b>
+    <ul><li><a href="query/index.html">Web query interface</a></li></ul>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>query (required)
+            <ul>
+              <li><a href="http://lucene.apache.org/core/3_6_0/queryparsersyntax.html">Lucene query</a> (e.g. +author:ben* +tokenMorph:quantitas +tokenMorph:sum)
+              <ul>
+                <li>supported fields
+                  <ul>
+                  <li>docId</li>
+                  <li>identifier</li>
+                  <li>author</li>
+                  <li>title</li>
+                  <li>language</li>
+                  <li>publisher (place)</li>
+                  <li>date (year)</li>
+                  <li>subject</li>
+                  <li>rights</li>
+                  <li>license</li>
+                  <li>accessRights</li>
+                  <li>tokenOrig</li>
+                  <li>tokenReg</li>
+                  <li>tokenNorm</li>
+                  <li>tokenMorph</li>
+                  <li>default: tokenOrig</li>
+                </ul>
+              </li>
+              </ul>
+            </li>
+            </ul>
+          </li>
+          <li>sortBy (optional)
+            <ul>
+              <li>fieldNames separated by blank
+              <ul>
+                <li>supported fields
+                  <ul>
+                  <li>author</li>
+                  <li>title</li>
+                  <li>language</li>
+                  <li>publisher (place)</li>
+                  <li>docId</li>
+                  <li>date (year)</li>
+                  <li>lastModified</li>
+                  <li>schemaName</li>
+                </ul>
+              </li>
+              <li>default: result is sorted by score (the most relevant result first)</li>
+              </ul>
+            </li>
+            </ul>
+          </li>
+          <li>language (optional)
+            <ul>
+              <li>ISO 639-3 specifier</li>
+              <li>default: automatically derived from query</li>
+            </ul>
+          </li>
+          <li>translate (optional)
+            <ul>
+              <li>expansion of the query: translation of the query terms to other languages</li>
+              <li>true</li>
+              <li>false</li>
+              <li>default: false</li>
+            </ul>
+          </li>
+          <li>page (optional)
+            <ul>
+              <li>result page number</li>
+              <li>default: 1</li>
+            </ul>
+          </li>
+          <li>pageSize (optional)
+            <ul>
+              <li>result page size</li>
+              <li>default: 10</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>xml</li>
+              <li>html</li>
+              <li>default: html</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>Documents matching the query</li>
+          <li>Example: <a href="query/QueryDocuments?query=tokenOrig:tempore">all documents which contains "tempore" in original content</a></li>
+          <li>Example: <a href="query/QueryDocuments?query=tokenOrig:relatiuũ">all documents which contains "relatiuũ" in original content</a></li>
+          <li>Example: <a href="query/QueryDocuments?query=tokenReg:relatiuum">all documents which contains "relatiuum" in regularized content</a></li>
+          <li>Example: <a href="query/QueryDocuments?query=tokenNorm:relativum">all documents which contains "relativum" in normalized content</a></li>
+          <li>Example: <a href="query/QueryDocuments?query=tokenOrig:Sabaudiæ&language=lat">all latin documents which contains "sabaudiæ" in content</a></li>
+          <li>Example: <a href="query/QueryDocuments?query=tokenMorph:sum&language=lat&page=2">all latin documents which morphological contains "sum" in content (result page 2)</a></li>
+          <li>Example: <a href="query/QueryDocuments?query=tokenOrig:buch&translate=true">all documents which contains translated "buch" in content</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/query/QueryDocument</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>docId (required)
+            <ul>
+              <li>document identifier (e.g. "/echo/la/Benedetti_1585.xml"</li>
+            </ul>
+          </li>
+          <li>query (required)
+            <ul>
+              <li><a href="http://lucene.apache.org/core/3_6_0/queryparsersyntax.html">Lucene query</a> (e.g. +tokenMorph:quantitas +tokenMorph:sum)
+              <ul>
+                <li>supported fields
+                  <ul>
+                  <li>language</li>
+                  <li>pageNumber</li>
+                  <li>lineNumber</li>
+                  <li>elementName</li>
+                  <li>elementDocPosition (position in document, e.g. the 7th element in document)</li>
+                  <li>elementAbsolutePosition (position in all elements with this name, e.g. the 5th sentence in document)</li>
+                  <li>elementPagePosition (position of this element within a page, e.g. the 8th sentence on page 5)</li>
+                  <li>elementPosition (position of this element in parent element, e.g. the 3rd sentence element in a paragraph)</li>
+                  <li>xmlId</li>
+                  <li>xpath</li>
+                  <li>tokenOrig</li>
+                  <li>tokenReg</li>
+                  <li>tokenNorm</li>
+                  <li>tokenMorph</li>
+                  <li>default: tokenOrig</li>
+                </ul>
+              </li>
+              </ul>
+            </li>
+            </ul>
+          </li>
+          <li>page (optional)
+            <ul>
+              <li>result page number</li>
+              <li>default: 1</li>
+            </ul>
+          </li>
+          <li>pageSize (optional)
+            <ul>
+              <li>result page size</li>
+              <li>default: 10</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>xml</li>
+              <li>html</li>
+              <li>default: xml</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>nodes/elements in document which matches the query, sorted by position in document, word tokens are extracted and hits are highlighted</li>
+          <li>Example: <a href="query/QueryDocument?docId=/echo/la/Benedetti_1585_163127KK.xml&query=tokenOrig:tempore">in /echo/la/Benedetti_1585_163127KK.xml: all nodes which contains "tempore" in original content (XML output)</a></li>
+          <li>Example: <a href="query/QueryDocument?docId=/echo/la/Benedetti_1585_163127KK.xml&query=tokenOrig:tempore&outputFormat=html">in /echo/la/Benedetti_1585_163127KK.xml: all nodes which contains "tempore" in original content (HTML output)</a></li>
+          <li>Example: <a href="query/QueryDocument?docId=/echo/la/Benedetti_1585_163127KK.xml&query=tokenReg:relatiuum">in /echo/la/Benedetti_1585.xml: all nodes which contains "relatiuum" in regularized content (XML output)</a></li>
+          <li>Example: <a href="query/QueryDocument?docId=/echo/la/Benedetti_1585_163127KK.xml&query=tokenMorph:praeclarus&outputFormat=html">in /echo/la/Benedetti_1585_163127KK.xml: all nodes which contains morphological "praeclarus" in content (HTML output)</a></li>
+          <li>Example: <a href="query/QueryDocument?docId=/tei/en/Test_1789.xml&query=tokenOrig:sentence&outputFormat=html">in /tei/en/Test_1789.xml: all nodes which contains "sentence" in original content (HTML output)</a></li>
+          <li>Example: <a href="query/QueryDocument?docId=/echo/zh/SongYingxing_1637.xml&query=xmlId:N400022&outputFormat=xml">in /echo/zh/SongYingxing_1637.xml: node with xmlId "N400022"</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/query/XQueryDocument</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>docId (required)
+            <ul>
+              <li>document identifier (e.g. "/echo/la/Benedetti_1585.xml"</li>
+            </ul>
+          </li>
+          <li>query (required)
+            <ul>
+              <li><a href="http://www.saxonica.com/documentation/javadoc/net/sf/saxon/s9api/package-summary.html">Saxon's</a> <a href="http://www.w3.org/TR/xquery">XQuery</a>/<a href="http://www.w3.org/TR/xpath20">XPath</a></li>
+            </ul>
+          </li>
+          <li>page (optional)
+            <ul>
+              <li>result page number</li>
+              <li>default: 1</li>
+            </ul>
+          </li>
+          <li>pageSize (optional)
+            <ul>
+              <li>result page size</li>
+              <li>default: 10</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>xml</li>
+              <li>html</li>
+              <li>default: xml</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>Example: <a href="query/XQueryDocument?docId=/echo/la/Benedetti_1585_163127KK.xml&query=count(//*:s)">in /echo/la/Benedetti_1585_163127KK.xml: count all sentences (XML output)</a></li>
+          <li>Example: <a href="query/XQueryDocument?docId=/echo/la/Benedetti_1585_163127KK.xml&query=//*:s">in /echo/la/Benedetti_1585_163127KK.xml: all sentences (XML output)</a></li>
+          <li>Example: <a href="query/XQueryDocument?docId=/tei/en/Test_1789.xml&query=//*:note[@n = 1 or @n=2]&outputFormat=html">in /tei/en/Test_1789.xml: note with number 1 or 2 (HTML output)</a></li>
+          <li>Example: <a href="query/XQueryDocument?docId=/tei/en/Test_1789.xml&query=//*:note/@n">in /tei/en/Test_1789.xml: "n" attributes of all notes (XML output)</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /wspCmsWebApp/query/MoreLikeThis</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>docId (required)
+            <ul>
+              <li>document identifier (e.g. "/echo/la/Benedetti_1585_163127KK.xml"</li>
+            </ul>
+          </li>
+          <li>page (optional)
+            <ul>
+              <li>result page number</li>
+              <li>default: 1</li>
+            </ul>
+          </li>
+          <li>pageSize (optional)
+            <ul>
+              <li>result page size</li>
+              <li>default: 10</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>xml</li>
+              <li>html</li>
+              <li>json</li>
+              <li>default: html</li>
+            </ul>
+          </li>
+          <li>addInf (optional)
+            <ul>
+              <li>result with additional information such as person names etc.</li>
+              <li>true</li>
+              <li>false</li>
+              <li>default: false</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>Similar documents</li>
+          <li>Example: <a href="query/MoreLikeThis?docId=/echo/la/Benedetti_1585_163127KK.xml">similar documents of "/echo/la/Benedetti_1585_163127KK.xml"</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/query/GetToken</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>docId (optional)
+            <ul>
+              <li>document identifier (e.g. "/echo/la/Benedetti_1585_163127KK.xml"</li>
+            </ul>
+          </li>
+          <li>attribute (optional)
+            <ul>
+              <li>identifier</li>
+              <li>author</li>
+              <li>title</li>
+              <li>language</li>
+              <li>date</li>
+              <li>rights</li>
+              <li>license</li>
+              <li>accessRights</li>
+              <li>tokenOrig</li>
+              <li>tokenReg</li>
+              <li>tokenNorm</li>
+              <li>tokenMorph</li>
+              <li>default: tokenOrig</li>
+            </ul>
+          </li>
+          <li>query (optional)
+            <ul>
+              <li>beginning characters of token (e.g. "a")</li>
+              <li>default: empty (beginning alphabetically at first position in all tokens)</li>
+            </ul>
+          </li>
+          <li>count (optional)
+            <ul>
+              <li>count of tokens</li>
+              <li>default: 100</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>xml</li>
+              <li>default: xml</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>Tokens of the attribute</li>
+          <li>Example: <a href="query/GetToken?attribute=docId">all token in docId field (starting from beginning)</a></li>
+          <li>Example: <a href="query/GetToken?docId=/echo/la/Benedetti_1585_163127KK.xml&attribute=tokenMorph&query=a">in /echo/la/Benedetti_1585_163127KK.xml: all token beginning with "a" in morphological content (starting from "a")</a></li>
+          <li>Example: <a href="query/GetToken?attribute=tokenMorph&query=a">in all documents: all token beginning with "a" in morphological content (starting from "a")</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/query/GetDocInfo</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>docId (required)
+            <ul>
+              <li>document identifier (e.g. "/echo/la/Benedetti_1585_163127KK.xml"</li>
+            </ul>
+          </li>
+          <li>field (optional)
+            <ul>
+              <li>author</li>
+              <li>title</li>
+              <li>language</li>
+              <li>date</li>
+              <li>rights</li>
+              <li>license</li>
+              <li>accessRights</li>
+              <li>countPages</li>
+              <li>lastModified</li>
+              <li>schema</li>
+              <li>echoId</li>
+              <li>toc (table of contents)</li>
+              <li>figures</li>
+              <li>notes</li>
+              <li>notesHandwritten</li>
+              <li>pages</li>
+              <li>places</li>
+              <li>default: null (all fields except automatic generated lists such as toc, figures, etc.)</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>xml</li>
+              <li>default: xml</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>Metadata information of the document (document fields)</li>
+          <li>Example: <a href="query/GetDocInfo?docId=/echo/la/Benedetti_1585_163127KK.xml">Meta info of document /echo/la/Benedetti_1585_163127KK.xml</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/doc/GetDocumentJobs</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>id (optional)
+            <ul>
+              <li>id of the document job</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>xml</li>
+              <li>default: xml</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>all document jobs (when parameter id is not set) or document job with the specified id</li>
+          <li>Example: <a href="doc/GetDocumentJobs">get all document jobs</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+</ul>   
+ 
+</body></html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/getDictionaryEntries.css	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,95 @@
+.body {
+    margin:3px;
+    color: #000000;
+    background-color: #ebebeb;
+    min-width:1100px;
+}
+div.title {
+	font-size: 30px;
+  font-weight: bold;
+  margin-bottom: 10px;
+}
+input.query {
+	border-radius: 5px;
+}
+span.inputType {
+  font-size: 22px;
+  font-weight:bold;
+  display:block;
+  margin-top: 10px;
+}
+
+.tree ul,
+.tree li {
+  padding: 0;
+  margin: 0;
+  margin-left: 10px;
+  list-style: none;
+}
+.tree input {
+  position: absolute;
+  opacity: 0;
+}
+.tree input + label + ul {
+  margin: 0 0 0 22px;
+}
+.tree input + label + ul {
+  display: none;
+}
+.tree label,
+.tree label::before {
+  cursor: pointer;
+}
+.tree input:disabled + label {
+  cursor: default;
+  opacity: .6;
+}
+.tree input:checked:not(:disabled) + label + ul {
+  display: block;
+}
+.tree label,
+.tree label::before {
+  background: url("/mpiwg-mpdl-lt-web/images/treecheckbox.png") no-repeat;
+}
+.tree label,
+.tree a,
+.tree label::before {
+  display: inline-block;
+  height: 16px;
+  line-height: 16px;,
+  vertical-align: middle;
+}
+.tree label {
+  background-position: 18px 0;
+}
+.tree label::before {
+  content: "";
+  width: 16px;
+  margin: 0 22px 0 0;
+  vertical-align: middle;
+  background-position: 0 -32px;
+}
+.tree input:checked + label::before {
+  background-position: 0 -16px;
+}
+
+/* webkit adjacent element selector bugfix */
+@media screen and (-webkit-min-device-pixel-ratio:0)
+{
+  .tree 
+  {
+    -webkit-animation: webkit-adjacent-element-selector-bugfix infinite 1s;
+  }
+  
+  @-webkit-keyframes webkit-adjacent-element-selector-bugfix 
+  {
+    from 
+    { 
+      padding: 0;
+    } 
+    to 
+    { 
+      padding: 0;
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/page.css	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,261 @@
+/* general */
+.it        { font-style:italic }                    /* DESpecs: _ _ and attribute "it" */
+.bf        { font-weight:bold }                     /* DESpecs: <bf> */
+.sc        { font-variant:small-caps }              /* DESpecs: <sc> */
+.sub       { vertical-align:sub; font-size:.8em }   /* DESpecs: <_>  */ /* line-height:1em; ? */
+.super     { vertical-align:super; font-size:.8em } /* DESpecs: <^> */
+.sm        { font-size:smaller }                    /* DESpecs: <sm>, if within <p> */
+.ul        { text-decoration:underline }            /* DESpecs: <ul> */
+.ol        { text-decoration:overline }             /* DESpecs: <ol> */
+.st        { text-decoration:line-through }         /* DESpecs: <st> */
+.red       { color:red }                            /* DESpecs: <red> */
+.sp        { letter-spacing:0.3em }                 /* DESpecs: <sp> */  /* "font-stretch:wider;" is deprecated */
+.center    { text-align:center }
+.fr        { font-family:'Lucida blackletter'}     /* preliminary representation of Fraktur */
+.rom       { font-family:'default'}
+
+/* unused */
+.setoff    { margin-left:2cm; margin-right:2cm }
+
+/* highlighting    */
+.highlight { background-color:#D3D3D3; }  /* LightGrey    */
+div.highlight.elem { background-color:#D3D3D3; }  /* LightGrey    */
+span.highlight.elem { background-color:#D3D3D3; }  /* LightGrey    */
+span.highlight.hit { background-color:#77DD77; }  /* pastell green  */
+span.hit.highlight { background-color:#77DD77; }  /* pastell green  */
+
+/* about      */
+span.about {float:right;}
+
+/* query results  */
+span.query { font-weight:bold; font-size:150%; }
+span.result { display:none }
+tr.hit { vertical-align: top; }
+td.hitNum { display:inline-block; }
+td.hitLink { margin-left:1%; display:inline-block; width:30%; }
+td.hitContent { display:inline-block; width:90%; }
+
+/* xml presentation    */
+span.xml.elementName { font-weight:bold;color:purple; }
+span.xml.attributeName { font-weight:bold; }
+span.xml.attributeValue { color:blue; }
+span.xml.comment { color:green; font-style:italic; }
+ul.xml.element { margin-left:0px;padding-left:8px }
+ul.xml.element.highlight { background-color:#D3D3D3; }      /* LightGrey    */
+
+/* divs */
+div.float.none {
+  margin-left:10%; 
+} 
+div.float.right {
+  float:right;
+  clear:both;
+  margin-right:10%
+}
+
+/* page breaks */
+span.pb {
+  display:none;
+}
+
+/* Figures  */
+span.figure {
+  display: block;
+  width: 200px;
+  margin-top: 0.5em;
+  margin-bottom: 0.5em;
+  padding: 5px;
+  border: 1px dashed silver;
+}
+span.figureNumber {
+} 
+span.figureNum {
+  display:none;
+} 
+span.figureNumText {
+  display: block;
+} 
+span.caption {
+} 
+span.description {
+  display: block;
+} 
+span.variables {
+  display: block;
+} 
+
+span.handwritten {
+} 
+
+/* toc elements    */
+div.tocItem { 
+  float:left; 
+  width:90%;        
+}
+span.tocPageRef {   
+  float:right; 
+  vertical-align:top;
+}
+
+/* paragraphs     */
+div.p { 
+  margin: 1.12em 0px;
+}
+
+/* initials     */
+span.initial {
+   float: left;
+   font-family: Georgia;
+   font-size: 250%;
+   line-height: 0.8em; 
+   margin-right: 10px;
+   padding-top: 1px;
+}
+
+/* small caps */
+span.sc { font-weight:bold; }
+span.sc.it {font-weight:bold; font-style:italic; }
+
+/* variables and numbers */
+span.var { font-style:italic; }
+span.var.segment { font-style:italic; text-decoration:overline; }
+span.var.line    { font-style:italic; text-decoration:underline; }
+span.var.gnomon  { font-style:italic; text-decoration:line-through; }
+span.num   { color:maroon }
+
+/* foreign languages     */
+span.foreign { color:#006400; }
+span.foreign a:link { color:#006400; }
+span.foreign a:visited { color:#1B370D; }
+span.foreign.el span.foreign.grc span.foreign.greek { color:#006400; } 
+span.foreign.en span.foreign.english { color:#006400; }  
+span.foreign.fr span.foreign.french { color:#006400; } 
+span.foreign.la span.foreign.latin { color:#006400; } 
+
+/* quotes */
+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; }
+
+/* dictionary / terminology     */
+span.term { color:purple; }  /* Blue   */
+span.entry { display:block; margin-bottom:20px;}
+span.entryDiv { margin-left:2em; display:block; margin-bottom:0.5em; margin-top:0.5em;}
+span.orth { font-weight:bold; }
+span.mentioned { font-style:italic; }
+
+/* GIS elements    */
+span.place { color:#0000FF; }  /* Blue   */
+span.person  { color:#0000FF; }  /* Blue   */
+
+/* sentence    */
+span.s.highlight { background-color:#D3D3D3; }  /* LightGrey    */
+span.s:hover { background-color:#D3D3D3; }      /* LightGrey    */
+span.s.it { font-style:italic; }
+
+/* ref               */
+span.ref a:link {text-decoration: underline; color: blue;}
+span.ref a:visited {text-decoration: none; color: #800080;}
+span.ref a:hover {text-decoration: underline; color: blue;}
+
+/* Links   */
+a.dictionary:link {text-decoration: none; color: #892B06;}
+a.dictionary:visited {text-decoration: none; color: #892B06;}
+a.dictionary:hover {text-decoration: underline; color: #892B06;}
+
+/* Notes  */
+span.note { font-style:italic; }
+span.note span.noteSign {vertical-align:super; font-size:.8em; }
+span.note span.noteBody span.noteSign {display:none;}
+span.note.left { position:absolute; left:2em; width: 5em; font-style:normal; }
+span.note.right { position:absolute; left:30em; width: 5em; font-style:normal; } 
+a.note {
+  color: blue;
+  margin-right: 0.2em;
+}
+a.note:before {
+  content: url('../images/linkback.png');
+  margin-left: 0.1em;
+  margin-right: 0.2em;
+}
+a.note:link { text-decoration: none; }
+a.note:visited { text-decoration: none; }
+a.note:hover { text-decoration: underline; }
+a.noteRef {
+  color: blue;
+  margin-right: 0.2em;
+}
+a.noteRef:before {
+  content: url('../images/linkto.png');
+  margin-left: 0.1em;
+  margin-right: 0.2em;
+}
+a.noteRef:link { text-decoration: none; }
+a.noteRef:visited { text-decoration: none; }
+a.noteRef:hover { text-decoration: underline; }
+/*
+a:link {text-decoration: none;}
+a:visited {text-decoration: none}
+a:active {text-decoration: none}
+a:hover {text-decoration: underline; color: red;}
+ */
+
+/* table     */
+table { margin-left:30px; }
+
+table.toc { width:100%; margin-left:1px; }
+
+/* page styling for generating PDF documents with Flying Saucer */
+div.pageHeaderTitle {
+  font-weight:bold;
+  text-align:center;
+}
+body {
+    counter-reset: pn; 
+}
+div.page:before {
+  float:right;
+  font:11pt sans-serif;
+  font-weight:bold;
+  content:"[Page " counter(pn) "]";
+  counter-increment:pn;
+  page:pdfPage;
+  clear:both;
+}
+div.page {
+  page-break-after:always;
+  page:pdfPage;
+  clear:both;
+}
+@page pdfPage {
+  size:A4;
+  margin-top:0.7cm;
+  margin-bottom:0.7cm;
+  margin-left:0.7cm;
+  margin-right:0.7cm;
+  padding:0.2cm;
+  border:thin solid #808080;
+    @top-left { font: 11pt sans-serif; padding-left: 0.2cm; padding-right: 1cm; font-weight:bold;};
+    @top-right { font: 11pt sans-serif;  white-space: nowrap; font-weight:bold;};
+    @bottom-left { font: 11pt sans-serif;  white-space: nowrap; font-weight:bold;};
+    @bottom-right { font: 11pt sans-serif;  white-space: nowrap; content: counter(page);};
+}
+
+div.tocPage {
+  page-break-after:always;
+  page:tocPage;
+}
+@page tocPage {
+  size:A4;
+  margin-top:0.7cm;
+  margin-bottom:0.7cm;
+  margin-left:0.7cm;
+  margin-right:0.7cm;
+  padding:0.2cm;
+  border:thin solid #808080;
+    @top-left { font: 11pt sans-serif; padding-left: 0.2cm; padding-right: 1cm; font-weight:bold;};
+    @top-right { font: 11pt sans-serif;  white-space: nowrap; font-weight:bold;};
+    @bottom-left { font: 11pt sans-serif;  white-space: nowrap; font-weight:bold;};
+    @bottom-right { font: 11pt sans-serif;  white-space: nowrap; content: counter(page);};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageNorm.css	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,12 @@
+span.w a.dictionary {
+  display:none;
+}
+span.w span.dictionary {
+  display:none;
+}
+span.w span.orig {
+  display:none;
+}
+span.w span.reg {
+  display:none;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageNormDict.css	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,15 @@
+span.w a.dictionary span.orig {
+  display:none;
+}
+span.w a.dictionary span.reg {
+  display:none;
+}
+span.w span.dictionary span.orig {
+  display:none;
+}
+span.w span.dictionary span.reg {
+  display:none;
+}
+span.w span.nodictionary {
+  display:none;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageOrig.css	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,12 @@
+span.w a.dictionary {
+  display:none;
+}
+span.w span.dictionary {
+  display:none;
+}
+span.w span.reg {
+  display:none;
+}
+span.w span.norm {
+  display:none;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageOrigDict.css	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,15 @@
+span.w a.dictionary span.reg {
+  display:none;
+}
+span.w a.dictionary span.norm {
+  display:none;
+}
+span.w span.dictionary span.reg {
+  display:none;
+}
+span.w span.dictionary span.norm {
+  display:none;
+}
+span.w span.nodictionary {
+  display:none;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageReg.css	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,12 @@
+span.w a.dictionary {
+  display:none;
+}
+span.w span.dictionary {
+  display:none;
+}
+span.w span.orig {
+  display:none;
+}
+span.w span.norm {
+  display:none;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/css/pageRegDict.css	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,15 @@
+span.w a.dictionary span.orig {
+  display:none;
+}
+span.w a.dictionary span.norm {
+  display:none;
+}
+span.w span.dictionary span.orig {
+  display:none;
+}
+span.w span.dictionary span.norm {
+  display:none;
+}
+span.w span.nodictionary {
+  display:none;
+}
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/2downarrow.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/2leftarrow.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/2rightarrow.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/2uparrow.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/book-pointer.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/book.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/camera.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/copyleft.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/dictionary.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/dictionaryMorph.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/dot.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/download.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/echo.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/figures.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/help.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/image.jpg has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/imageU.jpg has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/info.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/left.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/link.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/linkback.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/linkext.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/linkto.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/malcolm.jpg has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/malcolm.tif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/pirate-joey.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/right.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/search.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/searchMorph.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/searchStructural.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/searchXPath.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/slime_logo.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/text.jpg has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/textPollux.jpg has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/textPolluxU.jpg has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/textU.jpg has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/toc.gif has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/treecheckbox.png has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/xml.jpg has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/images/xmlU.jpg has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/index.html	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <title>Max Planck Institute for the History of Science - Language technology &amp; CMS services</title>
+  </head>
+<body>
+<h2>Max Planck Institute for the History of Science - Language technology &amp; CMS services</h2>
+
+<ul>
+  <li><a href="lt-services.html">Language technology services</a></li>
+  <li><a href="cms-services.html">CMS technology services</a></li>
+</ul>
+
+</body></html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/lt-services.html	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,408 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <title>Max Planck Institute for the History of Science - Language technology services</title>
+  </head>
+<body>
+<table align="right">
+<tr>
+<td>
+  [<i>This software is dedicated to <a href="http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/info.xql?info=malcolm">Dr. Malcolm Hyman</a></i>]
+  <img src="/mpiwg-mpdl-cms-web/images/info.png" width="15" height="15" border="0" alt="Info"/><br/>
+  [<i>It is based on <a href="http://archimedes.fas.harvard.edu/">Donatus and Pollux</a></i>] 
+  <img src="/mpiwg-mpdl-cms-web/images/info.png" width="15" height="15" border="0" alt="Info"/>
+</td>
+</tr>
+</table>
+<h2>Max Planck Institute for the History of Science - Language technology services</h2>
+
+<ul>
+  <li><b>Url: /mpiwg-mpdl-cms-web/lt/GetDictionaryEntries</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>query (required)
+              <ul>
+                <li>by one form or lemma (e.g. "revolution")</li>
+                <li>by a list of forms or lemmas (e.g. "revolution equality brotherliness")</li>
+                <li>by a prefix range: entries starting with a prefix (e.g. "a*")</li>
+             </ul>
+          </li>
+          <li>queryDisplay (optional)
+            <ul>
+              <li>display of the query</li>
+              <li>default: content of parameter "query"</li>
+            </ul>
+          </li>
+          <li>inputType (optional)
+            <ul>
+              <li>"form"</li>
+              <li>"lemma"</li>
+              <li>default: "form"</li>
+            </ul>
+          </li>
+          <li>language (optional)
+            <ul>
+              <li>ISO 639-3 specifier</li>
+              <li>default: "eng"</li>
+            </ul>
+          </li>
+          <li>dictionary (optional)
+            <ul>
+              <li>dictionary name, e.g. "webster"</li>
+              <li>default: "all" (all dictionaries for the specified language)</li>
+            </ul>
+          </li>
+          <li>outputType (optional)
+            <ul>
+              <li>this parameter can occur many times (e.g. "outputType=morphCompact&amp;outputType=dictCompact")
+                <ul>
+                  <li>"morphCompact"</li>
+                  <li>"dictCompact"</li>
+                  <li>"wikiCompact"</li>
+                  <li>"allCompact" (all output types compact)</li>
+                  <li>"morphFull"</li>
+                  <li>"dictFull"</li>
+                  <li>"wikiFull"</li>
+                  <li>"allFull" (all output types full)</li>
+                </ul>
+              </li>
+              <li>default: "allCompact"</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>"html"</li>
+              <li>"xml"</li>
+              <li>default: "xml"</li>
+            </ul>
+          </li>
+          <li>normalization (optional)
+            <ul>
+              <li>"none"</li>
+              <li>"norm"</li>
+              <li>default: "norm"</li>
+            </ul>
+          </li>
+          <li>resultPageNumber (optional)
+            <ul>
+              <li>works only for range queries</li>
+              <li>page number of the result (e.g. "2": result entries from position 51 to 100)</li>
+              <li>default: "1"</li>
+            </ul>
+          </li>
+          <li>resultPageSize (optional)
+            <ul>
+              <li>works only for range queries</li>
+              <li>page size of the result (e.g. "100": each result page has a size of 100)</li>
+              <li>default: "50"</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>dependent of outputFormat, outputType and resultPage: morphology, dictionary and Wikipedia entries in Xml or Html format</li>
+          <li>Example: <a href="lt/GetDictionaryEntries?query=a*&language=lat&outputFormat=html">query=a*&amp;language=lat&amp;outputFormat=html</a></li>
+          <li>Example: <a href="lt/GetDictionaryEntries?query=a*&dictionary=ls">query=a*&amp;dictionary=ls</a></li>
+          <li>Example: <a href="lt/GetDictionaryEntries?query=revolution&language=eng">query=revolution&amp;language=lat</a></li>
+          <li>Example: <a href="lt/GetDictionaryEntries?query=multa&language=lat&outputFormat=html&outputType=allCompact">query=multa&amp;language=lat&amp;outputFormat=html&amp;outputType=allCompact</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/lt/GetLemmas</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>query (required)
+              <ul>
+                <li>one form or lemma (e.g. "revolution") or</li>
+                <li>blank separated list of forms or lemmas (e.g. "revolution equality brotherliness")</li>
+             </ul>
+          </li>
+          <li>inputType (optional)
+            <ul>
+              <li>"form"</li>
+              <li>"lemma"</li>
+              <li>default: "form"</li>
+            </ul>
+          </li>
+          <li>language (optional)
+            <ul>
+              <li>ISO 639-3 specifier</li>
+              <li>default: "eng"</li>
+            </ul>
+          </li>
+          <li>outputType (optional)
+            <ul>
+              <li>"compact"</li>
+              <li>"full"</li>
+              <li>default: "compact"</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>"html"</li>
+              <li>"xml"</li>
+              <li>"string" (lemma names separated by a blank)</li>
+              <li>default: "xml"</li>
+            </ul>
+          </li>
+          <li>normalization (optional)
+            <ul>
+              <li>"none"</li>
+              <li>"norm"</li>
+              <li>default: "norm"</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>dependent of outputFormat and outputType: lemma entries in Xml or Html or string format</li>
+          <li>Example: <a href="lt/GetLemmas?query=multa&language=lat&outputFormat=html">query=multa&amp;language=lat&amp;outputFormat=html</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/lt/GetForms</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>query (required)
+              <ul>
+                <li>one lemma (e.g. "revolution") or</li>
+                <li>blank separated list of forms (e.g. "revolution equality brotherliness")</li>
+             </ul>
+          </li>
+          <li>language (optional)
+            <ul>
+              <li>ISO 639-3 specifier</li>
+              <li>default: "eng"</li>
+            </ul>
+          </li>
+          <li>outputType (optional)
+            <ul>
+              <li>"compact"</li>
+              <li>"full"</li>
+              <li>default: "compact"</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>"html"</li>
+              <li>"xml"</li>
+              <li>"string" (lemma names separated by a blank)</li>
+              <li>default: "xml"</li>
+            </ul>
+          </li>
+          <li>normalization (optional)
+            <ul>
+              <li>"none"</li>
+              <li>"norm"</li>
+              <li>default: "norm"</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>dependent of outputFormat and outputType: form entries in Xml or Html or string format</li>
+          <li>Example: <a href="lt/GetForms?query=edo sum&language=lat&outputFormat=string">query=edo sum&amp;language=lat&amp;outputFormat=string</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/text/Tokenize</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>inputString or srcUrl (required)
+            <ul>
+              <li>inputString
+                <ul>
+                  <li>string which should be tokenized
+                    <ul>
+                      <li>unstructured text</li>
+                      <li>XML fragment/document</li>
+                    </ul>
+                  </li>
+                </ul>
+              </li>
+              <li>srcUrl
+                <ul>
+                  <li>source URL
+                    <ul>
+                      <li>unstructured text</li>
+                      <li>XML fragment/document</li>
+                    </ul>
+                  </li>
+                </ul>
+              </li>
+            </ul>
+          </li>
+          <li>language (optional)
+            <ul>
+              <li>ISO 639-3 specifier</li>
+              <li>if input is XML and an element contains the attribute "xml:lang" this value is used for this element</li>
+              <li>default: "eng"</li>
+            </ul>
+          </li>
+          <li>normalization (optional)
+            <ul>
+              <li>"none" (no normalization)</li>
+              <li>"reg" (regularized)</li>
+              <li>"norm" (regularized + normalized)</li>
+              <li>default: "norm"</li>
+            </ul>
+          </li>
+          <li>normalizationType (optional)
+            <ul>
+              <li>"dictionary"</li>
+              <li>"display"</li>
+              <li>default: "dictionary"</li>
+            </ul>
+          </li>
+          <li>elements (optional)
+            <ul>
+              <li>list of xml element names which should be tokenized (e.g. "s head")</li>
+              <li>default: empty list (which means: all elements are tokenized)</li>
+            </ul>
+          </li>
+          <li>stopElements (optional)
+            <ul>
+              <li>list of xml element names which are stop elements(e.g. "var emph"): stop elements: its tokens should not get word tags (when output format is "xml") or its tokens should be removed (if output format is "string")</li>
+              <li>default: empty list</li>
+            </ul>
+          </li>
+          <li>highlightTerms (optional)
+            <ul>
+              <li>list of word forms which should be highlighted. Each matched word form is surrounded by &lt;hi&gt;&lt;/hi&gt;. The matching function is dependent of the normalization. E.g. if normalization = "norm" then the normalized word form is fetched and highlighted.</li>
+              <li>default: empty list</li>
+            </ul>
+          </li>
+          <li>outputFormat (optional)
+            <ul>
+              <li>"xml"</li>
+              <li>"string"</li>
+              <li>default: "xml"</li>
+            </ul>
+          </li>
+          <li>outputOptions (optional)
+            <ul>
+              <li>output options separated by blanks (e.g. "withForms withLemmas")
+                <ul>
+                  <li>"withForms"</li>
+                  <li>"withLemmas"</li>
+                  <li>default: empty list</li>
+                </ul>
+              </li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>outputFormat=xml
+            <ul>
+              <li>tokenized inputString or document (enriched by element &lt;w&gt;)
+                <ul>
+                  <li>Example: &lt;s&gt;&lt;w lang="deu" form="dies" formRegularized="dies" formNormalized="dies" forms="dies, dieser, dieses, diesen" lemmas="dieser"&gt;Dies&lt;/w&gt; &lt;w 
+                  lang="deu" form="ist" formRegularized="ist" formNormalized="ist" forms="bin, bist, ist, seid, sind, sein, war, warst, wart" lemmas="sein"&gt;ist&lt;/w&gt; &lt;w 
+                  lang="deu" form="ein" formRegularized="ein" formNormalized="ein" forms="ein, eines, einer" lemmas="ein"&gt;ein&lt;/w&gt; &lt;w lang="deu" form="satz" 
+                  formRegularized="satz" formNormalized="satz" forms="satz, sätze, satzes" lemmas="satz"&gt;Satz&lt;/w&gt;&lt;/s&gt;
+                  </li>
+                </ul>
+              </li>
+            </ul>
+          <li>outputFormat=string
+            <ul>
+              <li>word tokens of inputString or document (separated by Blank)</li>
+            </ul> 
+          <li>Example: <a href="text/Tokenize?inputString=edo sum philoſophi&language=lat&outputFormat=xml">inputString=edo sum philoſophi&amp;language=lat&amp;outputFormat=xml</a></li>
+          <li>Example: <a href="text/Tokenize?language=lat&srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml%26mode=pureXml%26pn=13">language=lat&amp;srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml%26mode=pureXml%26pn=13</a></li>
+          <li>Example: <a href="text/Tokenize?language=lat&highlightTerms=eorumque&srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml%26mode=pureXml%26pn=13">language=lat&amp;highlightTerms=eorumque&amp;srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml%26mode=pureXml%26pn=13</a></li>
+          <li>Example: <a href="text/Tokenize?language=lat&outputOptions=withForms withLemmas&srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml%26mode=pureXml%26pn=13">language=lat&amp;outputOptions=withForms withLemmas&amp;srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml%26mode=pureXml%26pn=13</a></li>
+          <li>Example: <a href="text/Tokenize?language=lat&outputFormat=string&normalization=orig&srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml%26mode=pureXml%26pn=13">language=lat&amp;outputFormat=string&amp;normalization=orig&amp;srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml%26mode=pureXml%26pn=13</a></li>
+          <li>Example: <a href="text/Tokenize?language=lat&outputFormat=string&outputOptions=withLemmas&srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml%26mode=pureXml%26pn=13">language=lat&amp;outputFormat=string&amp;outputOptions=withLemmas&amp;srcUrl=http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml%26mode=pureXml%26pn=13</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/text/Normalize</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>inputString (required)
+            <ul>
+              <li>string which should be normalized</li>
+            </ul>
+          </li>
+          <li>language (optional)
+            <ul>
+              <li>ISO 639-3 specifier</li>
+              <li>default: "eng"</li>
+            </ul>
+          </li>
+          <li>type (optional)
+            <ul>
+              <li>"dictionary"</li>
+              <li>"display"</li>
+              <li>default: "display"</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>normalized string</li>
+          <li>Example: <a href="text/Normalize?inputString=philoſophi&language=lat">inputString=philoſophi&amp;language=lat</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+
+  <li><b>Url: /mpiwg-mpdl-cms-web/text/Transcode</b>
+    <ul>
+      <li>Request parameters
+        <ul>
+          <li>inputString (required)
+            <ul>
+              <li>string which should be transcoded</li>
+            </ul>
+          </li>
+          <li>srcEncoding (required)
+            <ul>
+              <li>"betacode"</li>
+              <li>"buckwalter"</li>
+              <li>"unicode"</li>
+            </ul>
+          </li>
+          <li>destEncoding (optional)
+            <ul>
+              <li>"betacode"</li>
+              <li>"buckwalter"</li>
+              <li>"unicode"</li>
+              <li>default: "unicode"</li>
+            </ul>
+          </li>
+        </ul>
+      </li>
+      <li>Response output
+        <ul>
+          <li>transcoded string</li>
+          <li>Example: <a href="text/Transcode?inputString=kai/&srcEncoding=betacode&destEncoding=unicode">inputString=kai/&amp;srcEncoding=betacode&amp;destEncoding=unicode</a></li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+</ul>   
+
+ 
+</body></html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/query/index.html	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,313 @@
+<html>
+<head>
+<title>MPIWG Query project</title>
+<script type="text/javascript">
+<!--
+function Browse() {
+  var luceneQuery = document.getElementById("luceneQueryId1");
+  var schema1checked = document.getElementById("schema1Id").checked;
+  var schema2checked = document.getElementById("schema2Id").checked;
+  var schema3checked = document.getElementById("schema3Id").checked;
+  var schema4checked = document.getElementById("schema4Id").checked;
+  var luceneSchemaQueryStr = GetLuceneSchemaQuery();
+  if (schema1checked && schema2checked && schema3checked && schema4checked)
+    luceneSchemaQueryStr =  "*";
+  luceneQuery.value = luceneSchemaQueryStr;
+}
+function GetLuceneSchemaQuery() {
+  var schemaFieldValue = "schemaName";
+  var schema1Val = document.getElementById("schema1Id").value;
+  var schema2Val = document.getElementById("schema2Id").value;
+  var schema3Val = document.getElementById("schema3Id").value;
+  var schema4Val = document.getElementById("schema4Id").value;
+  var schema1checked = document.getElementById("schema1Id").checked;
+  var schema2checked = document.getElementById("schema2Id").checked;
+  var schema3checked = document.getElementById("schema3Id").checked;
+  var schema4checked = document.getElementById("schema4Id").checked;
+  var luceneQueryStr = "+" + schemaFieldValue + ":" + "(";
+  if (schema1checked)
+    luceneQueryStr = luceneQueryStr + schema1Val;
+  if (schema2checked)
+    luceneQueryStr = luceneQueryStr + " " + schema2Val;
+  if (schema3checked)
+    luceneQueryStr = luceneQueryStr + " " + schema3Val;
+  if (schema4checked)
+    luceneQueryStr = luceneQueryStr + " " + schema4Val;
+  luceneQueryStr = luceneQueryStr + ")";
+  return luceneQueryStr;
+}
+function GetLuceneBoolOp(relOp) {
+  if (relOp == "mustContain")
+    return "+";
+  else if (relOp == "mustNotContain")
+    return "-";
+  else 
+    return "";
+}
+function AttributeQuery() {
+  var luceneQuery = document.getElementById("luceneQueryId2");
+  var sortBy = document.getElementById("sortById2");
+  var field1Val = document.getElementById("field1Id").value;
+  var field1QueryVal = document.getElementById("field1QueryId").value;
+  var relOp1Value = document.getElementById("relOp1Id").value;
+  var relOp1ValueLucene = GetLuceneBoolOp(relOp1Value);
+  var field2Val = document.getElementById("field2Id").value;
+  var field2QueryVal = document.getElementById("field2QueryId").value;
+  var relOp2Value = document.getElementById("relOp2Id").value;
+  var relOp2ValueLucene = GetLuceneBoolOp(relOp2Value);
+  var luceneQueryStr = "*:* " + relOp1ValueLucene + field1Val + ":";  // *:* so that the minus-Operator works correct when it is alone
+  luceneQueryStr = luceneQueryStr + field1QueryVal;
+  if (field2QueryVal != "")
+    luceneQueryStr = luceneQueryStr + " " + relOp2ValueLucene + field2Val + ":" + field2QueryVal;
+  var schemaQueryStr = GetLuceneSchemaQuery();
+  var schema1checked = document.getElementById("schema1Id").checked;
+  var schema2checked = document.getElementById("schema2Id").checked;
+  var schema3checked = document.getElementById("schema3Id").checked;
+  var schema4checked = document.getElementById("schema4Id").checked;
+  if (schema1checked && schema2checked && schema3checked && schema4checked)
+    schemaQueryStr =  "";
+  luceneQueryStr = luceneQueryStr + " " + schemaQueryStr;
+  luceneQuery.value = luceneQueryStr;
+  sortBy.value = "author";
+}
+function FulltextQuery() {
+  var luceneQuery = document.getElementById("luceneQueryId3");
+  var translateElem = document.getElementById("translateId3");
+  translateElem.value = "false";
+  var isTranslateQuery = document.getElementById("isTranslateQueryId").checked;
+  if (isTranslateQuery)
+    translateElem.value = "true";
+  var fulltextQueryFieldValue = "tokenOrig";
+  var isMorphQuery = document.getElementById("isMorphQueryId").checked;
+  if (isMorphQuery)
+    fulltextQueryFieldValue = "tokenMorph";
+  var fulltextQueryVal = document.getElementById("fulltextQueryId").value;
+  var luceneQueryStr = "+" + fulltextQueryFieldValue + ":(" + fulltextQueryVal + ")";
+  changeIsMorph();
+  var schemaQueryStr = GetLuceneSchemaQuery();
+  var schema1checked = document.getElementById("schema1Id").checked;
+  var schema2checked = document.getElementById("schema2Id").checked;
+  var schema3checked = document.getElementById("schema3Id").checked;
+  var schema4checked = document.getElementById("schema4Id").checked;
+  if (schema1checked && schema2checked && schema3checked && schema4checked)
+    schemaQueryStr =  "";
+  luceneQueryStr = luceneQueryStr + " " + schemaQueryStr;
+  luceneQuery.value = luceneQueryStr;
+}
+function changeIsMorph() {
+  var isMorphQuery = document.getElementById("isMorphQueryId").checked;
+  var language = document.getElementById("languageId3");
+  if (isMorphQuery) {
+    var languageValue = document.getElementById("languageId").value;
+    if (languageValue == "none") {
+      if (language != null) 
+        language.parentNode.removeChild(language);  
+    } else if (language == null) {
+      var queryDocumentsForm = document.getElementById("queryDocumentsId");
+      var languageElement = document.createElement("input");
+      languageElement.setAttribute("type", "hidden");
+      languageElement.setAttribute("name", "language");
+      languageElement.setAttribute("id", "languageId3");
+      languageElement.value = languageValue;
+      queryDocumentsForm.appendChild(languageElement);
+    } else if (language != null) {
+      language.value = languageValue;
+    }
+  } else {
+    if (language != null) 
+      language.parentNode.removeChild(language);
+  }
+}
+function checkCR(event) {
+  var keyCode = event.keyCode
+  if (keyCode == 13)
+    return false;
+}
+
+-->
+</script>
+</head>
+<body>
+  <table height="60px">
+    <colgroup>
+      <col width="90%"/>
+      <col width="10%"/>
+    </colgroup>
+    <tr>
+    <td align="left" valign="top">
+      <text style="font-weight:bold;font-size:30px">Query documents <a href="info.html"><img src="../images/info.png" valign="bottom" width="18" height="18" border="0" alt="Info Query Documents"/></a></text>
+    </td>
+    <td align="left" valign="top">
+      Release 0.5, July, 2012
+    </td>
+    </tr>
+  </table>
+  <hr/>
+  <table>
+    <tr>
+    <td valign="top" height="60px">
+      <table>
+      <tr>
+        <td valign="top"><b>Documents:</b></td>
+        <td>
+          <text style="margin-left:15px;">Archimedes DTD</text><br/>
+          <text style="margin-left:15px;">(until 2008)</text>
+        </td>
+        <td valign="top">
+          <text style="margin-left:1px;"></text><input type="checkbox" name="schema1" id="schema1Id" value="archimedes" checked="checked"/>
+        </td>
+        <td>
+          <text style="margin-left:20px;">Echo Schema</text><br/>
+          <text style="margin-left:20px;">(since 2009)</text>
+        </td>
+        <td valign="top">
+          <text style="margin-left:1px;"></text><input type="checkbox" name="schema2" id="schema2Id" 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="schema3" id="schema3Id" value="TEI" checked="checked"/>
+        </td>
+        <td>
+          <text style="margin-left:20px;">Diverse</text><br/>
+          <text style="margin-left:20px;">(since 2011)</text>
+        </td>
+        <td valign="top">
+          <text style="margin-left:1px;"></text><input type="checkbox" name="schema4" id="schema4Id" value="html" checked="checked"/>
+        </td>
+        <td valign="top">
+          <form name="queryDocuments" action="/mpiwg-mpdl-cms-web/query/QueryDocuments" method="get">
+          <input type="hidden" name="query" id="luceneQueryId1"/>
+          <input type="hidden" name="sortBy" id="sortById1" value="author"/>
+          <text style="margin-left:40px;"></text><button type="submit" onclick="Browse()">Browse</button>
+         </form>
+       </td>
+      </tr>
+      <tr>
+      </tr>
+      </table> 
+    </td>
+    </tr>
+
+    <tr>
+    <td valign="top" height="70px">
+      <table>
+      <tr>
+      <td>
+      <select name="field1" id="field1Id">
+      <option value ="author" selected="true">Author</option>
+      <option value ="title">Title</option>
+      <option value ="publisher">Place</option>
+      <option value ="date">Year</option>
+      <option value ="docId">Id</option>
+      <option value ="language">Language</option>
+      </select>          
+      </td>
+      <td>
+      <select name="relOp1" id="relOp1Id">
+      <option value ="mustContain" selected="true">must contain</option>
+      <option value ="mayContain">may contain</option>
+      <option value ="mustNotContain">does not contain</option>
+      </select>          
+      </td>
+      <td>
+      <input type="text" size="40" name="field1Query" id="field1QueryId" onkeypress="return checkCR(event)"/>
+      </td>
+      <td valign="middle">
+      <form name="queryDocuments" action="/mpiwg-mpdl-cms-web/query/QueryDocuments" method="get">
+        <input type="hidden" name="query" id="luceneQueryId2"/>
+        <input type="hidden" name="sortBy" id="sortById2"/>
+        <button type="submit" onclick="AttributeQuery()">Query</button>
+      </form>
+      </td>
+      </tr>
+
+      <tr>
+      <td>
+      <select name="field2" id="field2Id">
+      <option value ="author">Author</option>
+      <option value ="title" selected="true">Title</option>
+      <option value ="publisher">Place</option>
+      <option value ="date">Year</option>
+      <option value ="docId">Id</option>
+      <option value ="language">Language</option>
+      </select>          
+      </td>
+      <td>
+      <select name="relOp2" id="relOp2Id">
+      <option value ="mustContain" selected="true">must contain</option>
+      <option value ="mayContain">may contain</option>
+      <option value ="mustNotContain">does not contain</option>
+      </select>          
+      </td>
+      <td>
+      <input type="text" size="40" name="field2Query" id="field2QueryId" value="" onkeypress="return checkCR(event)"/>
+      </td>
+      </tr>
+      </table>
+    </td>
+    </tr>
+    
+    <tr>
+    <td valign="top" height="60px">
+      <table>
+        <tr>
+        <td>
+        Document contains <input type="text" size="40" name="fulltextQuery" id="fulltextQueryId" onkeypress="return checkCR(event)"/>
+        </td>
+        <td valign="middle">
+        <form id="queryDocumentsId" name="queryDocuments" action="/mpiwg-mpdl-cms-web/query/QueryDocuments" method="get">
+          <input type="hidden" name="query" id="luceneQueryId3"/>
+          <input type="hidden" name="language" id="languageId3"/>
+          <input type="hidden" name="translate" id="translateId3"/>
+          <button type="submit" onclick="FulltextQuery()">Query</button>
+        </form>
+        </td>
+        </tr>
+      </table>
+      <table>
+        <tr>
+          <td valign="top">
+            <text style="margin-left:30px;">morphological</text>
+          </td>
+          <td valign="top">
+            <text style="margin-left:1px;"></text><input type="checkbox" name="isMorphQuery" id="isMorphQueryId" value="isMorphQuery" onchange="ChangeIsMorph()"/>
+          </td>
+          <td valign="top">
+            <text style="margin-left:3px;">language: </text>
+          </td>
+          <td valign="top" style="margin-left:3px;">
+          <text style="margin-left:1px;"></text>
+          <select name="language" id="languageId">
+          <option value ="none" selected="true">None</option>
+          <option value ="ara">Arabic</option>
+          <option value ="zho">Chinese</option>
+          <option value ="nld">Dutch</option>
+          <option value ="eng">English</option>
+          <option value ="fra">French</option>
+          <option value ="deu">German</option>
+          <option value ="grc">Greek</option>
+          <option value ="ita">Italian</option>
+          <option value ="lat">Latin</option>
+          </select>
+          </td>
+          <td valign="top">
+            <text style="margin-left:10px;">translate</text><br/>
+          </td>
+          <td valign="top">
+            <text style="margin-left:1px;"></text><input type="checkbox" name="isTranslateQuery" id="isTranslateQueryId" value="translate"/>
+          </td>
+        </tr>
+      </table>
+    </td>
+    </tr>
+
+  </table> 
+  <hr/>
+  <p/>
+  See the <a href="../cms-services.html">CMS Services Page</a>, if you find a bug <a href="https://it-dev.mpiwg-berlin.mpg.de/tracs/mpdl-project-software/newticket">let us know</a>
+  <br/>Last software update: July, 2012
+</body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/query/info.html	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <title>Max Planck Institute for the History of Science - CMS services - Documentation</title>
+  </head>
+<body>
+<h2>Max Planck Institute for the History of Science - CMS services- Documentation</h2>
+
+<h4>Document bases</h4>
+<ul>
+  <li><b>Archimedes DTD (until 2008): </b>more than 120 documents (4KB - 18MB), coming from Echo collections "Archimedes" and "Historical Travel Guides", languages: latin, italian, english, german, french, dutch, greek, arabic, chinese<br/></li>
+  <li><b>Echo Schema (since 2009): </b>planned more than 100 documents in different languages<br/></li>
+  <li><b>TEI Schema (since 2011): </b>different languages, mainly by external document providers<br/></li>
+  <li><b>Diverse (since 2011): </b>different languages, no schema prerequesites, mainly HTML documents</li>
+</ul>
+
+<h4>Metadata and fulltext search</h4>
+Query power of Lucene, see: <a href="http://lucene.apache.org/core/3_6_0/queryparsersyntax.html">Lucene query syntax</a>
+
+</body></html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/WebContent/xsl/generateId.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="xml" encoding="utf-8"/>
+
+<xsl:template match="@*|node()">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="*:s|*:head">
+  <xsl:variable name="elemName" select="name()"/>
+  <xsl:variable name="docPos">
+    <xsl:choose>
+      <xsl:when test="$elemName = 's'">
+        <xsl:value-of select="count(./preceding::*:s) + 1"/>
+	    </xsl:when>
+      <xsl:when test="$elemName = 'head'">
+        <xsl:value-of select="count(./preceding::*:head) + 1"/>
+      </xsl:when>
+	    <xsl:otherwise></xsl:otherwise>
+	  </xsl:choose>
+  </xsl:variable>
+  <xsl:copy>
+    <xsl:attribute name="xml:id">
+      <xsl:value-of select="concat($elemName, $docPos)"/>
+    </xsl:attribute>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/build/build.xml	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,57 @@
+<!DOCTYPE project>
+<project name="mpiwg-mpdl-cms-web" default="dist" basedir="../">
+  <description>mpiwg-mpdl-cms-web</description>
+  <!-- global properties -->
+  <property name="baseLibFile" location="../mpiwg-mpdl-cms/dist/mpiwg-mpdl-cms.jar"/>
+  <property name="src" location="src"/>
+  <property name="lib" location="WebContent/WEB-INF/lib"/>
+  <property name="libTomcat" location="/Applications/java/apache-tomcat-7.0.26/lib"/>
+  <property name="webappTomcat" location="/Applications/java/apache-tomcat-7.0.26/webapps"/>
+  <property name="build" location="build/classes"/>
+  <property name="dist" location="dist"/>
+
+	<path id="classpath">
+    <fileset dir="${lib}" includes="**/*.jar"/>
+    <fileset dir="${libTomcat}" includes="**/*.jar"/>
+  </path>
+  
+  <target name="init">
+    <!-- Create time stamp -->
+    <tstamp/>
+    <mkdir dir="${build}"/>
+    <mkdir dir="${dist}"/>
+    <copy file="${baseLibFile}" todir="${lib}"/>
+  </target>
+
+  <target name="compile" depends="init" description="compile">
+    <javac srcdir="${src}" destdir="${build}" classpathref="classpath" includeantruntime="false"/>
+  </target>
+
+  <target name="dist" depends="compile" description="generate the distribution">
+    <delete file="WebContent/WEB-INF/classes/constants.properties"/>
+    <copy overwrite="true" file="conf/constants.properties" tofile="WebContent/WEB-INF/classes/constants.properties"/>
+    <jar jarfile="${dist}/mpiwg-mpdl-cms-web.jar" basedir="${build}"/>
+    <copy file="dist/mpiwg-mpdl-cms-web.jar" todir="${lib}"/>
+    <war destfile="dist/mpiwg-mpdl-cms-web.war" webxml="WebContent/WEB-INF/web.xml">
+      <fileset dir="WebContent"/>
+      <lib dir="WebContent/WEB-INF/lib"/>
+    </war>
+    <copy file="dist/mpiwg-mpdl-cms-web.war" todir="${webappTomcat}"/>
+  </target>
+
+  <target name="dist-remote-thrax" depends="compile" description="generate the distribution">
+    <delete file="WebContent/WEB-INF/classes/constants.properties"/>
+    <copy overwrite="true" file="conf/constants-thrax.properties" tofile="WebContent/WEB-INF/classes/constants.properties"/>
+    <jar jarfile="dist-remote/mpiwg-mpdl-cms-web.jar" basedir="${build}"/>
+    <copy file="dist-remote/mpiwg-mpdl-cms-web.jar" todir="${lib}"/>
+    <war destfile="dist-remote/mpiwg-mpdl-cms-web.war" webxml="WebContent/WEB-INF/web.xml">
+      <fileset dir="WebContent"/>
+      <lib dir="WebContent/WEB-INF/lib"/>
+    </war>
+  </target>
+
+  <target name="clean" description="clean" >
+    <delete dir="${build}"/>
+    <delete file="${dist}/mpiwg-mpdl-cms-web.jar"/>
+  </target>
+</project>
\ No newline at end of file
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/exception/ApplicationException.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/DocumentOperation.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocInfo.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocument.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocumentJobs.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetPage.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetToken.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/MoreLikeThis.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/MpiwgMpdlCmsWebServletContextListener.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/QueryDocument.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/QueryDocuments.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/cms/XQueryDocument.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetDictionaryEntries.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetForms.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetLemmas.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/MpiwgMpdlLtWebServletContextListener.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Normalize.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Tokenize.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Transcode.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/build/classes/de/mpg/mpiwg/berlin/mpdl/servlets/util/ServletUtil.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/conf/constants-thrax.properties	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+documentsDir=/usr/local/java/mpdl-data/xml/documents
+luceneDocumentsDir=/usr/local/java/mpdl-data/xml/lucene/documents
+luceneNodesDir=/usr/local/java/mpdl-data/xml/lucene/nodes
+dataDir=/usr/local/java/mpdl-data/lt
+confDir=/usr/local/java/mpdl-data/collectionConfs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/conf/constants.properties	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+documentsDir=/Users/jwillenborg/mpdl/data/xml/documents
+luceneDocumentsDir=/Users/jwillenborg/mpdl/data/xml/lucene/documents
+luceneNodesDir=/Users/jwillenborg/mpdl/data/xml/lucene/nodes
+dataDir=/Users/jwillenborg/mpdl/data/lt
+confDir=/Users/jwillenborg/mpdl/data/collectionConfs
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/dist-remote/mpiwg-mpdl-cms-web.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/dist-remote/mpiwg-mpdl-cms-web.war has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/dist/mpiwg-mpdl-cms-web.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms-web/dist/mpiwg-mpdl-cms-web.war has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/exception/ApplicationException.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,15 @@
+package de.mpg.mpiwg.berlin.mpdl.exception;
+
+public class ApplicationException extends Exception {
+  private static final long serialVersionUID = 1L;
+
+  public ApplicationException(Exception e) {
+    super(e);
+  }
+
+  public ApplicationException(String str) {
+    super(str);
+  }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/DocumentOperation.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,102 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.scheduler.CmsChainScheduler;
+import de.mpg.mpiwg.berlin.mpdl.cms.scheduler.CmsDocOperation;
+import de.mpg.mpiwg.berlin.mpdl.servlets.util.ServletUtil;
+
+public class DocumentOperation extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+
+  public DocumentOperation() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String srcUrlStr = request.getParameter("srcUrl");
+    String docId = request.getParameter("docId");  // id in file system: e.g. /tei/en/Test_1789.xml
+    String mainLanguage = request.getParameter("mainLanguage");  // main language of that document
+    String elementNames = request.getParameter("elementNames");  
+    String operation = request.getParameter("operation");
+    String outputFormat = request.getParameter("outputFormat");
+    if (outputFormat == null)
+      outputFormat = "xml";
+    if (outputFormat.equals("xml")) {
+      response.setContentType("text/xml");
+    } else { 
+      response.setContentType("text/html");
+    }
+    CmsDocOperation docOperation = new CmsDocOperation(operation, srcUrlStr, null, docId);
+    if (mainLanguage != null)
+      docOperation.setMainLanguage(mainLanguage);
+    String[] elementNamesArray = null;
+    if (elementNames != null)
+      elementNamesArray = elementNames.split(" ");
+    docOperation.setElementNames(elementNamesArray);
+    try {
+      if (docId == null || docId.isEmpty()) {
+        write(response, "Parameter: \"docId\" is not set. Please set parameter \"docId\".");
+        return;
+      }
+      if (operation.equals("create") || operation.equals("delete")) {
+        CmsChainScheduler scheduler = CmsChainScheduler.getInstance();
+        docOperation = scheduler.doOperation(docOperation);
+        String jobId = "" + docOperation.getOrderId();
+        String baseUrl = ServletUtil.getInstance().getBaseUrl(request);
+        String docJobUrlStr = baseUrl + "/doc/GetDocumentJobs?id=" + jobId;
+        if (outputFormat.equals("xml")) {
+          write(response, "<result>");
+          write(response, "<docJob>");
+          write(response, "<id>" + jobId + "</id>");
+          write(response, "<url>" + docJobUrlStr + "</url>");
+          write(response, "</docJob>");
+          write(response, "</result>");
+        } else if (outputFormat.equals("html")) {
+          write(response, "<html>");
+          write(response, "<h2>" + "Document operation result" + "</h2>");
+          write(response, "See your document operation " + jobId + " <a href=\"" + docJobUrlStr + "\">" + "here" + "</a>");
+          write(response, "</html>");
+        } else if (outputFormat.equals("string")) {
+          write(response, docJobUrlStr);
+        }
+      } else {
+        String errorStr = "Error: Operation: " + operation + " is not supported";
+        if (outputFormat.equals("xml")) {
+          write(response, "<error>" + errorStr + "</error>");
+        } else { 
+          write(response, "<html>");
+          write(response, "<h2>" + "Error" + "</h2>");
+          write(response, errorStr);
+        }
+      }
+      PrintWriter out = response.getWriter();
+      out.close();
+    } catch (Exception e) {
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    // TODO 
+  }
+
+  private void write(HttpServletResponse response, String str) throws IOException {
+    PrintWriter out = response.getWriter();
+    out.write(str);
+  }
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocInfo.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,195 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Date;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.FileUtils;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.DocumentHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.MetadataRecord;
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.TocTransformer;
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.util.Util;
+
+public class GetDocInfo extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  private TocTransformer tocTransformer;
+  
+  public GetDocInfo() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+    ServletContext context = getServletContext();
+    tocTransformer = (TocTransformer) context.getAttribute("tocTransformer");
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String docId = request.getParameter("docId");
+    String field = request.getParameter("field");
+    String outputFormat = request.getParameter("outputFormat");
+    if (outputFormat == null)
+      outputFormat = "xml";
+    String cssUrl = request.getParameter("cssUrl");
+    if (cssUrl == null) {
+      String baseUrl = getBaseUrl(request);
+      cssUrl = baseUrl + "/css/page.css";
+    }
+    try {
+      IndexHandler indexHandler = IndexHandler.getInstance();
+      MetadataRecord mdRecord = indexHandler.getDocMetadata(docId);
+      if (outputFormat.equals("xml"))
+        response.setContentType("text/xml");
+      else if (outputFormat.equals("html"))
+        response.setContentType("text/html");
+      PrintWriter out = response.getWriter();
+      if (mdRecord != null && outputFormat.equals("xml")) {
+        out.print("<doc>");
+        out.print("<id>" + docId + "</id>");
+        String identifier = mdRecord.getIdentifier();
+        if ((field == null || (field != null && field.equals("identifier"))) && identifier != null)
+          out.print("<identifier>" + identifier + "</identifier>");
+        String uri = mdRecord.getUri();
+        if ((field == null || (field != null && field.equals("uri"))) && uri != null)
+          out.print("<uri>" + uri + "</uri>");
+        String collectionNames = mdRecord.getCollectionNames();
+        if ((field == null || (field != null && field.equals("collectionNames"))) && collectionNames != null)
+          out.print("<collectionNames>" + collectionNames + "</collectionNames>");
+        String author = mdRecord.getCreator();
+        if ((field == null || (field != null && field.equals("author"))) && author != null)
+          out.print("<author>" + author + "</author>");
+        String title = mdRecord.getTitle();
+        if ((field == null || (field != null && field.equals("title"))) && title != null)
+          out.print("<title>" + title + "</title>");
+        String language = mdRecord.getLanguage();
+        if ((field == null || (field != null && field.equals("language"))) && language != null)
+          out.print("<language>" + language + "</language>");
+        String publisher = mdRecord.getPublisher();
+        if ((field == null || (field != null && field.equals("publisher"))) && publisher != null)
+          out.print("<publisher>" + publisher + "</publisher>");
+        String date = mdRecord.getYear();
+        if ((field == null || (field != null && field.equals("date"))) && date != null)
+          out.print("<date>" + date + "</date>");
+        String subject = mdRecord.getSubject();
+        if ((field == null || (field != null && field.equals("subject"))) && subject != null)
+          out.print("<subject>" + subject + "</subject>");
+        String rights = mdRecord.getRights();
+        if ((field == null || (field != null && field.equals("rights"))) && rights != null)
+          out.print("<rights>" + rights + "</rights>");
+        String license = mdRecord.getLicense();
+        if ((field == null || (field != null && field.equals("license"))) && license != null)
+          out.print("<license>" + license + "</license>");
+        String accessRights = mdRecord.getAccessRights();
+        if ((field == null || (field != null && field.equals("accessRights"))) && accessRights != null)
+          out.print("<accessRights>" + accessRights + "</accessRights>");
+        String echoId = mdRecord.getEchoId();
+        if ((field == null || (field != null && field.equals("echoId"))) && echoId != null)
+          out.print("<echoId>" + echoId + "</echoId>");
+        String echoPageImageDir = mdRecord.getEchoPageImageDir();
+        if ((field == null || (field != null && field.equals("echoPageImageDir"))) && echoPageImageDir != null)
+          out.print("<echoPageImageDir>" + echoPageImageDir + "</echoPageImageDir>");
+        String echoFiguresDir = mdRecord.getEchoFiguresDir();
+        if ((field == null || (field != null && field.equals("echoFiguresDir"))) && echoFiguresDir != null)
+          out.print("<echoFiguresDir>" + echoFiguresDir + "</echoFiguresDir>");
+        String mpiwgDocId = mdRecord.getMpiwgDocId();
+        if ((field == null || (field != null && field.equals("mpiwgDocId"))) && mpiwgDocId != null)
+          out.print("<mpiwgDocId>" + mpiwgDocId + "</mpiwgDocId>");
+        if (field == null || (field != null && ! field.equals("toc") && ! field.equals("figures") && ! field.equals("notes") && ! field.equals("notesHandwritten") && ! field.equals("pages") && ! field.equals("places")))
+          out.print("<system>");
+        int pageCount = mdRecord.getPageCount();
+        if (field == null || (field != null && field.equals("countPages")))
+          out.print("<countPages>" + pageCount + "</countPages>");
+        DocumentHandler docHandler = new DocumentHandler();
+        String docDir = docHandler.getDocDir(docId);
+        String tocFileName = docDir + "/toc.xml";
+        File tocFile = new File(tocFileName);
+        String tocStr = FileUtils.readFileToString(tocFile, "utf-8");
+        String tocCount = getTocCount(tocStr, "toc");
+        out.print("<countTocEntries>" + tocCount + "</countTocEntries>");
+        String figuresCount = getTocCount(tocStr, "figures");
+        out.print("<countFigures>" + figuresCount + "</countFigures>");
+        String notesCount = getTocCount(tocStr, "notes");
+        out.print("<countNotes>" + notesCount + "</countNotes>");
+        String notesHandwrittenCount = getTocCount(tocStr, "notesHandwritten");
+        out.print("<countNotesHandwritten>" + notesHandwrittenCount + "</countNotesHandwritten>");
+        String placesCount = getTocCount(tocStr, "places");
+        out.print("<countPlaces>" + placesCount + "</countPlaces>");
+        Date lastModified = mdRecord.getLastModified();
+        if ((field == null || (field != null && field.equals("lastModified"))) && lastModified != null) {
+          String lastModifiedStr = new Util().toXsDate(lastModified);
+          out.print("<lastModified>" + lastModifiedStr + "</lastModified>");
+        }
+        String schemaName = mdRecord.getSchemaName();
+        if ((field == null || (field != null && field.equals("schema"))) && schemaName != null)
+          out.print("<schema>" + schemaName + "</schema>");
+        if (field == null || (field != null && ! field.equals("toc") && ! field.equals("figures") && ! field.equals("notes") && ! field.equals("notesHandwritten") && ! field.equals("pages") && ! field.equals("places")))
+          out.print("</system>");
+        if (field != null && (field.equals("toc") || field.equals("figures") || field.equals("notes") || field.equals("notesHandwritten") || field.equals("pages") || field.equals("places"))) { 
+          String tocXmlStr = tocTransformer.transform(tocStr, field, outputFormat);
+          out.print(tocXmlStr);
+        }
+        out.print("</doc>");
+      } else if (mdRecord != null && outputFormat.equals("html")) {
+        if (field != null && (field.equals("toc") || field.equals("figures") || field.equals("notes") || field.equals("notesHandwritten") || field.equals("pages") || field.equals("places"))) { 
+          DocumentHandler docHandler = new DocumentHandler();
+          String docDir = docHandler.getDocDir(docId);
+          String tocFileName = docDir + "/toc.xml";
+          File tocFile = new File(tocFileName);
+          String tocStr = FileUtils.readFileToString(tocFile, "utf-8");
+          String tocHtmlStr = tocTransformer.transform(tocStr, field, outputFormat);
+          String title = docId + ", " + field;
+          String head = "<head><title>" + title + "</title><link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssUrl + "\"/></head>";
+          String result = "<html>" + head + "<body>" + tocHtmlStr + "</body>" + "</html>";
+          out.print(result);
+        }
+      } else {
+        out.print("<result>" + "no document found with id: " + docId + "</result>");
+      }
+      out.close();
+    } catch (ApplicationException e) {
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+
+  private String getBaseUrl(HttpServletRequest request) {
+    return getServerUrl(request) + request.getContextPath();
+  }
+
+  private String getServerUrl(HttpServletRequest request) {
+    if ( ( request.getServerPort() == 80 ) || ( request.getServerPort() == 443 ) )
+      return request.getScheme() + "://" + request.getServerName();
+    else
+      return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
+  }
+
+  private String getTocCount(String tocStr, String type) {
+    String tocCount = "0";
+    if (tocStr == null)
+      return "0";
+    String listTypeStr = "<list type=\"" + type + "\" count=\"";
+    int from = tocStr.indexOf(listTypeStr);
+    if (from != -1) {
+      from = from + listTypeStr.length(); 
+      int to = tocStr.indexOf("\"", from);
+      tocCount = tocStr.substring(from, to);
+    }
+    return tocCount;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocument.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,71 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URLConnection;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.DocumentHandler;
+
+public class GetDocument extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  private OutputStream out = null;
+
+  public GetDocument() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String id = request.getParameter("id");  
+    DocumentHandler docHandler = new DocumentHandler();
+    String fullFileName = docHandler.getDocFullFileName(id);
+    File file = new File(fullFileName);
+    if (file.exists()) {
+      write(response, file);
+    } else {
+      write(response, "Document: " + id + " does not exist");
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    // TODO 
+  }
+
+  private void write(HttpServletResponse response, File file) throws IOException {
+    String fileName = file.getName();
+    BufferedInputStream is = new BufferedInputStream(new FileInputStream(file));
+    String contentType = URLConnection.guessContentTypeFromName(fileName);  // other methods: URLConnection.guessContentTypeFromStream(is); or MIMEUtils.getMIMEType(file);
+    if (contentType != null)
+      response.setContentType(contentType);
+    response.setHeader("Content-Disposition", "filename=" + fileName);
+    out = response.getOutputStream();
+    byte[] buf = new byte[20000*1024]; // 20MB buffer
+    int bytesRead;
+    while ((bytesRead = is.read(buf)) != -1) {
+      out.write(buf, 0, bytesRead);
+    }
+    is.close();
+    out.flush();
+  }
+
+  private void write(HttpServletResponse response, String str) throws IOException {
+    out = response.getOutputStream();
+    byte[] strBytes = str.getBytes("utf-8");
+    out.write(strBytes, 0, strBytes.length);
+    out.flush();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetDocumentJobs.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,244 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Date;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.scheduler.CmsChainScheduler;
+import de.mpg.mpiwg.berlin.mpdl.cms.scheduler.CmsDocOperation;
+
+public class GetDocumentJobs extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  public GetDocumentJobs() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    response.setContentType("text/xml");
+    String jobIdStr = request.getParameter("id");
+    String outputFormat = request.getParameter("outputFormat");
+    if (outputFormat == null)
+      outputFormat = "xml";
+    try {
+      boolean getAllJobs = false;
+      if (jobIdStr == null)
+        getAllJobs = true;
+      CmsChainScheduler scheduler = CmsChainScheduler.getInstance();
+      ArrayList<CmsDocOperation> docOperations = new ArrayList<CmsDocOperation>();
+      if (getAllJobs) {
+        docOperations = scheduler.getDocOperations();
+      } else {
+        int jobId = Integer.parseInt(jobIdStr);
+        CmsDocOperation docOperation = scheduler.getDocOperation(jobId);
+        if (docOperation != null)
+          docOperations.add(docOperation);
+      }
+      PrintWriter out = response.getWriter();
+      String resultStr = "";
+      if (outputFormat.equals("xml")) {
+        response.setContentType("text/xml");
+        resultStr = createXmlString(docOperations);
+      } else if (outputFormat.equals("html")) { 
+        response.setContentType("text/html");
+        resultStr = createHtmlString(docOperations);
+      } else if (outputFormat.equals("error")) { 
+        response.setContentType("text/html");
+        resultStr = createErrorString(docOperations);
+      }
+      out.print(resultStr);
+      out.close();
+    } catch (Exception e) {
+      throw new ServletException(e);
+    }
+  }
+
+  String createXmlString(ArrayList<CmsDocOperation> docOperations) {
+    StringBuilder result = new StringBuilder();
+    if (docOperations != null && ! docOperations.isEmpty()) {
+      result.append("<docJobs>");
+      for (int i=0; i<docOperations.size(); i++) {
+        CmsDocOperation docOperation = docOperations.get(i);
+        result.append("<job>");
+        int jobId = docOperation.getOrderId();
+        result.append("<id>" + jobId + "</id>");
+        result.append("<name>" + docOperation.getName() + "</name>");
+        result.append("<status>");
+        Date start = docOperation.getStart();
+        String startStr = "No start time available because job is scheduled into server queue where other jobs have been started earlier";
+        if (start != null)
+          startStr = start.toString();
+        result.append("<started>" + startStr + "</started>");
+        Date end = docOperation.getEnd();
+        String endStr = "No end time available because job is not finished yet";
+        if (end != null)
+          endStr = end.toString();
+        result.append("<finished>" + endStr + "</finished>");
+        String status = docOperation.getStatus();
+        result.append("<description>" + status + "</description>");
+        String errorMessage = docOperation.getErrorMessage();
+        if (errorMessage == null)
+          errorMessage = "no error";
+        result.append("<error>" + errorMessage + "</error>");
+        result.append("</status>");
+        if (docOperation.getName().equals("delete")) {
+          result.append("<destination>");
+          result.append("<docId>" + docOperation.getDocIdentifier() + "</docId>");
+          result.append("</destination>");
+        } else if (docOperation.getName().equals("create")) {
+          result.append("<source>");
+          result.append("<url>" + docOperation.getSrcUrl() + "</url>");
+          result.append("<uploadFileName>" + docOperation.getUploadFileName() + "</uploadFileName>");
+          result.append("</source>");
+          result.append("<destination>");
+          result.append("<docId>" + docOperation.getDocIdentifier() + "</docId>");
+          result.append("</destination>");
+        }
+        String desc = "Document operations are maintained on server asychronously. Each operation is scheduled into a server job queue " + 
+            "and is executed when all previous started jobs in the queue are worked off. Each operation needs some execution time dependent " + 
+            "on the size and the number of pages of the document, the speed of the network connection and the performance of the " +
+            "server.";
+        result.append("<description>" + desc + "</description>");
+        result.append("</job>");
+      }
+      result.append("</docJobs>");
+    } else {
+      String message = "there are no scheduled jobs (neither finished, queued or executed)";
+      result.append("<message>" + message + "</message>");
+    }
+    return result.toString();
+  }
+  
+  String createHtmlString(ArrayList<CmsDocOperation> docOperations) {
+    // TODO all
+    StringBuilder result = new StringBuilder();
+    result.append("<html>");
+    result.append("<head>");
+    result.append("<title>" + "Document operation status" + "</title>");
+    result.append("</head>");
+    result.append("<body>");
+    result.append("<table>");
+    result.append("<h1>" + "Document operation status" + "</h1>");
+    if (docOperations != null && ! docOperations.isEmpty()) {
+      for (int i=0; i<docOperations.size(); i++) {
+        result.append("<tr>");
+        result.append("<td>");
+        CmsDocOperation docOperation = docOperations.get(i);
+        result.append("<b>Operation: </b>" + docOperation.getName());
+        int jobId = docOperation.getOrderId();
+        result.append("<p/>");
+        result.append("<b>Job id: </b>" + jobId);
+        result.append("<p/>");
+        result.append("<b>Job status: </b>");
+        result.append("<ul>");
+        Date start = docOperation.getStart();
+        String startStr = "No start time available because job is scheduled into server queue where other jobs have been started earlier";
+        if (start != null)
+          startStr = start.toString();
+        result.append("<li>");
+        result.append("<b>Started: </b>");
+        result.append("<started>" + startStr + "</started>");
+        result.append("</li>");
+        Date end = docOperation.getEnd();
+        String endStr = "No end time available because job is not finished yet";
+        if (end != null)
+          endStr = end.toString();
+        result.append("<li>");
+        result.append("<b>Finished: </b>");
+        result.append("<finished>" + endStr + "</finished>");
+        result.append("</li>");
+        String status = docOperation.getStatus();
+        result.append("<li>");
+        result.append("<b>Description: </b>");
+        result.append("<description>" + status + "</description>");
+        result.append("</li>");
+        String errorMessage = docOperation.getErrorMessage();
+        result.append("<li>");
+        if (errorMessage != null) {
+          result.append("<font color=\"#FF0000\"><b>Error: </b></font>");
+          result.append("<error>" + errorMessage + "</error>");
+        } else { 
+          result.append("<b>Error: </b>");
+          result.append("<error>" + "no error" + "</error>");
+        }
+        result.append("</li>");
+        result.append("</ul>");
+        if (docOperation.getName().equals("delete")) {
+          result.append("<b>Destination</b>");
+          result.append("<ul>");
+          result.append("<li>");
+          result.append("<b>Document identifier: </b>");
+          result.append("<docId>" + docOperation.getDocIdentifier() + "</docId>");
+          result.append("</li>");
+          result.append("</ul>");
+        } else if (docOperation.getName().equals("create")) {
+          result.append("<b>Source</b>");
+          result.append("<ul>");
+          result.append("<li>");
+          result.append("<url>" + docOperation.getSrcUrl() + "</url>");
+          String uploadFileName = docOperation.getUploadFileName();
+          if (uploadFileName != null) {
+            result.append("<li>");
+            result.append("<uploadFileName>" + uploadFileName + "</uploadFileName>");
+            result.append("</li>");
+          }
+          result.append("</li>");
+          result.append("</ul>");
+          result.append("<b>Destination</b>");
+          result.append("<ul>");
+          result.append("<li>");
+          result.append("<b>Document identifier: </b>");
+          result.append("<docId>" + docOperation.getDocIdentifier() + "</docId>");
+          result.append("</li>");
+          result.append("</ul>");
+        }
+        String desc = "Document operations are maintained on server asychronously. Each operation is scheduled into a server job queue " + 
+            "and is executed when all previous started jobs in the queue are worked off. Each operation needs some execution time dependent " + 
+            "on the size and the number of pages of the document, the speed of the network connection and the performance of the " +
+            "server."; 
+        result.append("<b>Description: </b>" + desc);
+        result.append("<p/>");
+        result.append("<hr/>");
+      }
+      result.append("</td>");
+      result.append("</tr>");
+    } else {
+      String message = "there are no scheduled jobs (neither finished, queued or executed)";
+      result.append("<message>" + message + "</message>");
+    }
+    result.append("</table>");
+    result.append("</body>");
+    result.append("</html>");
+    return result.toString();
+  }
+  
+  String createErrorString(ArrayList<CmsDocOperation> docOperations) {
+    String error = "";
+    if (docOperations != null && ! docOperations.isEmpty()) {
+      for (int i=0; i<docOperations.size(); i++) {
+        CmsDocOperation docOperation = docOperations.get(i);
+        String errorMessage = docOperation.getErrorMessage();
+        if (errorMessage != null)
+          error = errorMessage;
+      }
+    } 
+    return error;
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetPage.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,215 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringReader;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.FileUtils;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import com.sun.org.apache.xerces.internal.parsers.SAXParser;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.DocumentHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.MetadataRecord;
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.HighlightContentHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.PageTransformer;
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.WordContentHandler;
+
+public class GetPage extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  private PageTransformer pageTransformer;
+
+  public GetPage() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+    ServletContext context = getServletContext();
+    pageTransformer = (PageTransformer) context.getAttribute("pageTransformer");
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    String result = "";
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String docId = request.getParameter("docId");
+    String pageStr = request.getParameter("page");
+    String normalization = request.getParameter("normalization");
+    String highlightQuery = request.getParameter("highlightQuery");
+    String highlightQueryType = request.getParameter("highlightQueryType");
+    if (highlightQueryType == null)
+      highlightQueryType = "form";
+    String highlightElem = request.getParameter("highlightElem");
+    String highlightElemPosStr = request.getParameter("highlightElemPos");
+    int highlightElemPos = -1;
+    if (highlightElemPosStr != null)
+      highlightElemPos = Integer.parseInt(highlightElemPosStr);
+    String mode = request.getParameter("mode");
+    if (mode == null)
+      mode = "untokenized";
+    String outputFormat = request.getParameter("outputFormat");
+    if (outputFormat == null)
+      outputFormat = "html";
+    String cssUrl = request.getParameter("cssUrl");
+    String baseUrl = getBaseUrl(request);
+    if (cssUrl == null) {
+      cssUrl = baseUrl + "/css/page.css";
+    }
+    int page = 1;
+    if (pageStr != null)
+      page = Integer.parseInt(pageStr);
+    if (outputFormat.equals("xml"))
+      response.setContentType("text/xml");
+    else if (outputFormat.equals("html") || outputFormat.equals("xmlDisplay"))
+      response.setContentType("text/html");
+    // normalization 
+    if (normalization == null || ! (normalization.equals("orig") || normalization.equals("reg") || normalization.equals("norm")))
+      normalization = "norm";
+    if (outputFormat.equals("xmlDisplay"))
+      normalization = "orig";
+    PrintWriter out = response.getWriter();
+    try {
+      IndexHandler indexHandler = IndexHandler.getInstance();
+      MetadataRecord mdRecord = indexHandler.getDocMetadata(docId);
+      DocumentHandler docHandler = new DocumentHandler();
+      String docDir = docHandler.getDocDir(docId);
+      String docPageDir = docDir + "/" + "pages";
+      String pageFileName = docPageDir + "/page-" + page + "-morph.xml";
+      File pageFile = new File(pageFileName);
+      if (page == 1 && ! (new File(docPageDir)).exists()) {
+        String docFileName = docHandler.getDocFullFileName(docId);
+        pageFile = new File(docFileName);  // when no page breaks are in the document then the whole document is the first page
+      }
+      if (! pageFile.exists()) {
+        out.print("There is no page: " + page + " in document");
+        out.close();
+        return;
+      }
+      String pageHtmlFileName = docPageDir + "/page-" + page + ".html";
+      File pageHtmlFile = new File(pageHtmlFileName);
+      String fragmentMorphStr = FileUtils.readFileToString(pageFile, "utf-8");
+      if (! pageHtmlFile.exists())  // TODO rausnehmen sobald alle Dokumente neu indexiert wurden
+        fragmentMorphStr = enrichWordsOrigRegNorm(fragmentMorphStr);
+      if (outputFormat.equals("html") || outputFormat.equals("xmlDisplay")) {
+        String schemaName = mdRecord.getSchemaName();
+        String title = docId + ", Page: " + page;
+        String xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+        String cssShowWordFileName = "pageNormDict.css";
+        if (outputFormat.equals("xmlDisplay"))
+          cssShowWordFileName = "pageOrig.css"; // xml display shows always the original text
+        else if (normalization.equals("orig") && mode.equals("untokenized"))
+          cssShowWordFileName = "pageOrig.css";
+        else if (normalization.equals("orig") && mode.equals("tokenized"))
+          cssShowWordFileName = "pageOrigDict.css";
+        else if (normalization.equals("reg") && mode.equals("untokenized"))
+          cssShowWordFileName = "pageReg.css";
+        else if (normalization.equals("reg") && mode.equals("tokenized"))
+          cssShowWordFileName = "pageRegDict.css";
+        else if (normalization.equals("norm") && mode.equals("untokenized"))
+          cssShowWordFileName = "pageNorm.css";
+        String showWordCssUrl = baseUrl + "/css/" + cssShowWordFileName;
+        String mainCssLink = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssUrl + "\"/>";
+        String showWordCssLink = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + showWordCssUrl + "\"/>";
+        String head = "<head>" + "<title>" + title + "</title>" + showWordCssLink + mainCssLink + "</head>";
+        String namespace = "";
+        String pageHtmlStr = null;
+        if (pageHtmlFile.exists() && outputFormat.equals("html") && (highlightElem == null && highlightQuery == null)) {
+          pageHtmlStr = FileUtils.readFileToString(pageHtmlFile, "utf-8");
+        } else {
+          if (highlightElem != null || highlightQuery != null) {
+            String hiQueryType = "orig";
+            if (highlightQueryType.equals("morph"))
+              hiQueryType = "morph";
+            else
+              hiQueryType = normalization;
+            String language = mdRecord.getLanguage();
+            fragmentMorphStr = highlight(fragmentMorphStr, highlightElem, highlightElemPos, hiQueryType, highlightQuery, language);
+          }
+          pageHtmlStr = pageTransformer.transform(fragmentMorphStr, mdRecord, page, outputFormat);
+        }
+        if (schemaName != null && schemaName.equals("echo")) {
+          namespace = "xmlns:echo=\"http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/\" xmlns:de=\"http://www.mpiwg-berlin.mpg.de/ns/de/1.0/\" " +
+                  "xmlns:dcterms=\"http://purl.org/dc/terms\" " + "xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" xmlns:mml=\"http://www.w3.org/1998/Math/MathML\" " +
+                  "xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
+        }
+        result = xmlHeader + "<html " + namespace + ">" + head + "<body>" + pageHtmlStr + "</body>" + "</html>";
+      } else {
+        String pageFileNameOrig = docPageDir + "/page-" + page + ".xml";
+        File pageFileOrig = new File(pageFileNameOrig);
+        if (pageFileOrig.exists())
+          result = FileUtils.readFileToString(pageFileOrig, "utf-8");
+        else
+          result = "";
+      }
+      out.print(result);
+      out.close();
+    } catch (ApplicationException e) {
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+
+  private String getBaseUrl(HttpServletRequest request) {
+    return getServerUrl(request) + request.getContextPath();
+  }
+
+  private String getServerUrl(HttpServletRequest request) {
+    if ( ( request.getServerPort() == 80 ) || ( request.getServerPort() == 443 ) )
+      return request.getScheme() + "://" + request.getServerName();
+    else
+      return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
+  }
+
+  private String enrichWordsOrigRegNorm(String xmlStr) throws ApplicationException {
+    try {
+      WordContentHandler wordContentHandler = new WordContentHandler();
+      XMLReader xmlParser = new SAXParser();
+      xmlParser.setContentHandler(wordContentHandler);
+      StringReader strReader = new StringReader(xmlStr);
+      InputSource inputSource = new InputSource(strReader);
+      xmlParser.parse(inputSource);
+      String result = wordContentHandler.getResult();
+      return result;
+    } catch (SAXException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  private String highlight(String xmlStr, String highlightElem, int highlightElemPos, String highlightQueryType, String highlightQuery, String language) throws ApplicationException {
+    String result = null;
+    try {
+      HighlightContentHandler highlightContentHandler = new HighlightContentHandler(highlightElem, highlightElemPos, highlightQueryType, highlightQuery, language);
+      highlightContentHandler.setFirstPageBreakReachedMode(true);
+      XMLReader xmlParser = new SAXParser();
+      xmlParser.setContentHandler(highlightContentHandler);
+      StringReader stringReader = new StringReader(xmlStr);
+      InputSource inputSource = new InputSource(stringReader);
+      xmlParser.parse(inputSource);
+      result = highlightContentHandler.getResult().toString();
+    } catch (SAXException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+    return result;
+  }
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/GetToken.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,87 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.lucene.index.Term;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Token;
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+public class GetToken extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  public GetToken() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String docId = request.getParameter("docId");
+    String attribute = request.getParameter("attribute");
+    if (attribute == null)
+      attribute = "tokenOrig";
+    String query = request.getParameter("query");
+    String countStr = request.getParameter("count");
+    if (countStr == null)
+      countStr = "100";
+    int count = Integer.parseInt(countStr);
+    String outputFormat = request.getParameter("outputFormat");
+    if (outputFormat == null)
+      outputFormat = "xml";
+    try {
+      IndexHandler indexHandler = IndexHandler.getInstance();
+      ArrayList<Token> token = null;
+      if (docId == null)
+        token = indexHandler.getToken(attribute, query, count); 
+      else
+        token = indexHandler.getToken(docId, attribute, query, count);
+      if (outputFormat.equals("xml"))
+        response.setContentType("text/xml");
+      else if (outputFormat.equals("html"))
+        response.setContentType("text/html");
+      else 
+        response.setContentType("text/xml");
+      PrintWriter out = response.getWriter();
+      out.print("<result>");
+      out.print("<attribute>" + attribute + "</attribute>");
+      out.print("<query>" + query + "</query>");
+      out.print("<count>" + count + "</count>");
+      out.print("<result>");
+      if (token != null) {
+        for (int i=0; i<token.size(); i++) {
+          Token t = token.get(i);
+          Term term = t.getTerm();
+          int freq = t.getFreq();
+          out.print("<token>");
+          out.print("<text>" + term.text() + "</text>");
+          if (freq != -1)
+            out.print("<freq>" + freq + "</freq>");
+          out.print("</token>");
+        }
+      }
+      out.print("</result>");
+      out.print("</result>");
+      out.close();
+    } catch (ApplicationException e) {
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/MoreLikeThis.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,140 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Date;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.lucene.document.Fieldable;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Document;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Hits;
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+
+public class MoreLikeThis extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+       
+  public MoreLikeThis() {
+    super();
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String outputFormat = request.getParameter("outputFormat");
+    if (outputFormat == null)
+      outputFormat = "html";
+    String docId = request.getParameter("docId");
+    String pageStr = request.getParameter("page");
+    if (pageStr == null)
+      pageStr = "1";
+    int page = Integer.parseInt(pageStr);
+    String pageSizeStr = request.getParameter("pageSize");
+    if (pageSizeStr == null)
+      pageSizeStr = "10";
+    int pageSize = Integer.parseInt(pageSizeStr);
+    int from = (page * pageSize) - pageSize;  // e.g. 0
+    int to = page * pageSize - 1;  // e.g. 9
+    PrintWriter out = response.getWriter();
+    IndexHandler indexHandler;
+    try {
+      Date begin = new Date();
+      indexHandler = IndexHandler.getInstance();
+      Hits hits = indexHandler.moreLikeThis(docId, from, to);
+      ArrayList<Document> docs = null;
+      if (hits != null)
+        docs = hits.getHits();
+      int hitsSize = -1;
+      int docsSize = -1;
+      if (hits != null)
+        hitsSize = hits.getSize();
+      if (docs != null)
+        docsSize = docs.size();
+      Date end = new Date();
+      long elapsedTime = end.getTime() - begin.getTime();
+      if (outputFormat.equals("xml"))
+        response.setContentType("text/xml");
+      else if (outputFormat.equals("html"))
+        response.setContentType("text/html");
+      else 
+        response.setContentType("text/xml");
+      if (outputFormat.equals("xml")) {
+        out.print("<result>");
+        out.print("<query>");
+        out.print("<docId>" + docId + "</docId>");
+        out.print("<resultPage>" + page + "</resultPage>");
+        out.print("<resultPageSize>" + pageSize + "</resultPageSize>");
+        out.print("</query>");
+        out.print("<hitsSize>" + hitsSize + "</hitsSize>");
+        out.print("<hits>");
+        for (int i=0; i<docsSize; i++) {
+          Document doc = docs.get(i);
+          out.print("<doc>");
+          String similarDocId = doc.getFieldable("docId").stringValue();
+          out.print("<docId>" + similarDocId + "</docId>");
+          Fieldable docCollectionNamesField = doc.getFieldable("collectionNames");
+          if (docCollectionNamesField != null) {
+            String docCollectionNames = docCollectionNamesField.stringValue();
+            out.print("<collectionName>" + docCollectionNames + "</collectionName>");
+          }
+          ArrayList<String> hitFragments = doc.getHitFragments();
+          if (hitFragments != null) {
+            out.print("<hitFragments>");
+            for (int j=0; j<hitFragments.size(); j++) {
+              String hitFragment = hitFragments.get(j);
+              out.print("<hitFragment>" + hitFragment + "</hitFragment>");
+            }
+            out.print("</hitFragments>");
+          }
+          out.print("</doc>");
+        }
+        out.print("</hits>");
+        out.print("<executionTime>" + elapsedTime + "</executionTime>");
+        out.print("</result>");
+      } else if (outputFormat.equals("html")) {
+        StringBuilder htmlStrBuilder = new StringBuilder();
+        htmlStrBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
+        htmlStrBuilder.append("<html>");
+        htmlStrBuilder.append("<head>");
+        htmlStrBuilder.append("<title>Similar documents of: " + docId + "</title>");
+        htmlStrBuilder.append("</head>");
+        htmlStrBuilder.append("<body>");
+        htmlStrBuilder.append("<h4>Similar documents of: " + docId + "</h4>");
+        int fromDisplay = from + 1;
+        int toDisplay = to + 1;
+        if (hitsSize < to)
+          toDisplay = hitsSize;
+        htmlStrBuilder.append("Result: " + fromDisplay + " - " + toDisplay + " of " + hitsSize + " documents" + "</td>");
+        htmlStrBuilder.append("<ul>");
+        for (int i=0; i<docsSize; i++) {
+          Document doc = docs.get(i);
+          String similarDocId = doc.getFieldable("docId").stringValue();
+          int num = (page - 1) * pageSize + i + 1;
+          htmlStrBuilder.append("<li>" + num + ". " + similarDocId + "</li>");
+        }
+        htmlStrBuilder.append("</ul>");
+        htmlStrBuilder.append("<p/>");
+        htmlStrBuilder.append("Elapsed time: " + elapsedTime + " ms");
+        htmlStrBuilder.append("</body>");
+        htmlStrBuilder.append("</html>");
+        out.print(htmlStrBuilder.toString());
+      } 
+      out.close();
+    } catch (Exception e) {
+      throw new ServletException(e);
+    }
+  }
+
+  /**
+   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+   */
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    // TODO Auto-generated method stub
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/MpiwgMpdlCmsWebServletContextListener.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,67 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.db.LexHandler;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.MorphologyCache;
+import de.mpg.mpiwg.berlin.mpdl.servlets.cms.MpiwgMpdlCmsWebServletContextListener;
+import de.mpg.mpiwg.berlin.mpdl.xml.transform.FragmentTransformer;
+import de.mpg.mpiwg.berlin.mpdl.xml.xquery.XQueryEvaluator;
+import de.mpg.mpiwg.berlin.mpdl.cms.general.Constants;
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.scheduler.CmsChainScheduler;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.PageTransformer;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.TocTransformer;
+
+public class MpiwgMpdlCmsWebServletContextListener implements ServletContextListener {
+  private ServletContext context = null;
+  private FragmentTransformer fragmentTransformer = null;
+  private PageTransformer pageTransformer = null;
+  private TocTransformer tocTransformer = null;
+  private XQueryEvaluator xQueryEvaluator = null;  
+  public void contextInitialized(ServletContextEvent event) {
+    try {
+      this.context = event.getServletContext();
+      String documentsDirectory = Constants.getInstance().getDocumentsDir();
+      String luceneDocumentsDirectory = Constants.getInstance().getLuceneDocumentsDir();
+      String luceneNodesDirectory = Constants.getInstance().getLuceneNodesDir();
+      context.setAttribute("documentDirectory", documentsDirectory);
+      context.setAttribute("luceneDocumentsDirectory", luceneDocumentsDirectory);
+      context.setAttribute("luceneNodesDirectory", luceneNodesDirectory);
+      System.out.println(MpiwgMpdlCmsWebServletContextListener.class.getName() + ": contextInitialized (documentsDirectory= \"" + documentsDirectory + "\", set in constants.properties)");
+      System.out.println(MpiwgMpdlCmsWebServletContextListener.class.getName() + ": contextInitialized (luceneDocumentsDirectory= \"" + luceneDocumentsDirectory + "\", set in constants.properties)");
+      System.out.println(MpiwgMpdlCmsWebServletContextListener.class.getName() + ": contextInitialized (luceneNodesDirectory= \"" + luceneNodesDirectory + "\", set in constants.properties)");
+      fragmentTransformer = new FragmentTransformer();
+      context.setAttribute("fragmentTransformer", fragmentTransformer);
+      System.out.println(MpiwgMpdlCmsWebServletContextListener.class.getName() + ": contextInitialized (fragmentTransformer)");
+      pageTransformer = new PageTransformer();
+      context.setAttribute("pageTransformer", pageTransformer);
+      System.out.println(MpiwgMpdlCmsWebServletContextListener.class.getName() + ": contextInitialized (pageTransformer)");
+      tocTransformer = new TocTransformer();
+      context.setAttribute("tocTransformer", tocTransformer);
+      System.out.println(MpiwgMpdlCmsWebServletContextListener.class.getName() + ": contextInitialized (tocTransformer)");
+      xQueryEvaluator = new XQueryEvaluator();
+      context.setAttribute("xQueryEvaluator", xQueryEvaluator);
+      System.out.println(MpiwgMpdlCmsWebServletContextListener.class.getName() + ": contextInitialized (xQueryEvaluator)");
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  public void contextDestroyed(ServletContextEvent event) {
+    try {
+      this.context = null;
+      LexHandler.getInstance().end();
+      MorphologyCache.getInstance().end(); 
+      IndexHandler.getInstance().end();
+      CmsChainScheduler scheduler = CmsChainScheduler.getInstance();
+      scheduler.end();
+      Thread.sleep(1000);  // with this, also the scheduler worker threads could be closed
+      System.out.println(MpiwgMpdlCmsWebServletContextListener.class.getName() + ": contextDestroyed");
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/QueryDocument.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,350 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.util.ArrayList;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.lucene.document.Fieldable;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import com.sun.org.apache.xerces.internal.parsers.SAXParser;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Document;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Hits;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.MetadataRecord;
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.HighlightContentHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.PageTransformer;
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+public class QueryDocument extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  private PageTransformer pageTransformer = null;
+  
+  public QueryDocument() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+    ServletContext context = getServletContext();
+    pageTransformer = (PageTransformer) context.getAttribute("pageTransformer");
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String docId = request.getParameter("docId");
+    String query = request.getParameter("query");
+    String[] normFunctions = {"none"};
+    if (query.contains("tokenReg"))  // TODO ordentlich behandeln
+      normFunctions[0] = "reg";
+    else if (query.contains("tokenNorm"))  // TODO ordentlich behandeln
+      normFunctions[0] = "norm";
+    String[] outputOptions = {};
+    if (query.contains("tokenMorph")) {  // TODO ordentlich behandeln
+      outputOptions = new String[1];
+      outputOptions[0] = "withLemmas";
+    }
+    String pageStr = request.getParameter("page");
+    if (pageStr == null)
+      pageStr = "1";
+    int page = Integer.parseInt(pageStr);
+    String pageSizeStr = request.getParameter("pageSize");
+    if (pageSizeStr == null)
+      pageSizeStr = "10";
+    int pageSize = Integer.parseInt(pageSizeStr);
+    int from = (page * pageSize) - pageSize;  // e.g. 0
+    int to = page * pageSize - 1;  // e.g. 9
+    String outputFormat = request.getParameter("outputFormat");
+    if (outputFormat == null)
+      outputFormat = "xml";
+    try {
+      IndexHandler indexHandler = IndexHandler.getInstance();
+      Hits hits = indexHandler.queryDocument(docId, query, from, to);
+      MetadataRecord docMetadataRecord = indexHandler.getDocMetadata(docId);
+      if (outputFormat.equals("xml"))
+        response.setContentType("text/xml");
+      else if (outputFormat.equals("html"))
+        response.setContentType("text/html");
+      else 
+        response.setContentType("text/xml");
+      PrintWriter out = response.getWriter();
+      String resultStr = "";
+      if (outputFormat.equals("xml"))
+        resultStr = createXmlString(docMetadataRecord, query, page, pageSize, normFunctions, outputOptions, hits);
+      else if (outputFormat.equals("html"))
+        resultStr = createHtmlString(docMetadataRecord, query, page, pageSize, normFunctions, outputOptions, hits, request);
+      out.print(resultStr);
+      out.close();
+    } catch (ApplicationException e) {
+      throw new ServletException(e);
+    }
+  }
+
+  private String createXmlString(MetadataRecord docMetadataRecord, String query, int page, int pageSize, String[] normFunctions, String[] outputOptions, Hits hits) throws ApplicationException {
+    String docId = docMetadataRecord.getDocId();
+    ArrayList<Document> docs = null;
+    if (hits != null)
+      docs = hits.getHits();
+    int hitsSize = -1;
+    int docsSize = -1;
+    if (hits != null)
+      hitsSize = hits.getSize();
+    if (docs != null)
+      docsSize = docs.size();
+    StringBuilder xmlStrBuilder = new StringBuilder();
+    xmlStrBuilder.append("<document>");
+    xmlStrBuilder.append("<id>" + docId + "</id>");
+    xmlStrBuilder.append("<query>");
+    xmlStrBuilder.append("<queryText>" + query + "</queryText>");
+    xmlStrBuilder.append("<resultPage>" + page + "</resultPage>");
+    xmlStrBuilder.append("<resultPageSize>" + pageSize + "</resultPageSize>");
+    xmlStrBuilder.append("</query>");
+    xmlStrBuilder.append("<hitsSize>" + hitsSize + "</hitsSize>");
+    xmlStrBuilder.append("<hits>");
+    for (int i=0; i<docsSize; i++) {
+      Document doc = docs.get(i);
+      int num = (page - 1) * pageSize + i + 1;
+      xmlStrBuilder.append("<hit>");
+      xmlStrBuilder.append("<num>" + num + "</num>");
+      String pageNumber = null;
+      Fieldable fPageNumber = doc.getFieldable("pageNumber");
+      if (fPageNumber != null) {
+        pageNumber = fPageNumber.stringValue();
+        xmlStrBuilder.append("<pageNumber>" + pageNumber + "</pageNumber>");
+      }
+      String elementPagePosition = null;
+      Fieldable fElementPagePosition = doc.getFieldable("elementPagePosition");
+      if (fElementPagePosition != null) {
+        elementPagePosition = fElementPagePosition.stringValue();
+        xmlStrBuilder.append("<pagePosition>" + elementPagePosition + "</pagePosition>");
+      }
+      String lineNumber = null;
+      Fieldable fLineNumber = doc.getFieldable("lineNumber");
+      if (fLineNumber != null) {
+        lineNumber = fLineNumber.stringValue();
+        xmlStrBuilder.append("<lineNumber>" + lineNumber + "</lineNumber>");
+      }
+      String elementPosition = null;
+      Fieldable fElementPosition = doc.getFieldable("elementAbsolutePosition");
+      if (fElementPosition != null) {
+        elementPosition = fElementPosition.stringValue();
+        xmlStrBuilder.append("<absolutePosition>" + elementPosition + "</absolutePosition>");
+      }
+      String xpath = null;
+      Fieldable fXPath = doc.getFieldable("xpath");
+      if (fXPath != null) {
+        xpath = fXPath.stringValue();
+        xmlStrBuilder.append("<xpath>" + xpath + "</xpath>");
+      }
+      String xmlId = null;
+      Fieldable fXmlId = doc.getFieldable("xmlId");
+      if (fXmlId != null) {
+        xmlId = fXmlId.stringValue();
+        xmlStrBuilder.append("<xmlId>" + xmlId + "</xmlId>");
+      }
+      String language = null;
+      Fieldable fLanguage = doc.getFieldable("language");
+      if (fLanguage != null) {
+        language = fLanguage.stringValue();
+        xmlStrBuilder.append("<language>" + language + "</language>");
+      }
+      String xmlContentTokenized = null;
+      Fieldable fXmlContentTokenized = doc.getFieldable("xmlContentTokenized");
+      if (fXmlContentTokenized != null) {
+        String highlightQueryType = "orig";
+        if (withLemmas(outputOptions)) {
+          highlightQueryType = "morph";
+        } else if (normFunctions != null) { 
+          String normFunction = normFunctions[0];
+          highlightQueryType = normFunction;
+          if (normFunction.equals("none")) {
+            highlightQueryType = "orig";
+          }
+        }
+        xmlContentTokenized = fXmlContentTokenized.stringValue();
+        String xmlPre = "<content xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" xmlns:mml=\"http://www.w3.org/1998/Math/MathML\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">";
+        String xmlPost = "</content>";
+        String xmlInputStr = xmlPre + xmlContentTokenized + xmlPost;
+        String docLanguage = docMetadataRecord.getLanguage();
+        String highlightedXmlStr = highlight(xmlInputStr, highlightQueryType, query, docLanguage);
+        if (highlightedXmlStr == null)
+          highlightedXmlStr = "<content>" + xmlContentTokenized + "</content>";
+        xmlStrBuilder.append(highlightedXmlStr);
+      }
+      xmlStrBuilder.append("</hit>");
+    }
+    xmlStrBuilder.append("</hits>");
+    xmlStrBuilder.append("</document>");
+    return xmlStrBuilder.toString();   
+  }
+  
+  private String createHtmlString(MetadataRecord docMetadataRecord, String query, int page, int pageSize, String[] normFunctions, String[] outputOptions, Hits hits, HttpServletRequest request) throws ApplicationException {
+    String docId = docMetadataRecord.getDocId();
+    ArrayList<Document> docs = null;
+    if (hits != null)
+      docs = hits.getHits();
+    int hitsSize = -1;
+    int docsSize = -1;
+    if (hits != null)
+      hitsSize = hits.getSize();
+    if (docs != null)
+      docsSize = docs.size();
+    String highlightQueryType = "orig";
+    String normalizationStr = "";
+    String highlightQueryTypeStr = "";
+    if (withLemmas(outputOptions)) {
+      highlightQueryTypeStr = "&amp;highlightQueryType=norm";
+      highlightQueryType = "norm";
+    } else if (normFunctions != null) { 
+      String normFunction = normFunctions[0];
+      normalizationStr = "&amp;normalization=" + normFunction;
+      highlightQueryType = normFunction;
+      if (normFunction.equals("none")) {
+        normalizationStr = "&amp;normalization=" + "orig";
+        highlightQueryType = "orig";
+      }
+    }
+    StringBuilder xmlStrBuilder = new StringBuilder();
+    xmlStrBuilder.append("<html>");
+    xmlStrBuilder.append("<head>");
+    xmlStrBuilder.append("<title>Document: \"" + docId + " " + query + "\"</title>");
+    String baseUrl = getBaseUrl(request);
+    String cssUrl = baseUrl + "/css/page.css";
+    String cssShowWordFileName = "pageOrig.css";
+    if (highlightQueryType.equals("reg"))
+      cssShowWordFileName = "pageReg.css"; 
+    else if (highlightQueryType.equals("norm"))
+      cssShowWordFileName = "pageNorm.css";
+    String showWordCssUrl = baseUrl + "/css/" + cssShowWordFileName;
+    xmlStrBuilder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + showWordCssUrl + "\"/>");
+    xmlStrBuilder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssUrl + "\"/>");
+    xmlStrBuilder.append("</head>");
+    xmlStrBuilder.append("<body>");
+    xmlStrBuilder.append("<span class=\"about\">[<span class=\"it\">This is a MPIWG CMS technology service</span>] <a href=\"/mpiwg-mpdl-cms-web/index.html\"><img src=\"/mpiwg-mpdl-cms-web/images/info.png\" valign=\"bottom\" width=\"15\" height=\"15\" border=\"0\" alt=\"MPIWG CMS service\"/></a></span>");
+    xmlStrBuilder.append("<span class=\"query\">Query: " + query + "</span>");
+    xmlStrBuilder.append("<span class=\"result\">");
+    xmlStrBuilder.append("<span class=\"resultPage\">" + page + "</span>");
+    xmlStrBuilder.append("<span class=\"resultPageSize\">" + pageSize + "</span>");
+    xmlStrBuilder.append("<span class=\"hitsSize\">" + hitsSize + "</span>");
+    xmlStrBuilder.append("</span>");
+    xmlStrBuilder.append("<table>");
+    for (int i=0; i<docsSize; i++) {
+      xmlStrBuilder.append("<tr class=\"hit\">");
+      Document doc = docs.get(i);
+      int num = (page - 1) * pageSize + i + 1;
+      xmlStrBuilder.append("<td class=\"hitNum\">" + num + ". " + "</td>");
+      xmlStrBuilder.append("<td class=\"hitLink\">");
+      String posStr = "";
+      String pageNumber = "";
+      Fieldable fPageNumber = doc.getFieldable("pageNumber");
+      if (fPageNumber != null) {
+        pageNumber = fPageNumber.stringValue();
+        posStr = posStr + "Page " + pageNumber + ", ";
+      }
+      String elementName = null;
+      String presElementName = "";
+      Fieldable fElementName = doc.getFieldable("elementName");
+      if (fElementName != null) {
+        elementName = fElementName.stringValue();
+        presElementName = getPresentationName(elementName);
+      }
+      String elementPagePosition = "";
+      Fieldable fElementPagePosition = doc.getFieldable("elementPagePosition");
+      if (fElementPagePosition != null) {
+        elementPagePosition = fElementPagePosition.stringValue();
+        posStr = posStr + presElementName + " " + elementPagePosition + ":";
+      }
+      String language = docMetadataRecord.getLanguage();
+      String getPageLink = baseUrl + "/query/GetPage?docId=" + docId + "&amp;page=" + pageNumber + normalizationStr + "&amp;highlightElem=" + elementName + "&amp;highlightElemPos=" + elementPagePosition + highlightQueryTypeStr + "&amp;highlightQuery=" + query + "&amp;language=" + language;
+      xmlStrBuilder.append("<a href=\"" + getPageLink + "\">" + posStr + "</a>");
+      xmlStrBuilder.append("</td>");
+      String xmlContentTokenized = null;
+      Fieldable fXmlContentTokenized = doc.getFieldable("xmlContentTokenized");
+      if (fXmlContentTokenized != null) {
+        xmlContentTokenized = fXmlContentTokenized.stringValue();
+        String highlightedXmlStr = highlight(xmlContentTokenized, highlightQueryType, query, language);  
+        String highlightHtmlStr = pageTransformer.transform(highlightedXmlStr, docMetadataRecord, -1, "html");  // TODO performance: do not highlight each single node but highlight them all in one step
+        xmlStrBuilder.append("<td class=\"hitContent\">");
+        xmlStrBuilder.append(highlightHtmlStr);
+        xmlStrBuilder.append("</td>");
+      }
+      xmlStrBuilder.append("</tr>");
+    }
+    xmlStrBuilder.append("</table>");
+    xmlStrBuilder.append("</body>");
+    xmlStrBuilder.append("</html>");
+    return xmlStrBuilder.toString();   
+  }
+  
+  private String highlight(String xmlStr, String highlightQueryType, String highlightQuery, String language) throws ApplicationException {
+    String result = null;
+    try {
+      HighlightContentHandler highlightContentHandler = new HighlightContentHandler(null, -1, highlightQueryType, highlightQuery, language);
+      highlightContentHandler.setFirstPageBreakReachedMode(true);
+      XMLReader xmlParser = new SAXParser();
+      xmlParser.setContentHandler(highlightContentHandler);
+      StringReader stringReader = new StringReader(xmlStr);
+      InputSource inputSource = new InputSource(stringReader);
+      xmlParser.parse(inputSource);
+      result = highlightContentHandler.getResult().toString();
+    } catch (SAXException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+    return result;
+  }
+
+  private String getPresentationName(String elemName) {
+    String retStr = null;
+    if (elemName != null) {
+      if (elemName.equals("s")) {
+        retStr = "Sentence";
+      } else {
+        // first char to uppercase
+        char[] stringArray = elemName.toCharArray();
+        stringArray[0] = Character.toUpperCase(stringArray[0]);
+        retStr = new String(stringArray);
+      }
+    }
+    return retStr;
+  }
+  
+  private String getBaseUrl(HttpServletRequest request) {
+    return getServerUrl(request) + request.getContextPath();
+  }
+
+  private String getServerUrl(HttpServletRequest request) {
+    if ( ( request.getServerPort() == 80 ) || ( request.getServerPort() == 443 ) )
+      return request.getScheme() + "://" + request.getServerName();
+    else
+      return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
+  }
+
+  private boolean withLemmas(String[] outputOptions) {
+    boolean result = false;
+    for (int i=0; i< outputOptions.length; i++) {
+      String function = outputOptions[i];
+      if (function.equals("withLemmas"))
+        return true;
+    }
+    return result;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/QueryDocuments.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,333 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Date;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.lucene.document.Fieldable;
+import org.apache.lucene.search.Query;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Document;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.DocumentHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Hits;
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+
+public class QueryDocuments extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  public QueryDocuments() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String query = request.getParameter("query");
+    String sortBy = request.getParameter("sortBy");
+    String[] sortFields = null;
+    if (sortBy != null && ! sortBy.trim().isEmpty())
+      sortFields = sortBy.split(" ");
+    String language = request.getParameter("language");  // optional: is also detected by translator service
+    if (language != null && language.equals("none"))
+      language = null;
+    String translate = request.getParameter("translate");
+    String pageStr = request.getParameter("page");
+    if (pageStr == null)
+      pageStr = "1";
+    int page = Integer.parseInt(pageStr);
+    String pageSizeStr = request.getParameter("pageSize");
+    if (pageSizeStr == null)
+      pageSizeStr = "10";
+    int pageSize = Integer.parseInt(pageSizeStr);
+    int from = (page * pageSize) - pageSize;  // e.g. 0
+    int to = page * pageSize - 1;  // e.g. 9
+    String outputFormat = request.getParameter("outputFormat");
+    if (outputFormat == null)
+      outputFormat = "html";
+    if (outputFormat.equals("xml"))
+      response.setContentType("text/xml");
+    else if (outputFormat.equals("html"))
+      response.setContentType("text/html");
+    else 
+      response.setContentType("text/xml");
+    PrintWriter out = response.getWriter();
+    if (query == null) {
+      out.print("no query specified: please set parameter \"query\"");
+      out.close();
+      return;
+    }
+    try {
+      Date begin = new Date();
+      IndexHandler indexHandler = IndexHandler.getInstance();
+      boolean translateBool = false;
+      if (translate != null && translate.equals("true"))
+        translateBool = true;
+      boolean withHitHighlights = false;
+      if (query.contains("tokenOrig:") || query.contains("tokenMorph:") || query.contains("tokenReg:") || query.contains("tokenNorm:"))
+        withHitHighlights = true;
+      Hits hits = indexHandler.queryDocuments(query, sortFields, language, from, to, withHitHighlights, translateBool);
+      ArrayList<Document> docs = null;
+      if (hits != null)
+        docs = hits.getHits();
+      int hitsSize = -1;
+      int docsSize = -1;
+      if (hits != null)
+        hitsSize = hits.getSize();
+      if (docs != null)
+        docsSize = docs.size();
+      Date end = new Date();
+      long elapsedTime = end.getTime() - begin.getTime();
+      if (outputFormat.equals("xml")) {
+        out.print("<result>");
+        out.print("<query>");
+        out.print("<queryText>" + query + "</queryText>");
+        out.print("<resultPage>" + page + "</resultPage>");
+        out.print("<resultPageSize>" + pageSize + "</resultPageSize>");
+        out.print("</query>");
+        out.print("<hitsSize>" + hitsSize + "</hitsSize>");
+        out.print("<hits>");
+        for (int i=0; i<docsSize; i++) {
+          Document doc = docs.get(i);
+          out.print("<doc>");
+          String docId = doc.getFieldable("docId").stringValue();
+          out.print("<docId>" + docId + "</docId>");
+          Fieldable docCollectionNamesField = doc.getFieldable("collectionNames");
+          if (docCollectionNamesField != null) {
+            String docCollectionNames = docCollectionNamesField.stringValue();
+            out.print("<collectionName>" + docCollectionNames + "</collectionName>");
+          }
+          ArrayList<String> hitFragments = doc.getHitFragments();
+          if (hitFragments != null) {
+            out.print("<hitFragments>");
+            for (int j=0; j<hitFragments.size(); j++) {
+              String hitFragment = hitFragments.get(j);
+              out.print("<hitFragment>" + hitFragment + "</hitFragment>");
+            }
+            out.print("</hitFragments>");
+          }
+          out.print("</doc>");
+        }
+        out.print("</hits>");
+        out.print("<executionTime>" + elapsedTime + "</executionTime>");
+        out.print("</result>");
+      } else if (outputFormat.equals("html")) {
+        StringBuilder htmlStrBuilder = new StringBuilder();
+        String baseUrl = getBaseUrl(request);
+        String cssUrl = baseUrl + "/css/page.css";
+        htmlStrBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
+        htmlStrBuilder.append("<html>");
+        htmlStrBuilder.append("<head>");
+        htmlStrBuilder.append("<title>Query: " + query + "</title>");
+        htmlStrBuilder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssUrl + "\"/>");
+        htmlStrBuilder.append("</head>");
+        htmlStrBuilder.append("<body>");
+        htmlStrBuilder.append("<table align=\"right\" valign=\"top\">");
+        htmlStrBuilder.append("<td>[<i>This is a MPIWG CMS technology service</i>] <a href=\"/mpiwg-mpdl-cms-web/index.html\"><img src=\"/mpiwg-mpdl-cms-web/images/info.png\" valign=\"bottom\" width=\"15\" height=\"15\" border=\"0\" alt=\"MPIWG CMS service\"/></a></td>");
+        htmlStrBuilder.append("</table>");
+        htmlStrBuilder.append("<p/>");
+        String luceneQueryStr = query;
+        Query luceneQuery = hits.getQuery();
+        if (query != null)
+          luceneQueryStr = luceneQuery.toString();
+        String sortByStr = sortBy;
+        if (sortBy == null)
+          sortByStr = "";
+        htmlStrBuilder.append("<h4>Query: " + luceneQueryStr + ", sorted by: " + sortByStr + "</h4>");
+        htmlStrBuilder.append("<form action=\"QueryDocuments\" method=\"get\">");
+        htmlStrBuilder.append("<input type=\"hidden\" name=\"query\" value=\"" + query + "\"/>");
+        if (translate != null)
+          htmlStrBuilder.append("<input type=\"hidden\" name=\"translate\" value=\"" + translate + "\"/>");
+        if (language != null)
+          htmlStrBuilder.append("<input type=\"hidden\" name=\"language\" value=\"" + language + "\"/>");
+        htmlStrBuilder.append("<input type=\"hidden\" name=\"page\" id=\"pageId\" value=\"" + page + "\"/>");
+        htmlStrBuilder.append("<input type=\"hidden\" name=\"sortBy\" id=\"sortById\" value=\"" + sortByStr + "\"/>");
+        htmlStrBuilder.append("<input type=\"submit\" id=\"submitId\" style=\"position: absolute; left: -9999px\"/>");
+        htmlStrBuilder.append("<table>");
+        htmlStrBuilder.append("<colgroup>");
+        htmlStrBuilder.append("<col width=\"3%\"/>");
+        htmlStrBuilder.append("<col width=\"7%\"/>");
+        htmlStrBuilder.append("<col width=\"3%\"/>");
+        htmlStrBuilder.append("<col width=\"12%\"/>");
+        htmlStrBuilder.append("<col width=\"70%\"/>");
+        htmlStrBuilder.append("</colgroup>");
+        htmlStrBuilder.append("<tr>");
+        int countPages = hitsSize / 10 + 1;
+        if (hitsSize % 10 == 0) // modulo operator: e.g. 280 % 10 is 0
+          countPages = hitsSize / 10;
+        int pageLeft = page - 1;
+        if (page == 1)
+          pageLeft = 1;
+        int pageRight = page + 1; 
+        if (page == countPages)
+          pageRight = countPages;
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\"><button onclick=\"document.getElementById('pageId').value=" + pageLeft + "\" style=\"background:none;border:none;\"><img src=\"../images/left.gif\"/></button></td>");
+        htmlStrBuilder.append("<td align=\"middle\" valign=\"top\" nowrap=\"true\">" + page + " / " + countPages + "</td>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\"><button onclick=\"document.getElementById('pageId').value=" + pageRight + "\" style=\"background:none;border:none;\"><img src=\"../images/right.gif\"/></button></td>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\" nowrap=\"true\">Page: <input type=\"text\" size=\"3\" value=\"" + page + "\" id=\"pageTextId\" onkeydown=\"if (event.keyCode == 13) {document.getElementById('pageId').value=document.getElementById('pageTextId').value; document.getElementById('submitId').click();}\"/></td>");
+        int fromDisplay = from + 1;
+        int toDisplay = to + 1;
+        if (hitsSize < to)
+          toDisplay = hitsSize;
+        htmlStrBuilder.append("<td align=\"right\" valign=\"top\">" + fromDisplay + " - " + toDisplay + " of " + hitsSize + " documents" + "</td>");
+        htmlStrBuilder.append("</tr>");
+        htmlStrBuilder.append("</table>");
+        htmlStrBuilder.append("<p/>");
+        htmlStrBuilder.append("<table width=\"100%\" align=\"right\" border=\"2\" rules=\"groups\">");
+        htmlStrBuilder.append("<colgroup>");
+        htmlStrBuilder.append("<col width=\"3%\"/>");
+        htmlStrBuilder.append("<col width=\"15%\"/>");
+        htmlStrBuilder.append("<col width=\"45%\"/>");
+        htmlStrBuilder.append("<col width=\"10%\"/>");
+        htmlStrBuilder.append("<col width=\"5%\"/>");
+        htmlStrBuilder.append("<col width=\"10%\"/>");
+        htmlStrBuilder.append("<col width=\"6%\"/>");
+        htmlStrBuilder.append("<col width=\"5%\"/>");
+        htmlStrBuilder.append("<col width=\"4%\"/>");
+        htmlStrBuilder.append("</colgroup>");
+        htmlStrBuilder.append("<thead>");
+        htmlStrBuilder.append("<tr>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\" style=\"font-weight:bold;\">" + "No" + "</td>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + "<button onclick=\"document.getElementById('sortById').value='author'\" style=\"padding:0px;font-weight:bold;font-size:14px;background:none;border:none;\">" + "Author" + "</button></td>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + "<button onclick=\"document.getElementById('sortById').value='title'\"  style=\"padding:0px;font-weight:bold;font-size:14px;background:none;border:none;\">" + "Title" + "</button></td>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + "<button onclick=\"document.getElementById('sortById').value='publisher'\"  style=\"padding:0px;font-weight:bold;font-size:14px;background:none;border:none;\">" + "Place" + "</button></td>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + "<button onclick=\"document.getElementById('sortById').value='date'\"  style=\"padding:0px;font-weight:bold;font-size:14px;background:none;border:none;\">" + "Year" + "</button></td>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + "<button onclick=\"document.getElementById('sortById').value='docId'\" style=\"padding:0px;font-weight:bold;font-size:14px;background:none;border:none;\">" + "Id" + "</button></td>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + "<button onclick=\"document.getElementById('sortById').value='lastModified'\" style=\"padding:0px;font-weight:bold;font-size:14px;background:none;border:none;\">" + "Last modified" + "</button></td>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + "<button onclick=\"document.getElementById('sortById').value='language'\" style=\"padding:0px;font-weight:bold;font-size:14px;background:none;border:none;\">" + "Language" + "</button></td>");
+        htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + "<button onclick=\"document.getElementById('sortById').value='schemaName'\" style=\"padding:0px;font-weight:bold;font-size:14px;background:none;border:none;\">" + "Schema" + "</button></td>");
+        htmlStrBuilder.append("</tr>");
+        htmlStrBuilder.append("</thead>");
+        htmlStrBuilder.append("<tbody>");
+        for (int i=0; i<docsSize; i++) {
+          Document doc = docs.get(i);
+          htmlStrBuilder.append("<tr valign=\"top\">");
+          int num = (page - 1) * pageSize + i + 1;
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + num + ". " + "</td>");
+          Fieldable authorField = doc.getFieldable("author");
+          String author = "";
+          if (authorField != null)
+            author = authorField.stringValue();
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + author + "</td>");
+          Fieldable titleField = doc.getFieldable("title");
+          String title = "";
+          if (titleField != null)
+            title = titleField.stringValue();
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + title + "</td>");
+          Fieldable publisherField = doc.getFieldable("publisher");
+          String publisher = "";
+          if (publisherField != null)
+            publisher = publisherField.stringValue();
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + publisher + "</td>");
+          Fieldable yearField = doc.getFieldable("date");
+          String year = "";
+          if (yearField != null)
+            year = yearField.stringValue();
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + year + "</td>");
+          String docId = doc.getFieldable("docId").stringValue();
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + docId + "</td>");
+          Fieldable lastModifiedField = doc.getFieldable("lastModified");
+          String lastModified = "";
+          if (lastModifiedField != null)
+            lastModified = lastModifiedField.stringValue();
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + lastModified + "</td>");
+          Fieldable languageField = doc.getFieldable("language");
+          String lang = "";
+          if (languageField != null)
+            lang = languageField.stringValue();
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\" style=\"padding-left:5px\">" + lang + "</td>");
+          Fieldable schemaNameField = doc.getFieldable("schemaName");
+          String schemaName = "";
+          if (schemaNameField != null)
+            schemaName = schemaNameField.stringValue();
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\">" + schemaName + "</td>");
+          htmlStrBuilder.append("</tr>");
+          // Link row
+          htmlStrBuilder.append("<tr valign=\"top\">");
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\"></td>");
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\" colspan=\"8\">");
+          Fieldable echoIdField = doc.getFieldable("echoId");
+          String echoId = null;
+          if (echoIdField != null)
+            echoId = echoIdField.stringValue();
+          String urlDocuView = "http://echo.mpiwg-berlin.mpg.de/ECHOdocuView?url=" + echoId;
+          if (echoId == null)
+            urlDocuView = "http://echo.mpiwg-berlin.mpg.de/";
+          htmlStrBuilder.append("<img src=\"/mpiwg-mpdl-cms-web/images/book.png\" width=\"15\" height=\"15\" border=\"0\"/>" + " <a href=\"" + urlDocuView + "\">Full view</a>");
+          htmlStrBuilder.append(", " + "<a href=\"/mpiwg-mpdl-cms-web/query/GetPage?docId=" + docId + "\">Lite view</a>");
+          htmlStrBuilder.append("</td>");
+          htmlStrBuilder.append("</tr>");
+          htmlStrBuilder.append("<tr valign=\"top\">");
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\"></td>");
+          htmlStrBuilder.append("<td align=\"left\" valign=\"top\" colspan=\"8\">");
+          htmlStrBuilder.append("<img src=\"/mpiwg-mpdl-cms-web/images/download.png\" width=\"15\" height=\"15\" border=\"0\"/>" + " Download: <a href=\"/mpiwg-mpdl-cms-web/doc/GetDocument?id=" + docId + "\">XML</a>");
+          DocumentHandler docHandler = new DocumentHandler();
+          String destFileNamePdf = docHandler.getFullFileName(docId, "pdf");
+          String destFileNameHtml = docHandler.getFullFileName(docId, "html");
+          int lastDot = docId.lastIndexOf(".");
+          String docIdWithoutExtension = docId.substring(0, lastDot);
+          File destFilePdf = new File(destFileNamePdf);
+          File destFileHtml = new File(destFileNameHtml);
+          if (destFilePdf.exists())
+            htmlStrBuilder.append(", " + "<a href=\"/mpiwg-mpdl-cms-web/doc/GetDocument?id=" + docIdWithoutExtension + ".pdf" + "\">PDF</a>");
+          if (destFileHtml.exists())
+            htmlStrBuilder.append(", " + "<a href=\"/mpiwg-mpdl-cms-web/doc/GetDocument?id=" + docIdWithoutExtension + ".html" + "\">HTML</a>");
+          htmlStrBuilder.append("</td>");
+          htmlStrBuilder.append("</tr>");
+          // hit fragments row
+          ArrayList<String> hitFragments = doc.getHitFragments();
+          if (hitFragments != null) {
+            StringBuilder hitFragmentsStrBuilder = new StringBuilder();
+            hitFragmentsStrBuilder.append("<b>Hit summary: </b>");
+            hitFragmentsStrBuilder.append("(...) ");
+            for (int j=0; j<hitFragments.size(); j++) {
+              String hitFragment = hitFragments.get(j);
+              hitFragmentsStrBuilder.append(hitFragment + " (...) ");
+            }
+            htmlStrBuilder.append("<tr valign=\"top\">");
+            htmlStrBuilder.append("<td align=\"left\" valign=\"top\"></td>");
+            htmlStrBuilder.append("<td align=\"left\" valign=\"top\" colspan=\"8\">" + hitFragmentsStrBuilder.toString() + "</td>");
+            htmlStrBuilder.append("</tr>");
+          }
+        }
+        htmlStrBuilder.append("</tbody>");
+        htmlStrBuilder.append("</table>");
+        htmlStrBuilder.append("</form>");
+        htmlStrBuilder.append("<p/>");
+        htmlStrBuilder.append("Elapsed time: " + elapsedTime + " ms");
+        htmlStrBuilder.append("</body>");
+        htmlStrBuilder.append("</html>");
+        out.print(htmlStrBuilder.toString());
+      }
+      out.close();
+    } catch (Exception e) {
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+
+  private String getBaseUrl(HttpServletRequest request) {
+    return getServerUrl(request) + request.getContextPath();
+  }
+
+  private String getServerUrl(HttpServletRequest request) {
+    if ( ( request.getServerPort() == 80 ) || ( request.getServerPort() == 443 ) )
+      return request.getScheme() + "://" + request.getServerName();
+    else
+      return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/cms/XQueryDocument.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,228 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.cms;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.util.ArrayList;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.DocumentHandler;
+import de.mpg.mpiwg.berlin.mpdl.util.StringUtils;
+import de.mpg.mpiwg.berlin.mpdl.xml.xquery.Hit;
+import de.mpg.mpiwg.berlin.mpdl.xml.xquery.Hits;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.MetadataRecord;
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.PageTransformer;
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.xml.xquery.XQueryEvaluator;
+
+public class XQueryDocument extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  private XQueryEvaluator xQueryEvaluator = null;
+  private PageTransformer pageTransformer = null;
+  
+  public XQueryDocument() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+    ServletContext context = getServletContext();
+    xQueryEvaluator = (XQueryEvaluator) context.getAttribute("xQueryEvaluator");
+    pageTransformer = (PageTransformer) context.getAttribute("pageTransformer");
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String docId = request.getParameter("docId");
+    String query = request.getParameter("query");
+    String pageStr = request.getParameter("page");
+    if (pageStr == null)
+      pageStr = "1";
+    int page = Integer.parseInt(pageStr);
+    String pageSizeStr = request.getParameter("pageSize");
+    if (pageSizeStr == null)
+      pageSizeStr = "10";
+    int pageSize = Integer.parseInt(pageSizeStr);
+    int from = (page * pageSize) - pageSize;  // e.g. 0
+    int to = page * pageSize - 1;  // e.g. 9
+    String outputFormat = request.getParameter("outputFormat");
+    if (outputFormat == null)
+      outputFormat = "xml";
+    try {
+      DocumentHandler docHandler = new DocumentHandler();
+      String docFileName = docHandler.getDocFullFileName(docId);
+      URL docFileUrl = new URL("file:" + docFileName);
+      Hits hits = null;
+      String errorStr = null;
+      try {
+        hits = xQueryEvaluator.evaluate(docFileUrl, query, from, to);
+      } catch (ApplicationException e) {
+        errorStr = e.getLocalizedMessage();
+      }
+      IndexHandler indexHandler = IndexHandler.getInstance();
+      MetadataRecord docMetadataRecord = indexHandler.getDocMetadata(docId);
+      if (outputFormat.equals("xml"))
+        response.setContentType("text/xml");
+      else if (outputFormat.equals("html"))
+        response.setContentType("text/html");
+      else 
+        response.setContentType("text/xml");
+      PrintWriter out = response.getWriter();
+      String resultStr = "";
+      if (errorStr == null) {
+        if (outputFormat.equals("xml"))
+          resultStr = createXmlString(docMetadataRecord, query, page, pageSize, hits);
+        else if (outputFormat.equals("html"))
+          resultStr = createHtmlString(docMetadataRecord, query, page, pageSize, hits, request);
+      } else {
+        resultStr = "Saxon XQuery error: " + errorStr;
+      }
+      out.print(resultStr);
+      out.close();
+    } catch (ApplicationException e) {
+      throw new ServletException(e);
+    }
+  }
+
+  private String createXmlString(MetadataRecord docMetadataRecord, String query, int page, int pageSize, Hits hits) throws ApplicationException {
+    String docId = docMetadataRecord.getDocId();
+    ArrayList<Hit> hitsArray = null;
+    if (hits != null)
+      hitsArray = hits.getHits();
+    int hitsSize = -1;
+    int hitsArraySize = -1;
+    if (hits != null)
+      hitsSize = hits.getSize();
+    if (hitsArray != null)
+      hitsArraySize = hitsArray.size();
+    StringBuilder xmlStrBuilder = new StringBuilder();
+    xmlStrBuilder.append("<document>");
+    xmlStrBuilder.append("<id>" + docId + "</id>");
+    xmlStrBuilder.append("<query>");
+    String queryXml = StringUtils.deresolveXmlEntities(query);
+    xmlStrBuilder.append("<queryText>" + queryXml + "</queryText>");
+    xmlStrBuilder.append("<resultPage>" + page + "</resultPage>");
+    xmlStrBuilder.append("<resultPageSize>" + pageSize + "</resultPageSize>");
+    xmlStrBuilder.append("</query>");
+    xmlStrBuilder.append("<hitsSize>" + hitsSize + "</hitsSize>");
+    xmlStrBuilder.append("<hits>");
+    for (int i=0; i<hitsArraySize; i++) {
+      int num = (page - 1) * pageSize + i + 1;
+      xmlStrBuilder.append("<hit n=\"" + num + "\">");
+      Hit hit = hitsArray.get(i);
+      String name = hit.getName();
+      String typeStr = "ELEMENT";
+      int type = hit.getType();
+      if (type == Hit.TYPE_ATTRIBUTE)
+        typeStr = "ATTRIBUTE";
+      else if (type == Hit.TYPE_ATOMIC_VALUE)
+        typeStr = "ATOMIV_VALUE";
+      int docPage = hit.getPage();
+      int hitPagePosition = hit.getHitPagePosition();
+      String xmlContent = hit.getContent();
+      if (name != null)
+        xmlStrBuilder.append("<name>" + name + "</name>");
+      xmlStrBuilder.append("<type>" + typeStr + "</type>");
+      if (docPage != -1) {
+        xmlStrBuilder.append("<page>" + docPage + "</page>");
+        xmlStrBuilder.append("<posInPage>" + hitPagePosition + "</posInPage>");
+      }
+      xmlStrBuilder.append("<content>" + xmlContent + "</content>");
+      xmlStrBuilder.append("</hit>");
+    }
+    xmlStrBuilder.append("</hits>");
+    xmlStrBuilder.append("</document>");
+    return xmlStrBuilder.toString();   
+  }
+  
+  private String createHtmlString(MetadataRecord docMetadataRecord, String query, int page, int pageSize, Hits hits, HttpServletRequest request) throws ApplicationException {
+    String docId = docMetadataRecord.getDocId();
+    ArrayList<Hit> hitsArray = null;
+    if (hits != null)
+      hitsArray = hits.getHits();
+    int hitsArraySize = -1;
+    if (hitsArray != null)
+      hitsArraySize = hitsArray.size();
+    int hitsSize = hits.getSize();
+    StringBuilder xmlStrBuilder = new StringBuilder();
+    xmlStrBuilder.append("<html>");
+    xmlStrBuilder.append("<head>");
+    xmlStrBuilder.append("<title>Document: \"" + query + "\"</title>");
+    String baseUrl = getBaseUrl(request);
+    String cssUrl = baseUrl + "/css/page.css";
+    xmlStrBuilder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssUrl + "\"/>");
+    xmlStrBuilder.append("</head>");
+    xmlStrBuilder.append("<body>");
+    xmlStrBuilder.append("<span class=\"about\">[<span class=\"it\">This is a MPIWG CMS technology service</span>] <a href=\"/mpiwg-mpdl-cms-web/index.html\"><img src=\"/mpiwg-mpdl-cms-web/images/info.png\" valign=\"bottom\" width=\"15\" height=\"15\" border=\"0\" alt=\"MPIWG CMS service\"/></a></span>");
+    xmlStrBuilder.append("<span class=\"query\">XQuery: " + query + "</span>");
+    xmlStrBuilder.append("<span class=\"result\">");
+    xmlStrBuilder.append("<span class=\"resultPage\">" + page + "</span>");
+    xmlStrBuilder.append("<span class=\"resultPageSize\">" + pageSize + "</span>");
+    xmlStrBuilder.append("<span class=\"hitsSize\">" + hitsSize + "</span>");
+    xmlStrBuilder.append("</span>");
+    xmlStrBuilder.append("<table>");
+    if (hitsSize == 1 && hitsArray.get(0).getType() == Hit.TYPE_ATOMIC_VALUE) {
+      Hit hit = hitsArray.get(0);
+      String xmlContent = hit.getContent();
+      xmlContent = StringUtils.deresolveXmlEntities(xmlContent);
+      xmlStrBuilder.append(xmlContent);
+    } else {
+      for (int i=0; i<hitsArraySize; i++) {
+        xmlStrBuilder.append("<tr class=\"hit\">");
+        Hit hit = hitsArray.get(i);
+        int docPage = hit.getPage();
+        String hitName = hit.getName();
+        int hitType = hit.getType();
+        int hitPagePosition = hit.getHitPagePosition();
+        String getPageLink = baseUrl + "/query/GetPage?docId=" + docId + "&page=" + docPage + "&outputFormat=" + "xmlDisplay" + "&highlightElem=" + hitName + "&highlightElemPos=" + hitPagePosition;
+        String hitPres = hitName + "[" + hitPagePosition + "]";
+        if (hitType == Hit.TYPE_ATTRIBUTE) {
+          hitPres = "@" + hitName;
+          getPageLink = baseUrl + "/query/GetPage?docId=" + docId + "&page=" + docPage;
+        }
+        String posStr = "Page " + docPage + ", " + hitPres + ":";
+        int num = (page - 1) * pageSize + i + 1;
+        xmlStrBuilder.append("<td class=\"hitNum\">" + num + ". " + "</td>");
+        xmlStrBuilder.append("<td class=\"hitLink\">");
+        if (docPage != -1) {
+          xmlStrBuilder.append("<a href=\"" + getPageLink + "\">" + posStr + "</a>");
+        }
+        xmlStrBuilder.append("</td>");
+        String xmlContent = hit.getContent();
+        String htmlContent = pageTransformer.transform(xmlContent, docMetadataRecord, -1, "xmlDisplay");  // TODO performance: do not transform each single hit but transform then all in one step
+        xmlStrBuilder.append("<td class=\"hitContent\">");
+        xmlStrBuilder.append(htmlContent);
+        xmlStrBuilder.append("</td>");
+        xmlStrBuilder.append("</tr>");
+      }
+    }
+    xmlStrBuilder.append("</table>");
+    xmlStrBuilder.append("</body>");
+    xmlStrBuilder.append("</html>");
+    return xmlStrBuilder.toString();   
+  }
+
+  private String getBaseUrl(HttpServletRequest request) {
+    return getServerUrl(request) + request.getContextPath();
+  }
+
+  private String getServerUrl(HttpServletRequest request) {
+    if ( ( request.getServerPort() == 80 ) || ( request.getServerPort() == 443 ) )
+      return request.getScheme() + "://" + request.getServerName();
+    else
+      return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetDictionaryEntries.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,485 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.lt;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.app.Lexica;
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.app.Lexicon;
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.app.LexiconEntry;
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.db.LexHandler;
+import de.mpg.mpiwg.berlin.mpdl.lt.general.Language;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Form;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Lemma;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.norm.Normalizer;
+import de.mpg.mpiwg.berlin.mpdl.servlets.util.ServletUtil;
+
+public class GetDictionaryEntries extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  private LexHandler lexHandler;
+
+  public GetDictionaryEntries() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+    try {
+      lexHandler = LexHandler.getInstance();
+    } catch (ApplicationException e) {
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    Date begin = new Date();
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String query = request.getParameter("query");
+    String queryDisplay = request.getParameter("queryDisplay");
+    String language = request.getParameter("language");
+    String inputType = request.getParameter("inputType");
+    String outputFormat = request.getParameter("outputFormat");
+    String[] outputTypesArray = request.getParameterValues("outputType");
+    String dictionary = request.getParameter("dictionary");
+    String normalization = request.getParameter("normalization");
+    String normalizationType = request.getParameter("normalizationType");
+    String resultPageNumber = request.getParameter("resultPageNumber");
+    String resultPageSize = request.getParameter("resultPageSize");
+    if (query == null) 
+      query = "a*";
+    boolean isRangeQuery = false; 
+    if (query.endsWith("*"))
+      isRangeQuery = true;
+    if (queryDisplay == null)
+      queryDisplay = query;
+    if (language == null)
+      language = "eng";
+    if (inputType == null || ! (inputType.equals("form") || inputType.equals("lemma")))
+      inputType = "form";
+    if (outputFormat == null || ! (outputFormat.equals("xml") || outputFormat.equals("html") || outputFormat.equals("htmlFragment")))
+      outputFormat = "xml";
+    ArrayList<String> outputTypes = new ArrayList<String>();
+    if (outputTypesArray == null) {
+      outputTypes.add("allCompact");
+    } else if (isRangeQuery) {
+      outputTypes.add("dictCompact");
+    } else {
+      outputTypes = new ArrayList<String>(Arrays.asList(outputTypesArray));
+    }
+    if (normalization == null || ! (normalization.equals("none") || normalization.equals("reg") || normalization.equals("reg norm")))
+      normalization = "norm";
+    if (normalizationType == null || ! (normalizationType.equals("display") || normalizationType.equals("dictionary")))
+      normalizationType = "dictionary";
+    String xmlDict = "all";
+    if (dictionary != null)
+      xmlDict = dictionary;
+    int pageNumber = 1;
+    int pageSize = 50;
+    if (resultPageNumber != null) 
+      pageNumber = new Integer(resultPageNumber);
+    if (resultPageSize != null) 
+      pageSize = new Integer(resultPageSize);
+    String xmlQueryString = "<query>";
+    xmlQueryString = xmlQueryString + "<name>" + query + "</name>";
+    xmlQueryString = xmlQueryString + "<display>" + queryDisplay + "</display>";
+    xmlQueryString = xmlQueryString + "<language>" + language + "</language>";
+    xmlQueryString = xmlQueryString + "<inputType>" + inputType + "</inputType>";
+    xmlQueryString = xmlQueryString +  "<outputFormat>" + outputFormat + "</outputFormat>";
+    xmlQueryString = xmlQueryString + "<outputTypes>" + outputTypes + "</outputTypes>";
+    xmlQueryString = xmlQueryString + "<dictionary>" + xmlDict + "</dictionary>"; 
+    xmlQueryString = xmlQueryString + "<normalization>" + normalization + "</normalization>";
+    xmlQueryString = xmlQueryString + "<normalizationType>" + normalizationType + "</normalizationType>";
+    if (isRangeQuery) {
+      xmlQueryString = xmlQueryString + "<resultPageNumber>" + pageNumber + "</resultPageNumber>";
+      xmlQueryString = xmlQueryString + "<resultPageSize>" + pageSize + "</resultPageSize>";
+    }
+    xmlQueryString = xmlQueryString + "</query>";
+    try {
+      if (outputFormat.equals("xml"))
+        response.setContentType("text/xml");
+      else if (outputFormat.equals("html") || outputFormat.equals("htmlFragment"))
+        response.setContentType("text/html");
+      else 
+        response.setContentType("text/xml");
+      PrintWriter out = response.getWriter();
+      if (query == null || query.isEmpty()) {
+        out.print("request parameter \"query\" is empty. Please specify a query.");
+        out.close();
+        return;
+      }
+      ArrayList<Lemma> lemmas = null;
+      ArrayList<Lexicon> dictionaries = null;
+      if (isRangeQuery) {
+        String queryTmp = query.substring(0, query.length() - 1); // without last star
+        if (dictionary != null)
+          dictionaries = lexHandler.getLexEntriesByLexiconBeginningWith(dictionary, queryTmp, pageNumber, pageSize);
+        else 
+          dictionaries = lexHandler.getLexEntriesBeginningWith(language, queryTmp, pageNumber, pageSize);
+      } else {
+        String lang = language;
+        if (dictionary != null) {
+          Lexicon lexicon = Lexica.getInstance().getLexicon(dictionary);
+          if (lexicon != null)
+            lang = lexicon.getSourceLanguage();
+        }
+        int normMode = Normalizer.DICTIONARY;
+        if (normalization.equals("none"))
+          normMode = Normalizer.NONE;
+        else if (normalizationType.equals("display"))
+          normMode = Normalizer.DISPLAY;
+        lemmas = lexHandler.getLemmas(query, inputType, lang, normMode, true);
+        dictionaries = lexHandler.getLexEntries(lemmas, lang, dictionary, query);
+      }
+      String baseUrl = ServletUtil.getInstance().getBaseUrl(request);
+      Date end = new Date();
+      String elapsedTime = String.valueOf(end.getTime() - begin.getTime());
+      String result = "";
+      if (outputFormat == null || outputFormat.equals("xml"))
+        result = createXmlOutputString(query, lemmas, dictionaries, outputTypes, baseUrl, xmlQueryString, elapsedTime);
+      else if (outputFormat.equals("html") || outputFormat.equals("htmlFragment"))
+        result = createHtmlOutputString(query, queryDisplay, language, lemmas, dictionaries, pageNumber, pageSize, isRangeQuery, outputFormat, outputTypes, elapsedTime);
+      else 
+        result = createXmlOutputString(query, lemmas, dictionaries, outputTypes, baseUrl, xmlQueryString, elapsedTime);
+      out.print(result);
+      out.close();
+    } catch (ApplicationException e) { 
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+  
+  private String createXmlOutputString(String query, ArrayList<Lemma> lemmas, ArrayList<Lexicon> lexicons, ArrayList<String> outputTypes, String baseUrl, String xmlQueryString, String elapsedTime) {
+    boolean outputTypeMorphCompact = false; 
+    if (outputTypes.contains("allCompact") || outputTypes.contains("morphCompact"))
+      outputTypeMorphCompact = true;
+    boolean outputTypeMorphFull = false; 
+    if (outputTypes.contains("allFull") || outputTypes.contains("morphFull"))
+      outputTypeMorphFull = true;
+    boolean outputTypeDictCompact = false; 
+    if (outputTypes.contains("allCompact") || outputTypes.contains("dictCompact"))
+      outputTypeDictCompact = true;
+    boolean outputTypeDictFull = false; 
+    if (outputTypes.contains("allFull") || outputTypes.contains("dictFull"))
+      outputTypeDictFull = true;
+    boolean outputTypeWikiCompact = false; 
+    if (outputTypes.contains("allCompact") || outputTypes.contains("wikiCompact"))
+      outputTypeWikiCompact = true;
+    boolean outputTypeWikiFull = false; 
+    if (outputTypes.contains("allFull") || outputTypes.contains("wikiFull"))
+      outputTypeWikiFull = true;
+    String result = "<result>";
+    result = result + "<provider>" + "MPIWG MPDL language technology service (see: " + "" + baseUrl + "), Max Planck Institute for the History of Science, Berlin." + "</provider>";
+    result = result + xmlQueryString;
+    result = result + "<elapsed-time-ms>" + elapsedTime + "</elapsed-time-ms>";
+    if ((outputTypeMorphCompact || outputTypeMorphFull) && lemmas != null && ! lemmas.isEmpty()) {
+      result = result + "<morphology>";
+      for (int i=0; i<lemmas.size(); i++) {
+        Lemma lemma = lemmas.get(i);
+        String lemmaName = lemma.getLemmaName();
+        String language = lemma.getLanguage();
+        result = result + "<lemma>";
+        result = result + "<name>" + lemmaName + "</name>";
+        if (outputTypeMorphFull) {
+          String lemmaProvider = lemma.getProvider();
+          result = result + "<provider>" + lemmaProvider + "</provider>";
+          result = result + "<language>" + language + "</language>";
+        }
+        if (Language.getInstance().isArabic(language) || Language.getInstance().isLatin(language)) {
+          String remoteUrl = "http://www.perseus.tufts.edu/hopper/morph?l=" + lemmaName + "&amp;la=" + language;
+          result = result + "<remoteUrl>" + remoteUrl + "</remoteUrl>";
+        } else if (Language.getInstance().isGreek(language)) {
+          String remoteUrl = "http://www.perseus.tufts.edu/hopper/morph?l=" + lemmaName + "&amp;la=" + "greek";
+          result = result + "<remoteUrl>" + remoteUrl + "</remoteUrl>";
+        }
+        if (outputTypeMorphFull) {
+          ArrayList<Form> forms = lemma.getFormsList();
+          Collections.sort(forms);
+          if (forms != null && ! forms.isEmpty()) {
+            result = result + "<forms>";
+            for (int j=0; j<forms.size(); j++) {
+              result = result + "<form>";
+              Form f = forms.get(j);
+              String formName = f.getFormName();
+              String formProvider = f.getProvider();
+              result = result + "<provider>" + formProvider + "</provider>";
+              result = result + "<language>" + language + "</language>";
+              result = result + "<name>" + formName + "</name>";
+              result = result + "</form>";
+            }
+            result = result + "</forms>";
+          }
+        }
+        result = result + "</lemma>";
+      }
+      result = result + "</morphology>";
+    }
+    if ((outputTypeDictCompact || outputTypeDictFull) && lexicons != null) {
+      result = result + "<dictionaries>";
+      for (int i=0; i<lexicons.size(); i++) {
+        Lexicon lexicon = lexicons.get(i);
+        if (outputTypeDictFull)
+          result = result + lexicon.toXmlString();
+        else if (outputTypeDictCompact)
+          result = result + lexicon.toXmlStringCompact();
+      }
+      result = result + "</dictionaries>";
+    }
+    if ((outputTypeWikiCompact || outputTypeWikiFull) && lemmas != null && ! lemmas.isEmpty()) {
+      result = result + "<wikipedia>";
+      String language = null;
+      for (int i=0; i<lemmas.size(); i++) {
+        Lemma lemma = lemmas.get(i);
+        String lemmaName = lemma.getLemmaName();
+        language = Language.getInstance().getLanguageId(lemma.getLanguage());
+        result = result + "<article>";
+        result = result + "<name>" + lemmaName + "</name>";
+        String wikiHrefExact = "http://" + language + ".wikipedia.org/wiki/" + lemmaName;
+        String wikiHrefSearch = "http://" + language + ".wikipedia.org/wiki/index.php?search=" + lemmaName;
+        result = result + "<remoteUrl>" + wikiHrefExact + "</remoteUrl>";
+        result = result + "<remoteUrlSearch>" + wikiHrefSearch + "</remoteUrlSearch>";
+        result = result + "</article>";
+      }
+      if (language != null && Language.getInstance().isGerman(language) && query != null) {
+        String[] queryFormNames = query.split(" ");
+        for (int j=0; j<queryFormNames.length; j++) {
+          String queryFormName = queryFormNames[j];          
+          result = result + "<article>";
+          result = result + "<name>" + queryFormName + "</name>";
+          String wikiHrefExact = "http://" + language + ".wikipedia.org/wiki/" + queryFormName;
+          String wikiHrefSearch = "http://" + language + ".wikipedia.org/wiki/index.php?search=" + queryFormName;
+          result = result + "<remoteUrl>" + wikiHrefExact + "</remoteUrl>";
+          result = result + "<remoteUrlSearch>" + wikiHrefSearch + "</remoteUrlSearch>";
+          result = result + "</article>";
+        }
+      }
+      result = result + "</wikipedia>";
+    }
+    result = result + "</result>";
+    return result;
+  }
+  
+  private String createHtmlOutputString(String query, String queryDisplay, String language, ArrayList<Lemma> lemmas, ArrayList<Lexicon> lexicons, int pageNumber, int pageSize, boolean isRangeQuery, String outputFormat, ArrayList<String> outputTypes, String elapsedTime) {
+    boolean outputTypeMorphCompact = false; 
+    if (outputTypes.contains("allCompact") || outputTypes.contains("morphCompact"))
+      outputTypeMorphCompact = true;
+    boolean outputTypeMorphFull = false; 
+    if (outputTypes.contains("allFull") || outputTypes.contains("morphFull"))
+      outputTypeMorphFull = true;
+    boolean outputTypeDictCompact = false; 
+    if (outputTypes.contains("allCompact") || outputTypes.contains("dictCompact"))
+      outputTypeDictCompact = true;
+    boolean outputTypeDictFull = false; 
+    if (outputTypes.contains("allFull") || outputTypes.contains("dictFull"))
+      outputTypeDictFull = true;
+    boolean outputTypeWikiCompact = false; 
+    if (outputTypes.contains("allCompact") || outputTypes.contains("wikiCompact"))
+      outputTypeWikiCompact = true;
+    boolean outputTypeWikiFull = false; 
+    if (outputTypes.contains("allFull") || outputTypes.contains("wikiFull"))
+      outputTypeWikiFull = true;
+    String result = "";
+    result = result + "<html>";
+    result = result + "<head>";
+    result = result + "<title>WordInfo for: \"" + queryDisplay + "\"</title>";
+    result = result + "<link rel=\"stylesheet\" type=\"text/css\" href=\"/mpiwg-mpdl-cms-web/css/getDictionaryEntries.css\"/>";
+    result = result + getJavascriptFunctions();
+    result = result + "</head>";
+    result = result + "<body class=\"body\">";
+    result = result + "<table align=\"right\" valign=\"top\">";
+    result = result + "<td>[<i>This is a MPIWG MPDL language technology service</i>] <a href=\"/mpiwg-mpdl-cms-web/index.html\"><img src=\"/mpiwg-mpdl-cms-web/images/info.png\" valign=\"bottom\" width=\"15\" height=\"15\" border=\"0\" alt=\"MPIWG MPDL language technology service\"/></a></td>";
+    result = result + "</table>";
+    result = result + "<p/>";
+    result = result + "<div class=\"title\">WordInfo</div>";
+    
+    result = result + "<form name=\"getDictionaryEntries\" action=\"GetDictionaryEntries\" method=\"get\">";
+    result = result + "Query: <input name=\"query\" class=\"query\" type=\"text\" size=\"20\" value=\"" + query + "\"/>";
+    String htmlSelectBox = Language.getInstance().getHtmlSelectBox(language);
+    result = result + " Language: " + htmlSelectBox;
+    result = result + "<input type=\"hidden\" name=\"outputFormat\" value=\"" + outputFormat + "\"/>";
+    for (int i=0; i<outputTypes.size(); i++) {
+      String type = outputTypes.get(i);
+      result = result + "<input type=\"hidden\" name=\"outputType\" value=\"" + type + "\"/>";
+    }
+    result = result + " <button type=\"submit\" onclick=\"var query = document.getDictionaryEntries.query.value; if(query.substring(query.length-1, query.length) == '*') {document.getDictionaryEntries.outputType.value = 'dictCompact';}\">Query</button>";
+    result = result + "</form>";
+    result = result + "<hr/>";
+
+    if ((outputTypeMorphCompact || outputTypeMorphFull) && lemmas != null && ! lemmas.isEmpty()) {
+      result = result + "<span class=\"inputType\">Morphology</span>";
+      result = result + "<span  class=\"tree\">";
+      result = result + "<ul>";
+      result = result + "<li>" + "<b>" + "Lemmata" + "</b>";
+      result = result + "<ul>";
+      for (int i=0; i<lemmas.size(); i++) {
+        Lemma lemma = lemmas.get(i);
+        String lemmaName = lemma.getLemmaName();
+        String providerText = "";
+        String externalLinkText = "";
+        String formsText = "";
+        if (outputTypeMorphFull) {
+          String lemmaProvider = lemma.getProvider();
+          providerText = " (data provider: " + lemmaProvider + ")";
+        }
+        if (Language.getInstance().isArabic(language) || Language.getInstance().isLatin(language))
+          externalLinkText = " (external link: <a href=\"http://www.perseus.tufts.edu/hopper/morph?l=" + lemmaName + "&amp;la=" + language + "\">" + lemmaName + "</a>)";
+        else if (Language.getInstance().isGreek(language))
+          externalLinkText = " (external link: <a href=\"http://www.perseus.tufts.edu/hopper/morph?l=" + lemmaName + "&amp;la=" + "greek" + "\">" + lemmaName + "</a>)";
+        ArrayList<Form> forms = lemma.getFormsList();
+        Collections.sort(forms);
+        if (forms != null && ! forms.isEmpty()) {
+          formsText = formsText + "<ul>";
+          formsText = formsText + "<b>" + "Forms: " + "</b>";
+          for (int j=0; j<forms.size(); j++) {
+            Form f = forms.get(j);
+            String formName = f.getFormName();
+            String formProvider = f.getProvider();
+            formsText = formsText + formName + " (data provider: " + formProvider + "), ";
+          }
+          formsText = formsText.substring(0, formsText.length() - 2);  // without last comma and blank
+          formsText = formsText + "</ul>";
+        }
+        if (outputTypeMorphFull) {
+          result = result + "<li><input type=\"checkbox\" checked=\"checked\"/><label>" + lemmaName + providerText + externalLinkText + "</label>" + formsText + "</li>";
+        } else if (outputTypeMorphCompact) { 
+          result = result + "<li><input type=\"checkbox\"/><label>" + "<a href=\"GetDictionaryEntries?query=" + lemmaName + "&language=" + language + "&inputType=lemma" + "&outputFormat=html" + "&outputType=morphFull" + "\">" + lemmaName + "</a>" + providerText + externalLinkText + "</label>" + formsText + "</li>";
+        }
+      }
+      result = result + "</ul>";
+      result = result + "</li>";
+      result = result + "</ul>";
+      result = result + "</span>";
+    }
+    if ((outputTypeDictCompact || outputTypeDictFull) && lexicons != null && ! lexicons.isEmpty()) {
+      if (isRangeQuery) {
+        int pageNumberUp = 1;
+        if (pageNumber > 1)
+          pageNumberUp = pageNumber - 1;
+        int pageNumberDown = pageNumber + 1;
+        int from = (pageNumber * pageSize) - pageSize + 1;
+        int to = pageNumber * pageSize;
+        result = result + "<table align=\"right\">";
+        result = result + "<tr>";
+        result = result + "<td valign=\"middle\">Page: </td>";
+        result = result + "<td valign=\"middle\"><a href=\"/mpiwg-mpdl-cms-web/lt/GetDictionaryEntries?query=" + query + "&amp;language=" + language + "&amp;resultPageNumber=" + pageNumberUp + "&amp;outputFormat=html\"><img alt=\"page up\" src=\"/mpiwg-mpdl-cms-web/images/left.gif\" height=\"20\" width=\"20\"></a></td>";
+        result = result + "<td valign=\"middle\">" + pageNumber + "</td>";
+        result = result + "<td valign=\"middle\"><a href=\"/mpiwg-mpdl-cms-web/lt/GetDictionaryEntries?query=" + query + "&amp;language=" + language + "&amp;resultPageNumber=" + pageNumberDown + "&amp;outputFormat=html\"><img alt=\"page down\" src=\"/mpiwg-mpdl-cms-web/images/right.gif\" height=\"20\" width=\"20\"></a></td>";
+        result = result + "<td valign=\"middle\">(" + from + " - " + to + ")</td>";
+        result = result + "</tr>";
+        result = result + "</table>";
+      } 
+      result = result + "<span class=\"inputType\">Dictionary</span>";
+      result = result + "<span  class=\"tree\">";
+      result = result + "<ul>";
+      for (int i=0; i<lexicons.size(); i++) {
+        Lexicon lexicon = lexicons.get(i);
+        result = result + "<li>";
+        result = result + "<b>" + lexicon.getDescription() + "</b>";
+        result = result + "<ul>";
+        ArrayList<LexiconEntry> entries = lexicon.getEntries();
+        for (int j=0; j<entries.size(); j++) {
+          String entryContent = "";
+          LexiconEntry entry = entries.get(j);
+          if (lexicon.isLocalLexicon()) {
+            if (entry.isXmlValid()) {
+              String repairedEntry = entry.getRepairedEntry();
+              repairedEntry = repairedEntry.replaceAll("<repaired-entry>", "");
+              repairedEntry = repairedEntry.replaceAll("</repaired-entry>", "");
+              entryContent = entryContent + repairedEntry;  // valid unicode content of the original entry
+            } else {
+              entryContent = entryContent + "[Remark: <i> this dictionary entry has no valid XML/HTML content in database so a text version of this entry is shown.</i>]: <br/>";
+              String originalEntry = entry.getOriginalEntry();
+              originalEntry = originalEntry.replaceAll("<original-entry>", "");
+              originalEntry = originalEntry.replaceAll("</original-entry>", "");
+              originalEntry = StringEscapeUtils.escapeXml(originalEntry); // create text version of the invalid xml content
+              entryContent = entryContent + originalEntry;  
+            }
+            if (entry.getRemoteUrl() != null) {
+              entryContent = entryContent + "<div>(external link: <a href=\"" + entry.getRemoteUrl() + "\">" + entry.getFormName() + "</a>)</div>";          
+            }
+          } else {
+            if (entry.getRemoteUrl() != null) {
+              entryContent = entryContent + "external link: <a href=\"" + entry.getRemoteUrl() + "\">" + entry.getFormName() + "</a>";          
+            }
+          }
+          String formName = entry.getFormName();
+          String dictName = lexicon.getName();
+          if (outputTypeDictFull) {
+            result = result + "<li><input type=\"checkbox\" checked=\"checked\"/><label><b>" + formName + "</b></label><ul><li>" + entryContent + "</li></ul></li>";
+          } else if (outputTypeDictCompact) {
+            result = result + "<li><input type=\"checkbox\"/><label>" + "<a href=\"GetDictionaryEntries?query=" + formName + "&language=" + language + "&dictionary=" + dictName + "&inputType=lemma" + "&outputFormat=html" + "&outputType=dictFull" + "\">" + formName + "</a>" + "</label><ul><li>" + entryContent + "</li></ul></li>";
+          }
+        }
+        result = result + "</ul>";
+        result = result + "</li>";  // lexicon entry
+      }
+      result = result + "</ul>";
+      result = result + "</span>";
+    }
+    if ((outputTypeWikiCompact || outputTypeWikiFull) && lemmas != null && ! lemmas.isEmpty()) {
+      String langId = Language.getInstance().getLanguageId(language);
+      String wikiUrl = langId + ".wikipedia.org";
+      result = result + "<span class=\"inputType\">Wikipedia</span>";
+      result = result + "<span  class=\"tree\">";
+      result = result + "<ul>";
+      result = result + "<li>" + "<b>" + wikiUrl + "</b>";
+      result = result + "<ul>";
+      for (int i=0; i<lemmas.size(); i++) {
+        Lemma lemma = lemmas.get(i);
+        String lemmaName = lemma.getLemmaName();
+        String wikiHrefExact = "http://" + wikiUrl + "/wiki/" + lemmaName;
+        String wikiHrefSearch = "http://" + wikiUrl + "/wiki/index.php?search=" + lemmaName;
+        result = result + "<li><input type=\"checkbox\" checked=\"checked\"/><label>" + "External link: <a href=\"" + wikiHrefExact + "\">" + lemmaName + "</a> (or search for <a href=\"" + wikiHrefSearch + "\">" + lemmaName + "</a>)" + "</label>" + "</li>";
+      }
+      if (language != null && Language.getInstance().isGerman(language) && query != null) {
+        String[] queryFormNames = query.split(" ");
+        for (int j=0; j<queryFormNames.length; j++) {
+          String queryFormName = queryFormNames[j];          
+          result = result + "<li>";
+          String wikiHrefExact = "http://" + wikiUrl + "/wiki/" + queryFormName;
+          String wikiHrefSearch = "http://" + wikiUrl + "/wiki/index.php?search=" + queryFormName;
+          result = result + "<li><input type=\"checkbox\" checked=\"checked\"/><label>" + "External link: <a href=\"" + wikiHrefExact + "\">" + queryFormName + "</a> (or search for <a href=\"" + wikiHrefSearch + "\">" + queryFormName + "</a>)" + "</label>" + "</li>";
+          result = result + "</li>";
+        }
+      }
+      result = result + "</ul>";
+      result = result + "</li>";
+      result = result + "</ul>";
+      result = result + "</span>";
+    }
+    result = result + "<p/>";
+    result = result + "[* external links may not function]";
+    result = result + "<hr/>";
+    result = result + "<p/>";
+    result = result + "Elapsed time: " + elapsedTime + " ms, see the <a href=\"/mpiwg-mpdl-cms-web/index.html\">service description</a> of this page, if you find a bug <a href=\"https://it-dev.mpiwg-berlin.mpg.de/tracs/mpdl-project-software/newticket\">let us know</a>";
+    result = result + "</body>";
+    result = result + "</html>";
+    return result;
+  }
+
+  private String getJavascriptFunctions() {
+    String result = "<script type=\"text/javascript\">";
+    result = result + "<!-- ";
+    result = result + "function strEndsWith(str, suffix) {";
+    result = result + "  return str.match(suffix + \"$\") == suffix;";
+    result = result + "}";
+    result = result + " -->";
+    result = result + "</script>";
+    return result;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetForms.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,214 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.lt;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Hashtable;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.db.LexHandler;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Form;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Lemma;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.norm.Normalizer;
+
+public class GetForms extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  private LexHandler lexHandler;
+
+  public GetForms() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+    try {
+      lexHandler = LexHandler.getInstance();
+    } catch (ApplicationException e) {
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    Date begin = new Date();
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String query = request.getParameter("query");
+    String language = request.getParameter("language");
+    String outputFormat = request.getParameter("outputFormat");
+    String outputType = request.getParameter("outputType");
+    String normalization = request.getParameter("normalization");
+    if (language == null)
+      language = "eng";
+    if (outputFormat == null || ! (outputFormat.equals("xml") || outputFormat.equals("html") || outputFormat.equals("string")))
+      outputFormat = "xml";
+    if (outputType == null || ! (outputType.equals("compact") || outputType.equals("full")))
+      outputType = "compact";
+    if (normalization == null || ! (normalization.equals("none") || normalization.equals("reg") || normalization.equals("reg norm")))
+      normalization = "norm";
+    int normalizationType = Normalizer.DICTIONARY;
+    if (normalization != null && normalization.equals("none"))
+      normalizationType = Normalizer.NONE;
+
+    String xmlQueryString = "<query><name>" + query + "</name>" + "<language>" + language + "</language>" +  
+      "<outputFormat>" + outputFormat + "</outputFormat>" + "<outputType>" + outputType + "</outputType>" + "<normalization>" + normalization + "</normalization>" + "</query>";
+    try {
+      if (outputFormat.equals("xml"))
+        response.setContentType("text/xml");
+      else if (outputFormat.equals("html") || outputFormat.equals("string"))
+        response.setContentType("text/html");
+      else 
+        response.setContentType("text/xml");
+      PrintWriter out = response.getWriter();
+      if (query == null || query.isEmpty()) {
+        out.print("request parameter query is empty. Please specify a query.");
+        out.close();
+        return;
+      }
+      ArrayList<Lemma> lemmas = lexHandler.getLemmas(query, "lemma", language, normalizationType, true);
+      Hashtable<String, Form> formsHashtable = new Hashtable<String, Form>();
+      ArrayList<Form> forms = new ArrayList<Form>();
+      if (lemmas != null && ! lemmas.isEmpty()) {
+        for (int i=0; i<lemmas.size(); i++) {
+          Lemma lemma = lemmas.get(i);
+          ArrayList<Form> lemmaForms = lemma.getFormsList();
+          for (int j=0; j < lemmaForms.size(); j++) {
+            Form form = lemmaForms.get(j);
+            formsHashtable.put(form.getFormName(), form);
+          }
+        }
+      }
+      forms.addAll(formsHashtable.values());
+      Collections.sort(forms);
+      String baseUrl = getBaseUrl(request);
+      Date end = new Date();
+      String elapsedTime = String.valueOf(end.getTime() - begin.getTime());
+      String result = "";
+      if (outputFormat == null || outputFormat.equals("xml"))
+        result = createXmlOutputString(query, forms, outputType, baseUrl, xmlQueryString, elapsedTime);
+      else if (outputFormat.equals("html"))
+        result = createHtmlOutputString(query, forms, outputType, elapsedTime);
+      else if (outputFormat.equals("string"))
+        result = createStringOutputString(forms);
+      else 
+        result = createXmlOutputString(query, forms, outputType, baseUrl, xmlQueryString, elapsedTime);
+      out.print(result);
+      out.close();
+    } catch (ApplicationException e) { 
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+  
+  private String getBaseUrl( HttpServletRequest request ) {
+    if (request.getServerPort() == 80 || request.getServerPort() == 443)
+      return request.getScheme() + "://" + request.getServerName() + request.getContextPath();
+    else
+      return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
+  }
+
+  
+  private String createXmlOutputString(String query, ArrayList<Form> forms, String outputType, String baseUrl, String xmlQueryString, String elapsedTime) {
+    String result = "<result>";
+    result = result + "<provider>" + "MPIWG MPDL language technology service (see: " + "" + baseUrl + "), Max Planck Institute for the History of Science, Berlin." + "</provider>";
+    result = result + xmlQueryString;
+    result = result + "<elapsed-time-ms>" + elapsedTime + "</elapsed-time-ms>";
+    if (forms != null && ! forms.isEmpty()) {
+      result = result + "<morphology>";
+      result = result + "<forms>";
+      for (int i=0; i<forms.size(); i++) {
+        result = result + "<form>";
+        Form f = forms.get(i);
+        String formName = f.getFormName();
+        String language = f.getLanguage();
+        String formProvider = f.getProvider();
+        String lemmaName = f.getLemmaName();
+        result = result + "<provider>" + formProvider + "</provider>";
+        result = result + "<language>" + language + "</language>";
+        result = result + "<lemmaName>" + lemmaName + "</lemmaName>";
+        result = result + "<formName>" + formName + "</formName>";
+        result = result + "</form>";
+      }
+      result = result + "</forms>";
+      result = result + "</morphology>";
+    }
+    result = result + "</result>";
+    return result;
+  }
+  
+  private String createHtmlOutputString(String query, ArrayList<Form> forms, String outputType, String elapsedTime) {
+    String result = "";
+    result = result + "<html>";
+    result = result + "<head>";
+    result = result + "<title>Lemmas for: \"" + query + "\"</title>";
+    result = result + "</head>";
+    result = result + "<body>";
+    result = result + "<table align=\"right\" valign=\"top\">";
+    result = result + "<td>[<i>This is a MPIWG MPDL language technology service</i>] <a href=\"/mpiwg-mpdl-lt-web/index.html\"><img src=\"/mpiwg-mpdl-lt-web/images/info.png\" valign=\"bottom\" width=\"15\" height=\"15\" border=\"0\" alt=\"MPIWG MPDL language technology service\"/></a></td>";
+    result = result + "</table>";
+    result = result + "<p/>";
+    result = result + "<h1>Forms for: \"" + query + "\"</h1>";
+    if (forms != null && ! forms.isEmpty()) {
+      result = result + "<h3>Morphology</h3>";
+      result = result + "<ul>";
+      result = result + "<p/>";
+      if (outputType != null && outputType.equals("full")) {
+        for (int i=0; i<forms.size(); i++) {
+          result = result + "<li>";
+          Form f = forms.get(i);
+          String formName = f.getFormName();
+          String formProvider = f.getProvider();
+          String language = f.getLanguage();
+          String lemmaName = f.getLemmaName();
+          result = result + formName + " (data provider: " + formProvider + ", language: " + language + ", lemmaName: " + lemmaName + ")";
+          result = result + "</li>";
+        }
+      } else if (outputType == null || outputType.equals("compact")) {
+        result = result + "<li>";
+        for (int i=0; i<forms.size(); i++) {
+          Form f = forms.get(i);
+          String formName = f.getFormName();
+          result = result + formName + ", ";
+        }
+        result = result.substring(0, result.length() - 2);  // without last comma and blank
+        result = result + "</li>";
+      } else if (outputType.equals("string")) {
+        for (int i=0; i<forms.size(); i++) {
+          Form f = forms.get(i);
+          String formName = f.getFormName();
+          result = result + formName + " ";
+        }
+        result = result.substring(0, result.length() - 1);  // without last blank
+      }
+    }
+    result = result + "<hr/>";
+    result = result + "<p/>";
+    result = result + "Elapsed time: " + elapsedTime + " ms, see the <a href=\"/mpiwg-mpdl-lt-web/index.html\">service description</a> of this page, if you find a bug <a href=\"https://it-dev.mpiwg-berlin.mpg.de/tracs/mpdl-project-software/newticket\">let us know</a>";
+    result = result + "</body>";
+    result = result + "</html>";
+    return result;
+  }
+
+  private String createStringOutputString(ArrayList<Form> forms) {
+    String result = "";
+    for (int i=0; i<forms.size(); i++) {
+      Form f = forms.get(i);
+      String formName = f.getFormName();
+      result = result + formName + " ";
+    }
+    result = result.substring(0, result.length() - 1);  // without last blank
+    return result;
+  }
+    
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetLemmas.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,231 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.lt;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.db.LexHandler;
+import de.mpg.mpiwg.berlin.mpdl.lt.general.Language;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Form;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Lemma;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.norm.Normalizer;
+
+public class GetLemmas extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  private LexHandler lexHandler;
+
+  public GetLemmas() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+    try {
+      lexHandler = LexHandler.getInstance();
+    } catch (ApplicationException e) {
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    Date begin = new Date();
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String query = request.getParameter("query");
+    String language = request.getParameter("language");
+    String inputType = request.getParameter("inputType");
+    String outputFormat = request.getParameter("outputFormat");
+    String outputType = request.getParameter("outputType");
+    String normalization = request.getParameter("normalization");
+    if (language == null)
+      language = "eng";
+    if (inputType == null || ! (inputType.equals("form") || inputType.equals("lemma")))
+      inputType = "form";
+    if (outputFormat == null || ! (outputFormat.equals("xml") || outputFormat.equals("html") || outputFormat.equals("string")))
+      outputFormat = "xml";
+    if (outputType == null || ! (outputType.equals("compact") || outputType.equals("full")))
+      outputType = "compact";
+    if (normalization == null || ! (normalization.equals("none") || normalization.equals("reg") || normalization.equals("reg norm")))
+      normalization = "norm";
+    int normalizationType = Normalizer.DICTIONARY;
+    if (normalization != null && normalization.equals("none"))
+      normalizationType = Normalizer.NONE;
+
+    String xmlQueryString = "<query><name>" + query + "</name>" + "<language>" + language + "</language>" + "<inputType>" + inputType + "</inputType>" + 
+      "<outputFormat>" + outputFormat + "</outputFormat>" + "<outputType>" + outputType + "</outputType>" + "<normalization>" + normalization + "</normalization>" + "</query>";
+    try {
+      if (outputFormat.equals("xml"))
+        response.setContentType("text/xml");
+      else if (outputFormat.equals("html") || outputFormat.equals("string"))
+        response.setContentType("text/html");
+      else 
+        response.setContentType("text/xml");
+      PrintWriter out = response.getWriter();
+      if (query == null || query.isEmpty()) {
+        out.print("request parameter query is empty. Please specify a query.");
+        out.close();
+        return;
+      }
+      ArrayList<Lemma> lemmas = lexHandler.getLemmas(query, inputType, language, normalizationType, true);
+      String baseUrl = getBaseUrl(request);
+      Date end = new Date();
+      String elapsedTime = String.valueOf(end.getTime() - begin.getTime());
+      String result = "";
+      if (outputFormat == null || outputFormat.equals("xml"))
+        result = createXmlOutputString(query, lemmas, outputType, baseUrl, xmlQueryString, elapsedTime);
+      else if (outputFormat.equals("html"))
+        result = createHtmlOutputString(query, lemmas, outputType, elapsedTime);
+      else if (outputFormat.equals("string"))
+        result = createStringOutputString(lemmas);
+      else 
+        result = createXmlOutputString(query, lemmas, outputType, baseUrl, xmlQueryString, elapsedTime);
+      out.print(result);
+      out.close();
+    } catch (ApplicationException e) { 
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+  
+  private String getBaseUrl( HttpServletRequest request ) {
+    if (request.getServerPort() == 80 || request.getServerPort() == 443)
+      return request.getScheme() + "://" + request.getServerName() + request.getContextPath();
+    else
+      return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
+  }
+
+  
+  private String createXmlOutputString(String query, ArrayList<Lemma> lemmas, String outputType, String baseUrl, String xmlQueryString, String elapsedTime) {
+    String result = "<result>";
+    result = result + "<provider>" + "MPIWG MPDL language technology service (see: " + "" + baseUrl + "), Max Planck Institute for the History of Science, Berlin." + "</provider>";
+    result = result + xmlQueryString;
+    result = result + "<elapsed-time-ms>" + elapsedTime + "</elapsed-time-ms>";
+    if (lemmas != null && ! lemmas.isEmpty()) {
+      result = result + "<morphology>";
+      for (int i=0; i<lemmas.size(); i++) {
+        Lemma lemma = lemmas.get(i);
+        String lemmaName = lemma.getLemmaName();
+        String language = lemma.getLanguage();
+        result = result + "<lemma>";
+        result = result + "<name>" + lemmaName + "</name>";
+        if (outputType != null && outputType.equals("full")) {
+          String lemmaProvider = lemma.getProvider();
+          result = result + "<provider>" + lemmaProvider + "</provider>";
+          result = result + "<language>" + language + "</language>";
+        }
+        if (Language.getInstance().isArabic(language) || Language.getInstance().isLatin(language)) {
+          String remoteUrl = "http://www.perseus.tufts.edu/hopper/morph?l=" + lemmaName + "&amp;la=" + language;
+          result = result + "<remoteUrl>" + remoteUrl + "</remoteUrl>";
+        } else if (Language.getInstance().isGreek(language)) {
+          String remoteUrl = "http://www.perseus.tufts.edu/hopper/morph?l=" + lemmaName + "&amp;la=" + "greek";
+          result = result + "<remoteUrl>" + remoteUrl + "</remoteUrl>";
+        }
+        if (outputType != null && outputType.equals("full")) {
+          ArrayList<Form> forms = lemma.getFormsList();
+          Collections.sort(forms);
+          if (forms != null && ! forms.isEmpty()) {
+            result = result + "<forms>";
+            for (int j=0; j<forms.size(); j++) {
+              result = result + "<form>";
+              Form f = forms.get(j);
+              String formName = f.getFormName();
+              String formProvider = f.getProvider();
+              result = result + "<provider>" + formProvider + "</provider>";
+              result = result + "<language>" + language + "</language>";
+              result = result + "<name>" + formName + "</name>";
+              result = result + "</form>";
+            }
+            result = result + "</forms>";
+          }
+        }
+        result = result + "</lemma>";
+      }
+      result = result + "</morphology>";
+    }
+    result = result + "</result>";
+    return result;
+  }
+  
+  private String createHtmlOutputString(String query, ArrayList<Lemma> lemmas, String outputType, String elapsedTime) {
+    String result = "";
+    result = result + "<html>";
+    result = result + "<head>";
+    result = result + "<title>Lemmas for: \"" + query + "\"</title>";
+    result = result + "</head>";
+    result = result + "<body>";
+    result = result + "<table align=\"right\" valign=\"top\">";
+    result = result + "<td>[<i>This is a MPIWG language technology service</i>] <a href=\"/mpiwg-mpdl-cms-web/lt-services.html\"><img src=\"/mpiwg-mpdl-cms-web/images/info.png\" valign=\"bottom\" width=\"15\" height=\"15\" border=\"0\" alt=\"MPIWG language technology service\"/></a></td>";
+    result = result + "</table>";
+    result = result + "<p/>";
+    result = result + "<h1>Lemmas for: \"" + query + "\"</h1>";
+    if (lemmas != null && ! lemmas.isEmpty()) {
+      result = result + "<h3>Morphology</h3>";
+      result = result + "<ul>";
+      result = result + "<p/>";
+      for (int i=0; i<lemmas.size(); i++) {
+        Lemma lemma = lemmas.get(i);
+        String lemmaName = lemma.getLemmaName();
+        String language = lemma.getLanguage();
+        result = result + "<li>";
+        result = result + lemmaName;
+        if (outputType != null && outputType.equals("full")) {
+          String lemmaProvider = lemma.getProvider();
+          result = result + " (data provider: " + lemmaProvider + ")";
+        }
+        if (Language.getInstance().isArabic(language) || Language.getInstance().isLatin(language))
+          result = result + " (external link: <a href=\"http://www.perseus.tufts.edu/hopper/morph?l=" + lemmaName + "&amp;la=" + language + "\">" + lemmaName + "</a>)";
+        else if (Language.getInstance().isGreek(language))
+          result = result + " (external link: <a href=\"http://www.perseus.tufts.edu/hopper/morph?l=" + lemmaName + "&amp;la=" + "greek" + "\">" + lemmaName + "</a>)";
+        if (outputType != null && outputType.equals("full")) {
+          ArrayList<Form> forms = lemma.getFormsList();
+          Collections.sort(forms);
+          if (forms != null && ! forms.isEmpty()) {
+            result = result + "<ul>";
+            for (int j=0; j<forms.size(); j++) {
+              Form f = forms.get(j);
+              String formName = f.getFormName();
+              String formProvider = f.getProvider();
+              result = result + formName + " (data provider: " + formProvider + "), ";
+            }
+            result = result.substring(0, result.length() - 2);  // without last comma and blank
+            result = result + "</ul>";
+          }
+        }
+        result = result + "</li>";
+      }
+      result = result + "</ul>";
+    }
+    result = result + "[* external links may not function]";
+    result = result + "<hr/>";
+    result = result + "<p/>";
+    result = result + "Elapsed time: " + elapsedTime + " ms, see the <a href=\"/mpiwg-mpdl-lt-web/index.html\">service description</a> of this page, if you find a bug <a href=\"https://it-dev.mpiwg-berlin.mpg.de/tracs/mpdl-project-software/newticket\">let us know</a>";
+    result = result + "</body>";
+    result = result + "</html>";
+    return result;
+  }
+
+  private String createStringOutputString(ArrayList<Lemma> lemmas) {
+    String result = "";
+    for (int i=0; i<lemmas.size(); i++) {
+      Lemma l = lemmas.get(i);
+      String lemmaName = l.getLemmaName();
+      result = result + lemmaName + " ";
+    }
+    result = result.substring(0, result.length() - 1);  // without last blank
+    return result;
+  }
+    
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/MpiwgMpdlLtWebServletContextListener.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,43 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.lt;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.db.LexHandler;
+import de.mpg.mpiwg.berlin.mpdl.lt.general.Constants;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.MorphologyCache;
+
+public class MpiwgMpdlLtWebServletContextListener implements ServletContextListener {
+  private ServletContext context = null;
+  
+  public void contextInitialized(ServletContextEvent event) {
+    try {
+      /*
+      this.context = event.getServletContext();
+      // String dataDirectory = System.getProperty("catalina.base") + "/webapps/mpiwg-mpdl-lt-web/WEB-INF/data";
+      String dataDirectory = Constants.getInstance().getDataDir();
+      context.setAttribute("dataDirectory", dataDirectory);
+      System.out.println(MpiwgMpdlLtWebServletContextListener.class.getName() + ": contextInitialized (data directory= \"" + dataDirectory + "\", set in constants.properties)");
+      MorphologyCache.getInstance();
+      LexHandler.getInstance();
+      */
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  public void contextDestroyed(ServletContextEvent event) {
+    try {
+      /*
+      this.context = null;
+      LexHandler.getInstance().end();
+      MorphologyCache.getInstance().end();
+      String dataDirectory = Constants.getInstance().getDataDir();
+      System.out.println(MpiwgMpdlLtWebServletContextListener.class.getName() + ": contextDestroyed (databases in directory: \"" + dataDirectory + "\" are closed)");
+      */
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Normalize.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,68 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.lt;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.norm.Normalizer;
+
+public class Normalize extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+
+  public Normalize() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String inputString = request.getParameter("inputString");
+    String language = request.getParameter("language");
+    String method = request.getParameter("method");
+    String typeStr = request.getParameter("type");
+    if (language == null)
+      language = "eng";
+    if (method == null)
+      method = "norm";
+    String[] methods = method.split(" ");
+    if (typeStr == null)
+      typeStr = "display";
+    int type = Normalizer.DISPLAY;
+    if (typeStr.equals("dictionary"))
+      type = Normalizer.DICTIONARY;
+    else if (typeStr.equals("search"))
+      type = Normalizer.SEARCH;
+    String result = null;
+    try {
+      response.setContentType("text/html");
+      PrintWriter out = response.getWriter();
+      if (inputString == null || inputString.isEmpty()) {
+        out.print("request parameter \"inputString\" is empty. Please specify \"inputString\"");
+        out.close();
+        return;
+      }
+      Normalizer normalizer = new Normalizer(methods, language);
+      normalizer.setNormMode(type);
+      result = normalizer.normalize(inputString);
+      if (result != null)
+        out.print(result);
+      out.close();
+    } catch (ApplicationException e) { 
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Tokenize.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,212 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.lt;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.IOUtils;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.app.Lexicon;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.Token;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.Tokenizer;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.XmlTokenizer;
+
+public class Tokenize extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+
+  public Tokenize() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String inputString = request.getParameter("inputString");
+    String srcUrlStr = request.getParameter("srcUrl");
+    String language = request.getParameter("language");
+    String normalization = request.getParameter("normalization");
+    String stopElements = request.getParameter("stopElements");
+    String elements = request.getParameter("elements");
+    String highlightTerms = request.getParameter("highlightTerms");
+    String outputFormat = request.getParameter("outputFormat");
+    String outputOptionsStr = request.getParameter("outputOptions");
+    if (language == null)
+      language = "eng";
+    if (normalization == null)
+      normalization = "norm";
+    String[] normFunctions = normalization.split(" ");
+    String[] stopElementsArray = null;
+    if (stopElements != null && ! stopElements.equals(""))
+      stopElementsArray = stopElements.split(" ");
+    String[] elementsArray = null;
+    if (elements != null && ! elements.equals(""))
+      elementsArray = elements.split(" ");
+    if (highlightTerms == null)
+      highlightTerms = "";
+    String[] highlightTermsArray = highlightTerms.split(" ");
+    if (outputFormat == null)
+      outputFormat = "xml";
+    if (outputOptionsStr == null)
+      outputOptionsStr = "";
+    String[] outputOptions = outputOptionsStr.split(" ");
+    String result = null;
+    try {
+      if (outputFormat.equals("xml")) {
+        response.setContentType("text/xml");
+      } else if (outputFormat.equals("string")) {
+        response.setContentType("text/html");
+      } else { 
+        response.setContentType("text/xml");
+      }
+      response.setCharacterEncoding("utf-8");
+      PrintWriter out = response.getWriter();
+      String inputText = null;  // contains string or xml text
+      if ((inputString == null || inputString.isEmpty()) && (srcUrlStr == null || srcUrlStr.isEmpty())) {
+        out.print("request parameter \"inputString\" or  \"srcUrl\" is empty. Please specify \"inputString\"");
+        out.close();
+        return;
+      } else {
+        if (srcUrlStr != null && ! srcUrlStr.isEmpty()) {
+          URL srcUrl = new URL(srcUrlStr);
+          InputStream inputStream = srcUrl.openStream();
+          BufferedInputStream in = new BufferedInputStream(inputStream);
+          inputText = IOUtils.toString(in, "utf-8");
+          in.close();
+        } else if (inputString != null && ! inputString.isEmpty()) {
+          inputText = inputString;
+        }
+      }
+      inputText = inputText.trim();
+      // Tokenize
+      boolean inputTextIsXml = false;
+      if (inputText != null && inputText.startsWith("<")  && inputText.endsWith(">"))  // TODO check properly for xml type of the inputText
+        inputTextIsXml = true;
+      if (! inputTextIsXml) {
+        inputText = "<result>" + inputText + "</result>";
+      }
+      StringReader xmlInputStringReader = new StringReader(inputText);
+      XmlTokenizer xmlTokenizer = new XmlTokenizer(xmlInputStringReader);
+      xmlTokenizer.setDocIdentifier(srcUrlStr);  // TODO
+      xmlTokenizer.setLanguage(language);
+      xmlTokenizer.setNormFunctions(normFunctions);
+      xmlTokenizer.setOutputFormat(outputFormat);
+      xmlTokenizer.setOutputOptions(outputOptions);
+      if (stopElementsArray != null && stopElementsArray.length > 0)
+        xmlTokenizer.setStopElements(stopElementsArray);
+      if (elementsArray != null && elementsArray.length > 0)
+        xmlTokenizer.setElements(elementsArray);
+      if (highlightTermsArray != null && highlightTermsArray.length > 0)
+        xmlTokenizer.setHighlightTerms(highlightTermsArray);
+      xmlTokenizer.tokenize();
+      if (outputFormat != null && outputFormat.equals("xml")) {  
+        result = xmlTokenizer.getXmlResult();
+      } else {  // outputFormat == string
+        result = xmlTokenizer.getStringResult();
+      }
+      if (result != null)
+        out.print(result);
+      out.close();
+    } catch (ApplicationException e) { 
+      throw new ServletException(e);
+    }
+  }
+
+  private ArrayList<String> getToken(String inputString, String language, String[] normFunctions) throws ApplicationException {
+    ArrayList<String> retTokens = null;
+    try {
+      StringReader reader = new StringReader(inputString);
+      Tokenizer tokenizer = new Tokenizer(reader);
+      tokenizer.setLanguage(language);
+      tokenizer.setNormFunctions(normFunctions);
+      ArrayList<Token> tokens = tokenizer.getTokens();
+      if (tokens != null) {
+        retTokens = new ArrayList<String>();
+        for (int i=0; i<tokens.size(); i++) {
+          Token t = tokens.get(i);
+          String tokenStr = t.getContentOrig();
+          if (useNormFunction(normFunctions))
+            tokenStr = t.getContentNorm();
+          retTokens.add(tokenStr);
+        }
+      }
+      tokenizer.end();
+      tokenizer.close();
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+    return retTokens;
+  }
+
+  private String createXmlOutputString(ArrayList<String> tokens, Hashtable<String, ArrayList<Lexicon>> tokensDictionaries, String baseUrl, String elapsedTime) {
+    StringBuilder result = new StringBuilder();
+    result.append("<result>");
+    result.append("<provider>" + "MPIWG MPDL language technology service (see: " + "" + baseUrl + "), Max Planck Institute for the History of Science, Berlin." + "</provider>");
+    result.append("<elapsed-time-ms>" + elapsedTime + "</elapsed-time-ms>");
+    if (tokens != null && ! tokens.isEmpty()) {
+      result.append("<tokens>");
+      for (int i=0; i<tokens.size(); i++) {
+        String token = tokens.get(i);
+        result.append("<token>");
+        result.append("<name>" + token + "</name>");
+        if (tokensDictionaries != null && ! tokensDictionaries.isEmpty()) {
+          ArrayList<Lexicon> tokenDictionaries = tokensDictionaries.get(token);
+          if (tokenDictionaries != null) {
+            result.append("<dictionaries>");
+            for (int j=0; j<tokenDictionaries.size(); j++) {
+              Lexicon lexicon = tokenDictionaries.get(j);
+              result.append(lexicon.toXmlString());
+            }
+            result.append("</dictionaries>");
+          }
+        }
+        result.append("</token>");
+      }
+      result.append("</tokens>");
+    }
+    result.append("</result>");
+    return result.toString();
+  }  
+  
+  private String createStringOutputString(ArrayList<String> tokens) {
+    StringBuilder result = new StringBuilder();
+    if (tokens != null && ! tokens.isEmpty()) {
+      for (int i=0; i<tokens.size(); i++) {
+        String token = tokens.get(i);
+        result.append(token + " ");
+      }
+      result.setLength(result.length() - 1); // without last blank
+    }
+    return result.toString();
+  }  
+
+  private boolean useNormFunction(String[] normFunctions) {
+    boolean useNorm = false;
+    for (int i=0; i< normFunctions.length; i++) {
+      String function = normFunctions[i];
+      if (function.equals("norm"))
+        return true;
+    }
+    return useNorm;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/Transcode.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,77 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.lt;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.transcode.Transcoder;
+
+public class Transcode extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+  private Transcoder transcoder;
+
+  public Transcode() {
+    super();
+  }
+
+  public void init(ServletConfig config) throws ServletException  {
+    super.init(config);
+    transcoder = Transcoder.getInstance();
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    request.setCharacterEncoding("utf-8");
+    response.setCharacterEncoding("utf-8");
+    String inputString = request.getParameter("inputString");
+    String srcEncoding = request.getParameter("srcEncoding");
+    String destEncoding = request.getParameter("destEncoding");
+    if (destEncoding == null)
+      destEncoding = "unicode";
+    String result = null;
+    try {
+      response.setContentType("text/html");
+      PrintWriter out = response.getWriter();
+      if (inputString == null || inputString.isEmpty()) {
+        out.print("request parameter \"inputString\" is empty. Please specify \"inputString\"");
+        out.close();
+        return;
+      }
+      if (srcEncoding == null || srcEncoding.isEmpty()) {
+        out.print("request parameter \"srcEncoding\" is empty. Please specify \"srcEncoding\"");
+        out.close();
+        return;
+      }
+      if (destEncoding == null || destEncoding.isEmpty()) {
+        out.print("request parameter \"destEncoding\" is empty. Please specify \"destEncoding\"");
+        out.close();
+        return;
+      }
+      if (srcEncoding.equals("buckwalter") && destEncoding.equals("unicode")) {
+        result = transcoder.transcodeFromBuckwalter2Unicode(inputString);
+      } else if (srcEncoding.equals("betacode") && destEncoding.equals("unicode")) {
+        result = transcoder.transcodeFromBetaCode2Unicode(inputString);
+      } else if (srcEncoding.equals("unicode") && destEncoding.equals("betacode")) {
+        result = transcoder.transcodeFromUnicode2BetaCode(inputString);
+      } else if (srcEncoding.equals("unicode") && destEncoding.equals("buckwalter")) {
+        result = transcoder.transcodeFromUnicode2Buckwalter(inputString);
+      } else {
+        result = "your combination of \"srcEncoding\" and \"destEncoding\" is not yet supported";
+      }
+      if (result != null)
+        out.print(result);
+      out.close();
+    } catch (ApplicationException e) { 
+      throw new ServletException(e);
+    }
+  }
+
+  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+    doGet(request, response);
+  }  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/util/ServletUtil.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,27 @@
+package de.mpg.mpiwg.berlin.mpdl.servlets.util;
+
+import javax.servlet.http.HttpServletRequest;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+public class ServletUtil {
+  private static ServletUtil instance;
+
+  public static ServletUtil getInstance() throws ApplicationException {
+    if (instance == null) {
+      instance = new ServletUtil();
+    }
+    return instance;
+  }
+
+  public ServletUtil() {
+  }
+
+  public String getBaseUrl( HttpServletRequest request ) {
+    if (request.getServerPort() == 80 || request.getServerPort() == 443)
+      return request.getScheme() + "://" + request.getServerName() + request.getContextPath();
+    else
+      return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
+  }
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/.classpath	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/mpiwg-mpdl-xml"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/mpiwg-mpdl-lt"/>
+	<classpathentry kind="lib" path="lib/lucene-core-3.5.0.jar" sourcepath="lib/lucene-core-3.5.0-sources.jar">
+		<attributes>
+			<attribute name="javadoc_location" value="jar:platform:/resource/mpiwg-mpdl-cms/lib/lucene-core-3.5.0-javadoc.jar!/"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="lib" path="lib/quartz-1.6.5.jar"/>
+	<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
+	<classpathentry kind="lib" path="lib/commons-io-2.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/commons-lang3-3.0.1.jar"/>
+	<classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/>
+	<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
+	<classpathentry kind="lib" path="lib/saxon9-s9api.jar"/>
+	<classpathentry kind="lib" path="lib/saxon9.jar"/>
+	<classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
+	<classpathentry kind="lib" path="lib/lucene-queries-3.5.0.jar"/>
+	<classpathentry kind="lib" path="lib/httpclient-4.1.2.jar"/>
+	<classpathentry kind="lib" path="lib/httpcore-4.1.2.jar"/>
+	<classpathentry kind="lib" path="lib/json_simple-1.1.jar"/>
+	<classpathentry kind="lib" path="lib/microsoft-translator-java-api-0.4.jar"/>
+	<classpathentry kind="lib" path="lib/lucene-highlighter-3.5.0.jar" sourcepath="lib/lucene-highlighter-3.5.0-javadoc.jar"/>
+	<classpathentry kind="lib" path="lib/lucene-memory-3.5.0.jar"/>
+	<classpathentry kind="lib" path="lib/iText-2.0.8.jar"/>
+	<classpathentry kind="lib" path="lib/core-renderer.jar"/>
+	<classpathentry kind="lib" path="lib/saxon9-dom.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/.externalToolBuilders/mpiwg-mpdl-cms-build.launch	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
+<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="mpiwg-mpdl-cms"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/mpiwg-mpdl-cms/build/build.xml}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+</launchConfiguration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/.project	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>mpiwg-mpdl-cms</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+			<triggers>full,incremental,</triggers>
+			<arguments>
+				<dictionary>
+					<key>LaunchConfigHandle</key>
+					<value>&lt;project&gt;/.externalToolBuilders/mpiwg-mpdl-cms-build.launch</value>
+				</dictionary>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/.settings/org.eclipse.core.resources.prefs	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,6 @@
+#Thu May 17 12:31:24 CEST 2012
+eclipse.preferences.version=1
+encoding//src/de/mpg/mpiwg/berlin/mpdl/cms/lucene/IndexHandler.java=UTF-8
+encoding//src/de/mpg/mpiwg/berlin/mpdl/cms/test/TestLocal.java=UTF-8
+encoding//src/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler.java=UTF-8
+encoding//src/de/mpg/mpiwg/berlin/mpdl/cms/transform/HighlightContentHandler.java=UTF-8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/constants.properties	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+dataDir=/Users/jwillenborg/mpdl/data/lt
+documentsDir=/Users/jwillenborg/mpdl/data/xml/documents
+luceneDocumentsDir=/Users/jwillenborg/mpdl/data/xml/lucene/documents
+luceneNodesDir=/Users/jwillenborg/mpdl/data/xml/lucene/nodes
+confDir=/Users/jwillenborg/mpdl/data/collectionConfs
\ No newline at end of file
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/CollectionReader.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManager.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManagerResultWrapper.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/Document.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/DocumentHandler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/Hits.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/MetadataRecord.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandlerUserAgent.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/document/Token.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/general/Constants.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/harvester/PathExtractor.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/lucene/IndexHandler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainScheduler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainSchedulerListener.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocJob.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocOperation.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/quartz.properties	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,9 @@
+org.quartz.scheduler.instanceName = MpdlScheduler
+org.quartz.scheduler.instanceId = auto
+org.quartz.scheduler.rmi.export = false
+org.quartz.scheduler.rmi.proxy = false
+
+org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
+org.quartz.threadPool.threadCount = 3
+
+org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/test/TestLocal.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler$Element.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/HighlightContentHandler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/PageTransformer.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/QueryTransformer.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/TocTransformer.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/XslResourceTransformer.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/chars.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes"/>
+
+<xsl:template match="text()">
+  <xsl:sequence select="normalize-space(.)"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageArchimedes.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,332 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:archimedes">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'archimedes'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:expan|*:emph|*:q|*:quote|*:blockquote|*:set-off|*:reg|*:var|*:num">
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="text">
+  <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
+  <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
+  <xsl:variable name="bottomNotes" select="//*:note"/>
+  <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
+    <xsl:apply-templates/>
+    <xsl:if test="$contentStr = '' and empty($figures)">  <!-- test if div only contains empty nodes but no figures -->
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
+        <xsl:value-of select="'[Empty page]'"/>
+      </div>
+    </xsl:if>
+    <!--   Foot notes                      -->
+    <xsl:if test="$countBottomNotes > 0">
+      <div class="notes foot">
+        <xsl:for-each select="$bottomNotes">
+          <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+          <span>
+            <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+            <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+            <span>
+              <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+              <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+              <xsl:apply-templates/>
+            </span>
+          </span>
+        </xsl:for-each>
+      </div>
+    </xsl:if>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <xsl:variable name="type" select="string(@type)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="$type = 'head'">
+        <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>      
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>      
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number">
+    <xsl:choose>
+      <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="file">
+    <xsl:choose>
+      <xsl:when test="not(empty(@xlink:href))"><xsl:value-of select="replace(@xlink:href, '/', '.')"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <span class="figure">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:variable name="fileHref" select="replace(@xlink:href, '/', '.')"/>
+    <xsl:variable name="fileName" select="concat($echoFiguresDir, '/', $fileHref)"/>
+    <xsl:variable name="digilibUrl" select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?fn=', $fileName)"/>
+    <xsl:variable name="scalerUrl" select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/>
+    <xsl:variable name="ancestorWords" select="./ancestor::*:w"/>  <!-- if figure is in a word then no link within a link should be produced -->
+    <xsl:choose>
+      <xsl:when test="empty($ancestorWords)">
+        <a href="{$digilibUrl}">
+          <img>
+            <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+          </img>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <img>
+          <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+        </img>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:if test="not(empty(@number))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
+          <xsl:value-of select="string(@number)"/>
+        </span>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
+          <xsl:value-of select="concat('[', 'Figure', ' ', string(@number), ']')"/>
+        </span>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="note">
+  <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
+  <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+    <span class="noteSign"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></span>
+  </span>
+</xsl:template>
+
+<xsl:template match="foreign">
+  <xsl:variable name="lang" select="@lang"/>
+  <xsl:variable name="xmllang" select="@xml:lang"/>
+  <xsl:variable name="language">
+    <xsl:choose>
+      <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
+      <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="gap">
+  <span class="gap">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
+    <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words                            -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEcho.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,559 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  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:de="http://www.mpiwg-berlin.mpg.de/ns/de/1.0/"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:mml="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms echo de math mml svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:echo">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'echo'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:text">
+  <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
+  <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
+  <xsl:variable name="bottomNotes" select="//*:note[contains(@position, 'foot') or empty(@position)]"/>
+  <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
+    <xsl:apply-templates/>
+    <xsl:if test="$contentStr = '' and empty($figures)">  <!-- test if div only contains empty nodes but no figures -->
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
+        <xsl:value-of select="'[Empty page]'"/>
+      </div>
+    </xsl:if>
+    <!--   Foot notes                      -->
+    <xsl:if test="$countBottomNotes > 0">
+      <div class="notes foot">
+        <xsl:for-each select="$bottomNotes">
+          <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+          <span>
+            <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+            <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+            <span>
+              <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+              <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+              <xsl:apply-templates/>
+            </span>
+          </span>
+        </xsl:for-each>
+      </div>
+    </xsl:if>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <xsl:variable name="style" select="@style"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
+    <xsl:choose>
+      <xsl:when test="not(empty($style))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="empty(@position)"><xsl:value-of select="name()"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat(name(), ' ', string(@position))"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="image" select="*:image"/>
+  <xsl:variable name="caption" select="*:caption"/>
+  <xsl:variable name="description" select="*:description"/>
+  <xsl:variable name="variables" select="*:variables"/>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:if test="not(empty($image))">
+      <xsl:variable name="file" select="$image/@file"/>
+      <xsl:variable name="pn" select="$image/@pn"/>
+      <xsl:variable name="wx" select="$image/@wx"/>
+      <xsl:variable name="wy" select="$image/@wy"/>
+      <xsl:variable name="ww" select="$image/@ww"/>
+      <xsl:variable name="wh" select="$image/@wh"/>
+      <xsl:variable name="digilibServiceName" select="'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html'"/>
+      <xsl:variable name="scalerServiceName" select="'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler'"/>
+      <xsl:variable name="fileName">
+        <xsl:choose>
+          <xsl:when test="empty($wx) and empty($file)"><xsl:value-of select="$echoFiguresDir"/></xsl:when>
+          <xsl:when test="empty($wx) and not(empty($file))"><xsl:value-of select="concat($echoFiguresDir, '/', $file)"/></xsl:when>
+          <xsl:when test="not(empty($wx)) and empty($file)"><xsl:value-of select="$echoPageImgDir"/></xsl:when>
+          <xsl:when test="not(empty($wx)) and not(empty($file))"><xsl:value-of select="concat($echoPageImgDir, '/', $file)"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="$echoFiguresDir"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="digilibUrl">
+        <xsl:choose>
+          <xsl:when test="empty($pn) and empty($wx)"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName)"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and empty($wx)"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;pn=', $pn)"/></xsl:when>
+          <xsl:when test="empty($pn) and not(empty($wx))"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh)"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and not(empty($wx))"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh)"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName)"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="scalerUrl">
+        <xsl:choose>
+          <xsl:when test="empty($pn) and empty($wx)"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and empty($wx)"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:when test="empty($pn) and not(empty($wx))"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and not(empty($wx))"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <a href="{$digilibUrl}">
+        <img>
+          <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+        </img>
+      </a>
+    </xsl:if>
+    <xsl:if test="not(empty(@number))">
+      <xsl:variable name="type"><xsl:value-of select="'Figure'"/></xsl:variable>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
+          <xsl:value-of select="string(@number)"/>
+        </span>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
+          <xsl:value-of select="concat('[', $type, ' ', string(@number), ']')"/>
+        </span>
+      </span>
+    </xsl:if>
+    <xsl:if test="not(empty($caption))">
+      <xsl:for-each select="$caption">
+        <span class="caption"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:if test="not(empty($description))">
+      <xsl:for-each select="$description">
+        <span class="description"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:if test="not(empty($variables))">
+      <xsl:for-each select="$variables">
+        <span class="variables"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="mml:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- XHTML: remove the xhtml namespace   -->
+<xsl:template match="xhtml:*">
+  <xsl:variable name="hasLabel" select="not(empty(@xhtml:label))"/>
+  <xsl:variable name="isTable" select="local-name() = 'table'"/>
+  <xsl:choose>
+    <xsl:when test="(not($hasLabel)) or ($isTable and $hasLabel)">
+      <xsl:element name="{name()}" namespace="">
+        <xsl:copy-of select="@*"/>
+        <xsl:apply-templates/>
+      </xsl:element>
+    </xsl:when>
+    <xsl:otherwise></xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:place|*:person">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <xsl:variable name="style" select="@style"/>
+  <xsl:variable name="class" select="'p'"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="not(empty($style))">
+        <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number">
+    <xsl:choose>
+      <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="file">
+    <xsl:choose>
+      <xsl:when test="not(empty(@file))"><xsl:value-of select="@file"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+      <xsl:if test="not(empty(@o))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'o'"/></xsl:attribute>
+          <xsl:value-of select="@o"/>
+        </span>
+      </xsl:if>
+      <xsl:if test="not(empty(@rhead))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'rhead'"/></xsl:attribute>
+          <xsl:value-of select="@rhead"/>
+        </span>
+      </xsl:if>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:expan">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'expan'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:note|*:handwritten">
+  <xsl:variable name="position">
+    <xsl:choose>
+      <xsl:when test="empty(@position) and name() = 'note'"><xsl:value-of select="'foot'"/></xsl:when>
+      <xsl:when test="empty(@position) and name() = 'handwritten'"><xsl:value-of select="'margin'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="string(@position)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="type">
+    <xsl:choose>
+      <xsl:when test="name() = 'note'"><xsl:value-of select="'printed'"/></xsl:when>
+      <xsl:when test="name() = 'handwritten'"><xsl:value-of select="'handwritten'"/></xsl:when>
+      <xsl:otherwise></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
+  <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="concat('note ', $type, ' ', $position)"/></xsl:attribute>
+    <span class="noteSign">
+      <xsl:choose>
+        <xsl:when test="$position = 'foot'"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></xsl:when>
+        <xsl:otherwise><xsl:value-of select="$noteSign"/></xsl:otherwise>
+      </xsl:choose>
+    </span>
+    <xsl:if test="$position != 'foot'">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+        <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+        <xsl:apply-templates/>
+        <xsl:if test="$type = 'handwritten'">
+          <span>
+            <xsl:attribute name="class"><xsl:value-of select="'noteNumText'"/></xsl:attribute>
+            <xsl:value-of select="concat('[Handwritten note ', string(@number), ']')"/>
+          </span>
+        </xsl:if>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:emph">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'emph'"/></xsl:attribute>
+    <xsl:choose>
+      <xsl:when test="not(empty(@style))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="string(@style)"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:foreign">
+  <xsl:variable name="lang" select="@lang"/>
+  <xsl:variable name="xmllang" select="@xml:lang"/>
+  <xsl:variable name="language">
+    <xsl:choose>
+      <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
+      <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="$language = ''"><xsl:value-of select="'foreign'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat('foreign ', $language)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:q">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'q'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:quote">
+  <span class="quote">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:blockquote">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'blockquote'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:set-off">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'set-off'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:reg">
+  <span class="reg">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'reg'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:var">
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="empty(@type)"><xsl:value-of select="'var'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat('var ', string(@type))"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:num">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'num'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:gap">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
+    <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words  -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageTei.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,690 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:TEI">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'TEI'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:expan|*:emph|*:q|*:quote|*:reg|*:num">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:teiHeader">
+  <!-- do nothing -->
+</xsl:template>
+
+<xsl:template match="*:text">
+  <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
+  <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
+  <xsl:variable name="textAncestors" select="./ancestor::*:text"/>
+  <xsl:variable name="bottomNotes" select="//*:note[contains(@place, 'foot') or empty(@place)]"/>
+  <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
+    <xsl:apply-templates/>
+    <xsl:if test="$contentStr = '' and empty($figures) and empty($textAncestors)">  <!-- test if div only contains empty nodes but no figures -->
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
+        <xsl:value-of select="'[Empty page]'"/>
+      </div>
+    </xsl:if>
+    <!--   Foot notes                      -->
+    <xsl:if test="$countBottomNotes > 0">
+      <div class="notes foot">
+        <xsl:for-each select="$bottomNotes">
+          <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+          <span>
+            <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+            <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+            <span>
+              <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+              <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+              <xsl:apply-templates/>
+            </span>
+          </span>
+        </xsl:for-each>
+      </div>
+    </xsl:if>
+  </div>
+  <!--   Dictionary                      -->
+  <xsl:if test="not(empty(//*:entry))">
+    <xsl:for-each select="//*:entry">
+      <xsl:sort select="*:form/*:orth"/>
+      <xsl:variable name="position" select="position()"/>
+      <span class="entry">
+        <xsl:apply-templates select="*:form"/>
+        <xsl:apply-templates select="*:sense"/>
+        <xsl:if test="not(empty(*:figure))">
+          <span class="entryDiv">
+            <span class="bf"><xsl:value-of select="'Figures: '"/></span>
+            <span class="entryDiv">
+              <xsl:for-each select="*:figure">
+                <xsl:variable name="href" select="*:graphic/@url"/>
+                <xsl:variable name="figDesc" select="string(*:figDesc)"/>
+                <xsl:if test="$href != ''">
+                  <div class="figure" style="margin-left:10px;">
+                    <a href="{$href}"><img alt="Figure: {$figDesc}" src="{$href}" width="200" height="200"/></a>
+                    <br/>
+                    <xsl:value-of select="'[Figure]: '"/><xsl:apply-templates select="*:head"/>
+                  </div>
+                </xsl:if>
+              </xsl:for-each>
+            </span>
+          </span>
+        </xsl:if>
+        <xsl:if test="not(empty(*:xr))">
+          <span class="entryDiv">
+            <span class="bf"><xsl:value-of select="'References: '"/></span>
+            <span class="entryDiv">
+              <xsl:for-each select="*:xr/*:ref">
+                <li><xsl:apply-templates select="."/></li>
+              </xsl:for-each>
+            </span>
+          </span>
+        </xsl:if>
+      </span>
+    </xsl:for-each>  
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number">
+    <xsl:choose>
+      <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="file">
+    <xsl:choose>
+      <xsl:when test="not(empty(@facs))"><xsl:value-of select="@facs"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <span class="figure">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:variable name="url">
+      <xsl:choose>
+        <xsl:when test="not(empty(@facs))"><xsl:value-of select="string(@facs)"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="string(graphic/@url)"/></xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="fileName" select="concat($echoFiguresDir, '/', $url)"/>
+    <xsl:variable name="digilibUrl">
+      <xsl:choose>
+        <xsl:when test="starts-with($url, 'http')"><xsl:value-of select="$url"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?fn=', $fileName)"/></xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="scalerUrl">
+      <xsl:choose>
+        <xsl:when test="starts-with($url, 'http')"><xsl:value-of select="$url"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <a href="{$digilibUrl}">
+      <img>
+        <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+      </img>
+    </a>
+    <xsl:if test="not(empty(@number))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
+          <xsl:value-of select="string(@number)"/>
+        </span>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
+          <xsl:value-of select="concat('[', 'Figure', ' ', string(@number), ']')"/>
+        </span>
+      </span>
+    </xsl:if>
+    <xsl:if test="not(empty(*:head))">
+      <span class="caption">
+        <xsl:for-each select="*:head">
+          <xsl:apply-templates/>
+        </xsl:for-each>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- segmentation   -->
+<xsl:template match="*:seg">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@rend = 'highlight'">
+        <xsl:attribute name="class"><xsl:value-of select="'seg highlight'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@rend = 'highlightPoint'">
+        <xsl:attribute name="class"><xsl:value-of select="'seg highlightPoint'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="class"><xsl:value-of select="'seg'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </span>
+</xsl:template>
+
+<!-- choice   -->
+<xsl:template match="*:choice">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'choice'"/></xsl:attribute>
+    <xsl:if test="not(empty(*:orig))">
+      <xsl:apply-templates select="*:orig"/>
+    </xsl:if>
+    <xsl:if test="not(empty(*:abbr))">
+      <xsl:apply-templates select="*:abbr"/>
+    </xsl:if>
+    <xsl:if test="not(empty(*:am))">
+      <xsl:apply-templates select="*:am"/>
+    </xsl:if>
+    <xsl:if test="not(empty(*:sic))">
+      <xsl:apply-templates select="*:sic"/>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- hi (highlighted)  -->
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="not(empty(@type)) and @type = 'elem'">
+      <div>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:when test="not(empty(@type)) and @type != 'elem'">
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:when>
+    <xsl:when test="@rend = 'initial'">
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="'initial'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:when>
+    <xsl:when test="@rend = 'bold'">
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="'bf'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- name (of type: place, person, ...)   -->
+<xsl:template match="*:name">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@type = 'place'">
+        <xsl:attribute name="class"><xsl:value-of select="'place'"/></xsl:attribute>
+        <xsl:attribute name="title"><xsl:value-of select="'Place'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@type = 'person'">
+        <xsl:attribute name="class"><xsl:value-of select="'person'"/></xsl:attribute>
+        <xsl:attribute name="title"><xsl:value-of select="'Person'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@type = 'org'">
+        <xsl:attribute name="class"><xsl:value-of select="'organization'"/></xsl:attribute>
+        <xsl:attribute name="title"><xsl:value-of select="'Organization'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="@type"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </span>
+</xsl:template>
+
+<!-- place, person, ...)   -->
+<xsl:template match="*:placeName">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'place'"/></xsl:attribute>
+    <xsl:attribute name="title"><xsl:value-of select="concat('Place: ', @type)"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+<xsl:template match="*:persName">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'person'"/></xsl:attribute>
+    <xsl:attribute name="title"><xsl:value-of select="'Person'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- term    -->
+<xsl:template match="*:term">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'term'"/></xsl:attribute>
+    <xsl:attribute name="title"><xsl:value-of select="'Terminology entry'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- line    -->
+<xsl:template match="*:lg">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lg'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:l">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'l'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+  <br/>
+</xsl:template>
+
+<!-- reference: sourounds it by parantheses so that it could be 
+iop from word links within it  -->
+<xsl:template match="*:ref">
+  <xsl:variable name="refPos"><xsl:value-of select="count(./preceding::*:ref) + 1"/></xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'ref'"/></xsl:attribute>
+    <xsl:if test="not(empty(@target))">
+      <a class="ref">
+        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
+        <span class="super"><xsl:value-of select="concat('[', $refPos)"/></span>
+      </a>
+      <xsl:value-of select="' '"/>
+      <xsl:apply-templates/>
+      <xsl:value-of select="' '"/>
+      <a class="ref">
+        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
+        <span class="super"><xsl:value-of select="concat($refPos, ']')"/></span>
+      </a>
+    </xsl:if>
+    <xsl:if test="empty(@target)">
+      <xsl:apply-templates/>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- table    -->
+<xsl:template match="*:table">
+  <table>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(head))">
+      <caption align="top"><xsl:apply-templates select="*:head"/></caption>
+    </xsl:if>
+    <xsl:apply-templates select="*:row"/>
+  </table>
+</xsl:template>
+
+<xsl:template match="*:row">
+  <tr>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@role = 'label'">
+01002    b
+  ghj565hghj23,b02,0    <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
+  0      <xsl:apply-templates/>
+   bvcxvb4    </xsl:when>
+      <xsl:when test="@role = 'data' or empty(@role)">
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </tr>
+</xsl:template>
+
+<xsl:template match="*:cell">
+  <td>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@role = 'label' and empty(@cols)">
+        <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@role = 'label' and not(empty(@cols))">
+        <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
+        <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="(@role = 'data' or empty(@role)) and empty(@cols)">
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="(@role = 'data' or empty(@role)) and not(empty(@cols))">
+        <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </td>
+</xsl:template>
+
+<!-- dictionary    -->
+<xsl:template match="*:entry">
+  <!-- emp
+  
+  + handled in text tag    -->
+</xsl:template>
+
+<xsl:template match="*:form">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'form'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:orth">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'orth'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:sense">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'sense'"/></xsl:attribute>
+    <span class="entryDiv"><xsl:apply-templates select="*:def"/></span>
+    <span class="entryDiv"><xsl:apply-templates select="*:etym"/></span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:def">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'def'"/></xsl:attribute>
+    <span class="bf"><xsl:value-of select="'Definition: '"/></span>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:mentioned">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'mentioned'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:etym">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'etym'"/></xsl:attribute>
+    <span class="bf"><xsl:value-of select="'Etymology: '"/></span>
+    <span class="entryDiv">
+      <xsl:for-each select="*:cit">
+        <li><xsl:apply-templates select="*:quote"/><xsl:value-of select="' ('"/><xsl:apply-templates select="*:def"/><xsl:value-of select="')'"/></li>
+      </xsl:for-each>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:cit">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cit'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:note">
+  <xsl:variable name="position">
+    <xsl:choose>
+      <xsl:when test="empty(@place) and name() = 'note'"><xsl:value-of select="'foot'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="string(@place)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="type" select="'printed'"/>
+  <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
+  <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="concat('note ', $type, ' ', $position)"/></xsl:attribute>
+    <span class="noteSign">
+      <xsl:choose>
+        <xsl:when test="$position = 'foot'"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></xsl:when>
+        <xsl:otherwise><xsl:value-of select="$noteSign"/></xsl:otherwise>
+      </xsl:choose>
+    </span>
+    <xsl:if test="$position != 'foot'">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+        <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:foreign">
+  <xsl:variable name="xmllang" select="@xml:lang"/>
+  <xsl:variable name="language">
+    <xsl:choose>
+      <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:gap">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
+    <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words                            -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXhtml.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,240 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:saxon="http://saxon.sf.net/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs saxon dc dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<!-- the identity template -->
+<xsl:template match="@*|node()">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="*:html">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="*:body">
+  <!-- to set the xhtml namespace onto this dummy node -->
+  <page>
+    <xsl:apply-templates/>
+  </page>
+</xsl:template>
+
+<xsl:template match="*:expan|*:emph|*:q|*:quote|*:blockquote|*:set-off|*:reg|*:var|*:num|*:figure">
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:a">
+  <!-- empty element with only name attribute makes trouble -->
+  <xsl:variable name="name" select="@name"/>
+  <xsl:variable name="href" select="@href"/>
+  <xsl:choose>
+    <xsl:when test="not(empty($name)) and empty($href)">
+      <span>
+        <xsl:attribute name="id"><xsl:value-of select="$name"/></xsl:attribute>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <a class="ref">
+        <xsl:copy-of select="@*"/>
+        <xsl:apply-templates/>
+      </a>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <div>
+    <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number" select="count(./preceding::*:pb) + 1"/>
+  <xsl:variable name="file" select="$number"/>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+    </span>
+  </span>
+</xsl:template>
+
+<!--  MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:br">
+  <br>
+    <xsl:attribute name="class"><xsl:value-of select="'br'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:note">
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words                            -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXml.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<!-- transform to browser like xml display -->
+<xsl:template match="element()">
+  <xsl:variable name="elementName" select="name()"/>
+  <xsl:variable name="elementPresentation">
+    <xsl:choose>
+    <xsl:when test="element() = node() or text() != ''">
+      <xsl:value-of select="'&lt;'"/>
+      <span class="xml elementName"><xsl:value-of select="$elementName"/></span>
+      <xsl:apply-templates select="attribute()"/>
+      <xsl:value-of select="'&gt;'"/>
+      <xsl:apply-templates select="element()|text()|comment()|processing-instruction()"/>
+      <xsl:value-of select="'&lt;/'"/>
+      <span class="xml elementName"><xsl:value-of select="$elementName"/></span>
+      <xsl:value-of select="'&gt;'"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="'&lt;'"/>
+      <span class="xml elementName"><xsl:value-of select="$elementName"/></span>
+      <xsl:apply-templates select="attribute()"/>
+      <xsl:value-of select="'/&gt;'"/>
+    </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <ul class="xml element">
+    <xsl:sequence select="$elementPresentation"/>
+  </ul>
+</xsl:template>
+
+<xsl:template match="attribute()">
+  <xsl:variable name="attributeName" select="name()"/>
+  <span class="xml attributeName">
+    <xsl:value-of select="' '"/>
+    <xsl:value-of select="$attributeName"/>
+  </span>
+  <xsl:value-of select="'=&quot;'"/>
+  <span class="xml attributeValue"><xsl:value-of select="."/></span><xsl:value-of select="'&quot;'"/>
+</xsl:template>
+
+<xsl:template match="comment()">
+  <span class="xml comment">
+    <xsl:value-of select="'&lt;!-- '"/><xsl:value-of select="."/><xsl:value-of select="' --&gt;'"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="processing-instruction()">
+</xsl:template>
+
+<xsl:template match="*:w">
+  <xsl:apply-templates select="*:orig/node()"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/queryDocument.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+ 
+<xsl:param name="query"></xsl:param>
+<xsl:param name="flags"></xsl:param>
+<xsl:param name="outputFormat"></xsl:param>
+
+<xsl:variable name="apos">'</xsl:variable>
+<xsl:variable name="xpathQuery">
+  <xsl:choose>
+    <xsl:when test="$flags = ''"><xsl:value-of select="concat('//*:s[matches(.,', $apos, $query, $apos, ')]', '|', '//*:head[matches(.,', $apos, $query, $apos, ')]')"/></xsl:when>
+    <xsl:otherwise><xsl:value-of select="concat('//*:s[matches(.,', $apos, $query, $apos, ',', $apos, $flags, $apos, ')]', '|', '//*:head[matches(.,', $apos, $query, $apos, ',', $apos, $flags, $apos, ')]')"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+<xsl:variable name="queryResult" select="saxon:evaluate($xpathQuery)" xmlns:saxon="http://saxon.sf.net/"/>
+<xsl:variable name="queryResultSize"><xsl:value-of select="count($queryResult)"/></xsl:variable>
+<xsl:variable name="queryResultPageSize" select="20"/>
+<xsl:variable name="queryResultPages">
+  <xsl:choose>
+    <xsl:when test="$queryResultSize = 0"><xsl:value-of select="count($queryResult)"/></xsl:when>
+    <xsl:otherwise><xsl:value-of select="$queryResultSize idiv $queryResultPageSize + 1"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+<xsl:variable name="pageBreaks" select="saxon:evaluate('//*:pb')" xmlns:saxon="http://saxon.sf.net/"/>
+<xsl:variable name="queryResultHtml">
+<xsl:choose>
+  <xsl:when test="$outputFormat = 'html'">
+    <table>
+      <thead>
+        <tr>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">No.</button>
+          </th>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Path</button>
+          </th>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Hit</button>
+          </th>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Page</button>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <xsl:for-each select="$queryResult">
+          <xsl:variable name="hit" select="."/>
+          <tr>
+            <td align="left" valign="top"><xsl:value-of select="position()"/></td>
+            <td align="left" valign="top"><xsl:value-of select="saxon:path(.)" xmlns:saxon="http://saxon.sf.net/"/></td>
+            <td align="left" valign="top"><xsl:value-of select="."/></td>
+            <td align="left" valign="top"><xsl:value-of select="count(./preceding::*:pb)"/></td>     <!-- better performance: count($pageBreaks[. << $hit])  -->
+          </tr>
+        </xsl:for-each>    
+      </tbody>
+    </table>
+  </xsl:when>
+  <xsl:otherwise>
+    <result>
+      <query><xsl:value-of select="$query"/></query>
+      <flags><xsl:value-of select="$flags"/></flags>
+      <size><xsl:value-of select="$queryResultSize"/></size>
+      <page-size><xsl:value-of select="$queryResultPageSize"/></page-size>
+      <pages><xsl:value-of select="$queryResultPages"/></pages>
+      <pn>1</pn>
+      <hits>
+        <xsl:for-each select="$queryResult">
+          <xsl:variable name="hit" select="."/>
+          <hit>
+            <hitType><xsl:value-of select="'s'"/></hitType>
+            <pos><xsl:value-of select="position()"/></pos>
+            <pn><xsl:value-of select="count(./preceding::*:pb)"/></pn>
+            <hitId>xmlId</hitId>
+            <hitPos>4711</hitPos>
+            <hitString><xsl:value-of select="."/></hitString>
+            <hitSurroundsPB>false</hitSurroundsPB>
+          </hit>
+        </xsl:for-each>    
+      </hits>
+      <query-forms></query-forms>
+      <query-regularizations></query-regularizations>
+    </result>
+  </xsl:otherwise>
+</xsl:choose>
+</xsl:variable>
+<xsl:template match="/">
+  <xsl:sequence select="$queryResultHtml"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/replaceAnchor.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet 
+  version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xhtml"
+>
+
+<xsl:output method="xml" encoding="utf-8"/>
+
+<xsl:template match="@*|node()">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+<!-- insert figure number  -->
+<xsl:template match="*:figure">
+  <xsl:variable name="number" select="count(./preceding::*:figure) + 1"/>
+  <xsl:element name="{name()}" namespace="{namespace-uri()}"><!-- remove namespace in element and its subnodes  -->
+    <xsl:apply-templates select="@*"/>
+    <xsl:attribute name="number"><xsl:value-of select="$number"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- insert figure number  -->
+<xsl:template match="*:handwritten">
+  <xsl:variable name="number" select="count(./preceding::*:handwritten) + 1"/>
+  <xsl:element name="{name()}" namespace="{namespace-uri()}"><!-- remove namespace in element and its subnodes  -->
+    <xsl:apply-templates select="@*"/>
+    <xsl:attribute name="number"><xsl:value-of select="$number"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:anchor">
+  <xsl:variable name="type" select="@type"/>
+  <xsl:variable name="href" select="@xlink:href"/>
+  <xsl:choose>
+    <xsl:when test="$type = 'figure'">
+      <xsl:variable name="figure" select="//*:figure[@xlink:label = $href]"/>
+      <xsl:apply-templates select="$figure"/>
+    </xsl:when>
+    <xsl:when test="$type = 'handwritten'">
+      <xsl:variable name="handwritten" select="//*:handwritten[@xlink:label = $href]"/>
+      <xsl:apply-templates select="$handwritten"/>
+    </xsl:when>
+    <xsl:when test="$type = 'note'">
+      <xsl:variable name="note" select="//*:note[@xlink:label = $href]"/>
+      <xsl:sequence select="$note"/>
+    </xsl:when>
+    <xsl:when test="$type = 'table'">
+      <xsl:variable name="table" select="//xhtml:table[@xlink:label = $href]"/>
+      <xsl:sequence select="$table"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy>
+        <xsl:apply-templates select="@*|node()"/>
+      </xsl:copy>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- remove the anchored divs: div which contain a labeled figure, note, handwritten or table -->
+<xsl:template match="*:div">
+  <xsl:variable name="containingElems" select="*:figure|*:note|*:handwritten|xhtml:table"/>
+  <xsl:variable name="hasLabel" select="not(empty($containingElems[1]/@xlink:label))"/>
+  <xsl:choose>
+    <xsl:when test="$hasLabel"></xsl:when>
+    <xsl:otherwise>
+      <xsl:copy>
+        <xsl:apply-templates select="@*|node()"/>
+      </xsl:copy>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/toc.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,147 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet 
+  version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xhtml"
+>
+
+<xsl:output method="xml" encoding="utf-8" indent="yes"/>
+
+<xsl:template match="/">
+  <xsl:variable name="toc" select="//*:div[@type = 'section' or @type = 'chapter' or @type = 'part']"/>
+  <xsl:variable name="figures" select="//*:figure"/>
+  <xsl:variable name="notes" select="//*:note|//*:handwritten"/>
+  <xsl:variable name="pages" select="//*:pb"/>
+  <xsl:variable name="places" select="//*:place"/>
+  <list>
+    <xsl:if test="not(empty($toc))">
+      <list type ="toc">
+        <xsl:attribute name="count"><xsl:value-of select="count($toc)"/></xsl:attribute>
+        <head>Table of contents</head>
+        <xsl:apply-templates select="$toc"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($figures))">
+      <list type="figures">
+        <xsl:attribute name="count"><xsl:value-of select="count($figures)"/></xsl:attribute>
+        <head>Figures</head>
+        <xsl:apply-templates select="$figures"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($notes))">
+      <list type="notes">
+        <xsl:attribute name="count"><xsl:value-of select="count($notes)"/></xsl:attribute>
+        <head>Notes</head>
+        <xsl:apply-templates select="$notes"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($pages))">
+      <list type="pages">
+        <xsl:attribute name="count"><xsl:value-of select="count($pages)"/></xsl:attribute>
+        <head>Pages</head>
+        <xsl:apply-templates select="$pages"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($places))">
+      <list type="places">
+        <xsl:attribute name="count"><xsl:value-of select="count($places)"/></xsl:attribute>
+        <head>Places</head>
+        <xsl:apply-templates select="$places"/>
+      </list>
+    </xsl:if>
+  </list>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <xsl:variable name="number" select="@number"/>
+  <item>
+    <xsl:if test="not(empty($number))"><xsl:attribute name="n"><xsl:value-of select="$number"/></xsl:attribute></xsl:if>
+    <xsl:apply-templates select="*:caption"/>
+    <xsl:apply-templates select="*:description"/>
+    <xsl:apply-templates select="*:variables"/>
+    <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:caption"><xsl:value-of select="' '"/>
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="*:description">
+  <xsl:apply-templates/><xsl:value-of select="' '"/>
+</xsl:template>
+
+<xsl:template match="*:variables">
+  <xsl:apply-templates/><xsl:value-of select="' '"/>
+</xsl:template>
+
+<xsl:template match="*:note|*:handwritten">
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <xsl:variable name="number" select="@number"/>
+  <xsl:variable name="position" select="@position"/>
+  <xsl:variable name="type">
+    <xsl:choose>
+      <xsl:when test="name() = 'note'"><xsl:value-of select="'printed'"/></xsl:when>
+      <xsl:when test="name() = 'handwritten'"><xsl:value-of select="'handwritten'"/></xsl:when>
+      <xsl:otherwise></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <item>
+    <xsl:if test="not(empty($type))"><xsl:attribute name="type"><xsl:value-of select="$type"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($position))"><xsl:attribute name="position"><xsl:value-of select="$position"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($number))"><xsl:attribute name="n"><xsl:value-of select="$number"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:place">
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <xsl:variable name="id" select="@id"/>
+  <item>
+    <xsl:if test="not(empty($id))"><xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute></xsl:if>
+    <content><xsl:apply-templates/></content>
+    <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:variable name="level"><xsl:number level="multiple" count="*:div[@type = 'section' or @type = 'chapter' or @type = 'part']" format="1."/></xsl:variable>
+  <xsl:variable name="depth" select="string-length(replace($level, '[^\\.]', ''))"/>
+  <xsl:variable name="pb" select="./preceding::*:pb[1]"/>
+  <xsl:variable name="o" select="$pb/@o"/>
+  <xsl:variable name="oNorm" select="$pb/@o-norm"/>
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <item>
+    <xsl:if test="not(empty($level))"><xsl:attribute name="n"><xsl:value-of select="$level"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($level))"><xsl:attribute name="lv"><xsl:value-of select="$depth"/></xsl:attribute></xsl:if>
+    <xsl:apply-templates select="*:head"/>
+    <xsl:if test="not(empty($page))">
+      <ref>
+        <xsl:if test="not(empty($o))"><xsl:attribute name="o"><xsl:value-of select="$o"/></xsl:attribute></xsl:if>
+        <xsl:if test="not(empty($oNorm))"><xsl:attribute name="o-norm"><xsl:value-of select="$oNorm"/></xsl:attribute></xsl:if>
+        <xsl:value-of select="$page"/>
+      </ref>
+    </xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <xsl:apply-templates/><xsl:value-of select="' '"/>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="page" select="count(./preceding::*:pb) + 1"/>
+  <item>
+    <xsl:attribute name="n"><xsl:value-of select="$page"/></xsl:attribute>
+    <xsl:if test="not(empty(@o))"><xsl:attribute name="o"><xsl:value-of select="@o"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(@o-norm))"><xsl:attribute name="o-norm"><xsl:value-of select="@o-norm"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(@file))"><xsl:attribute name="file"><xsl:value-of select="@file"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(@facs))"><xsl:attribute name="file"><xsl:value-of select="@facs"/></xsl:attribute></xsl:if>
+  </item>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/tocOut.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet 
+  version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+<xsl:output method="xhtml"/>
+
+<xsl:param name="type"></xsl:param>
+<xsl:param name="outputFormat"></xsl:param>
+
+<xsl:template match="/">
+  <xsl:choose>
+    <xsl:when test="$outputFormat = 'html'">
+      <xsl:apply-templates select="//*:list[@type = $type]/item" mode="html"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:sequence select="//*:list[@type = $type]"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*:item" mode="html">
+  <xsl:variable name="n" select="@n"/>
+  <xsl:variable name="level" select="@lv"/>
+  <div>
+    <xsl:attribute name="class"><xsl:value-of select="'tocItem'"/></xsl:attribute>
+    <xsl:value-of select="concat($n, ' ')"/>
+    <xsl:apply-templates mode="html"/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:ref" mode="html">
+  <xsl:variable name="pageOrig" select="@o"/>
+  <xsl:variable name="page" select="text()"/>
+  <xsl:variable name="pageHref" select="concat('#page', $page)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="'tocPageRef'"/></xsl:attribute>
+    <xsl:value-of select="'Page: '"/>
+    <a href="{$pageHref}"><xsl:apply-templates mode="html"/></a>
+  </span>
+</xsl:template>
+
+</xsl:stylesheet>
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/translator/MicrosoftTranslator.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/exception/ApplicationException.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/build.xml	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,39 @@
+<!DOCTYPE project>
+<project name="mpiwg-mpdl-cms" default="compile" basedir="../">
+  <description>mpiwg-mpdl-cms</description>
+  <!-- global properties -->
+  <property name="src" location="src"/>
+  <property name="lib" location="lib"/>
+  <property name="build" location="build/classes"/>
+  <property name="dist" location="dist"/>
+
+  <path id="classpath">
+    <fileset dir="${lib}" includes="**/*.jar"/>
+  </path>
+  
+  <target name="init">
+    <!-- Create time stamp -->
+    <tstamp/>
+    <mkdir dir="${build}"/>
+    <mkdir dir="${dist}"/>
+  </target>
+
+  <target name="compile" depends="init" description="compile">
+    <copy file="/Users/jwillenborg/java/mpiwg-mpdl-xml/dist/mpiwg-mpdl-xml.jar" todir="${lib}"/>
+    <copy file="/Users/jwillenborg/java/mpiwg-mpdl-lt/dist/mpiwg-mpdl-lt.jar" todir="${lib}"/>
+    <javac srcdir="${src}" destdir="${build}" classpathref="classpath" includeantruntime="false"/>
+    <copy todir="${build}">
+      <fileset dir="${src}">
+        <include name="**/*.xsl"/>
+        <include name="**/*.properties"/>
+      </fileset>
+    </copy>
+    <jar jarfile="${dist}/mpiwg-mpdl-cms.jar" basedir="${build}"/>
+    <copy file="${dist}/mpiwg-mpdl-cms.jar" todir="/Users/jwillenborg/java/mpiwg-mpdl-cms-web/WebContent/WEB-INF/lib"/>
+  </target>
+
+  <target name="clean" description="clean" >
+    <delete dir="${build}"/>
+    <delete file="${dist}/mpiwg-mpdl-cms.jar"/>
+  </target>
+</project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/constants.properties	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+dataDir=/Users/jwillenborg/mpdl/data/lt
+documentsDir=/Users/jwillenborg/mpdl/data/xml/documents
+luceneDocumentsDir=/Users/jwillenborg/mpdl/data/xml/lucene/documents
+luceneNodesDir=/Users/jwillenborg/mpdl/data/xml/lucene/nodes
+confDir=/Users/jwillenborg/mpdl/data/collectionConfs
\ No newline at end of file
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/CollectionReader.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManager.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManagerResultWrapper.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/Document.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/DocumentHandler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/Hits.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/MetadataRecord.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandlerUserAgent.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/document/Token.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/general/Constants.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/harvester/PathExtractor.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/lucene/IndexHandler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainScheduler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainSchedulerListener.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocJob.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocOperation.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/quartz.properties	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,9 @@
+org.quartz.scheduler.instanceName = MpdlScheduler
+org.quartz.scheduler.instanceId = auto
+org.quartz.scheduler.rmi.export = false
+org.quartz.scheduler.rmi.proxy = false
+
+org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
+org.quartz.threadPool.threadCount = 3
+
+org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/test/TestLocal.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler$1.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler$Element.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/HighlightContentHandler.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/HighlightTransformer.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/PageTransformer.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/QueryTransformer.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/ReplaceAnchorTransformer.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/TocTransformer.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/XslResourceTransformer.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/chars.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes"/>
+
+<xsl:template match="text()">
+  <xsl:sequence select="normalize-space(.)"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/highlight.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="html" encoding="utf-8"/>
+
+<xsl:template match="*:hi">
+  <xsl:variable name="type" select="string(@type)"/>
+  <xsl:choose>
+    <xsl:when test="$type = 'elem'">
+      <div style="background-color:#D3D3D3"><xsl:apply-templates/></div>
+    </xsl:when>
+    <xsl:when test="$type = 'hit'">
+      <span style="background-color:#77DD77"><xsl:apply-templates/></span>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:apply-templates/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*[. except self::*:hi]">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageArchimedes.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,332 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:archimedes">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'archimedes'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:expan|*:emph|*:q|*:quote|*:blockquote|*:set-off|*:reg|*:var|*:num">
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="text">
+  <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
+  <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
+  <xsl:variable name="bottomNotes" select="//*:note"/>
+  <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
+    <xsl:apply-templates/>
+    <xsl:if test="$contentStr = '' and empty($figures)">  <!-- test if div only contains empty nodes but no figures -->
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
+        <xsl:value-of select="'[Empty page]'"/>
+      </div>
+    </xsl:if>
+    <!--   Foot notes                      -->
+    <xsl:if test="$countBottomNotes > 0">
+      <div class="notes foot">
+        <xsl:for-each select="$bottomNotes">
+          <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+          <span>
+            <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+            <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+            <span>
+              <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+              <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+              <xsl:apply-templates/>
+            </span>
+          </span>
+        </xsl:for-each>
+      </div>
+    </xsl:if>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <xsl:variable name="type" select="string(@type)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="$type = 'head'">
+        <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>      
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>      
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number">
+    <xsl:choose>
+      <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="file">
+    <xsl:choose>
+      <xsl:when test="not(empty(@xlink:href))"><xsl:value-of select="replace(@xlink:href, '/', '.')"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <span class="figure">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:variable name="fileHref" select="replace(@xlink:href, '/', '.')"/>
+    <xsl:variable name="fileName" select="concat($echoFiguresDir, '/', $fileHref)"/>
+    <xsl:variable name="digilibUrl" select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?fn=', $fileName)"/>
+    <xsl:variable name="scalerUrl" select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/>
+    <xsl:variable name="ancestorWords" select="./ancestor::*:w"/>  <!-- if figure is in a word then no link within a link should be produced -->
+    <xsl:choose>
+      <xsl:when test="empty($ancestorWords)">
+        <a href="{$digilibUrl}">
+          <img>
+            <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+          </img>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <img>
+          <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+        </img>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:if test="not(empty(@number))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
+          <xsl:value-of select="string(@number)"/>
+        </span>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
+          <xsl:value-of select="concat('[', 'Figure', ' ', string(@number), ']')"/>
+        </span>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="note">
+  <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
+  <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+    <span class="noteSign"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></span>
+  </span>
+</xsl:template>
+
+<xsl:template match="foreign">
+  <xsl:variable name="lang" select="@lang"/>
+  <xsl:variable name="xmllang" select="@xml:lang"/>
+  <xsl:variable name="language">
+    <xsl:choose>
+      <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
+      <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="gap">
+  <span class="gap">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
+    <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words                            -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEcho.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,559 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  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:de="http://www.mpiwg-berlin.mpg.de/ns/de/1.0/"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:mml="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms echo de math mml svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:echo">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'echo'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:text">
+  <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
+  <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
+  <xsl:variable name="bottomNotes" select="//*:note[contains(@position, 'foot') or empty(@position)]"/>
+  <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
+    <xsl:apply-templates/>
+    <xsl:if test="$contentStr = '' and empty($figures)">  <!-- test if div only contains empty nodes but no figures -->
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
+        <xsl:value-of select="'[Empty page]'"/>
+      </div>
+    </xsl:if>
+    <!--   Foot notes                      -->
+    <xsl:if test="$countBottomNotes > 0">
+      <div class="notes foot">
+        <xsl:for-each select="$bottomNotes">
+          <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+          <span>
+            <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+            <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+            <span>
+              <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+              <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+              <xsl:apply-templates/>
+            </span>
+          </span>
+        </xsl:for-each>
+      </div>
+    </xsl:if>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <xsl:variable name="style" select="@style"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
+    <xsl:choose>
+      <xsl:when test="not(empty($style))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="empty(@position)"><xsl:value-of select="name()"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat(name(), ' ', string(@position))"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="image" select="*:image"/>
+  <xsl:variable name="caption" select="*:caption"/>
+  <xsl:variable name="description" select="*:description"/>
+  <xsl:variable name="variables" select="*:variables"/>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:if test="not(empty($image))">
+      <xsl:variable name="file" select="$image/@file"/>
+      <xsl:variable name="pn" select="$image/@pn"/>
+      <xsl:variable name="wx" select="$image/@wx"/>
+      <xsl:variable name="wy" select="$image/@wy"/>
+      <xsl:variable name="ww" select="$image/@ww"/>
+      <xsl:variable name="wh" select="$image/@wh"/>
+      <xsl:variable name="digilibServiceName" select="'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html'"/>
+      <xsl:variable name="scalerServiceName" select="'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler'"/>
+      <xsl:variable name="fileName">
+        <xsl:choose>
+          <xsl:when test="empty($wx) and empty($file)"><xsl:value-of select="$echoFiguresDir"/></xsl:when>
+          <xsl:when test="empty($wx) and not(empty($file))"><xsl:value-of select="concat($echoFiguresDir, '/', $file)"/></xsl:when>
+          <xsl:when test="not(empty($wx)) and empty($file)"><xsl:value-of select="$echoPageImgDir"/></xsl:when>
+          <xsl:when test="not(empty($wx)) and not(empty($file))"><xsl:value-of select="concat($echoPageImgDir, '/', $file)"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="$echoFiguresDir"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="digilibUrl">
+        <xsl:choose>
+          <xsl:when test="empty($pn) and empty($wx)"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName)"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and empty($wx)"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;pn=', $pn)"/></xsl:when>
+          <xsl:when test="empty($pn) and not(empty($wx))"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh)"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and not(empty($wx))"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh)"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName)"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="scalerUrl">
+        <xsl:choose>
+          <xsl:when test="empty($pn) and empty($wx)"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and empty($wx)"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:when test="empty($pn) and not(empty($wx))"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and not(empty($wx))"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <a href="{$digilibUrl}">
+        <img>
+          <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+        </img>
+      </a>
+    </xsl:if>
+    <xsl:if test="not(empty(@number))">
+      <xsl:variable name="type"><xsl:value-of select="'Figure'"/></xsl:variable>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
+          <xsl:value-of select="string(@number)"/>
+        </span>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
+          <xsl:value-of select="concat('[', $type, ' ', string(@number), ']')"/>
+        </span>
+      </span>
+    </xsl:if>
+    <xsl:if test="not(empty($caption))">
+      <xsl:for-each select="$caption">
+        <span class="caption"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:if test="not(empty($description))">
+      <xsl:for-each select="$description">
+        <span class="description"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:if test="not(empty($variables))">
+      <xsl:for-each select="$variables">
+        <span class="variables"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="mml:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- XHTML: remove the xhtml namespace   -->
+<xsl:template match="xhtml:*">
+  <xsl:variable name="hasLabel" select="not(empty(@xhtml:label))"/>
+  <xsl:variable name="isTable" select="local-name() = 'table'"/>
+  <xsl:choose>
+    <xsl:when test="(not($hasLabel)) or ($isTable and $hasLabel)">
+      <xsl:element name="{name()}" namespace="">
+        <xsl:copy-of select="@*"/>
+        <xsl:apply-templates/>
+      </xsl:element>
+    </xsl:when>
+    <xsl:otherwise></xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:place|*:person">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <xsl:variable name="style" select="@style"/>
+  <xsl:variable name="class" select="'p'"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="not(empty($style))">
+        <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number">
+    <xsl:choose>
+      <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="file">
+    <xsl:choose>
+      <xsl:when test="not(empty(@file))"><xsl:value-of select="@file"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+      <xsl:if test="not(empty(@o))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'o'"/></xsl:attribute>
+          <xsl:value-of select="@o"/>
+        </span>
+      </xsl:if>
+      <xsl:if test="not(empty(@rhead))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'rhead'"/></xsl:attribute>
+          <xsl:value-of select="@rhead"/>
+        </span>
+      </xsl:if>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:expan">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'expan'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:note|*:handwritten">
+  <xsl:variable name="position">
+    <xsl:choose>
+      <xsl:when test="empty(@position) and name() = 'note'"><xsl:value-of select="'foot'"/></xsl:when>
+      <xsl:when test="empty(@position) and name() = 'handwritten'"><xsl:value-of select="'margin'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="string(@position)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="type">
+    <xsl:choose>
+      <xsl:when test="name() = 'note'"><xsl:value-of select="'printed'"/></xsl:when>
+      <xsl:when test="name() = 'handwritten'"><xsl:value-of select="'handwritten'"/></xsl:when>
+      <xsl:otherwise></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
+  <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="concat('note ', $type, ' ', $position)"/></xsl:attribute>
+    <span class="noteSign">
+      <xsl:choose>
+        <xsl:when test="$position = 'foot'"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></xsl:when>
+        <xsl:otherwise><xsl:value-of select="$noteSign"/></xsl:otherwise>
+      </xsl:choose>
+    </span>
+    <xsl:if test="$position != 'foot'">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+        <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+        <xsl:apply-templates/>
+        <xsl:if test="$type = 'handwritten'">
+          <span>
+            <xsl:attribute name="class"><xsl:value-of select="'noteNumText'"/></xsl:attribute>
+            <xsl:value-of select="concat('[Handwritten note ', string(@number), ']')"/>
+          </span>
+        </xsl:if>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:emph">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'emph'"/></xsl:attribute>
+    <xsl:choose>
+      <xsl:when test="not(empty(@style))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="string(@style)"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:foreign">
+  <xsl:variable name="lang" select="@lang"/>
+  <xsl:variable name="xmllang" select="@xml:lang"/>
+  <xsl:variable name="language">
+    <xsl:choose>
+      <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
+      <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="$language = ''"><xsl:value-of select="'foreign'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat('foreign ', $language)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:q">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'q'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:quote">
+  <span class="quote">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:blockquote">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'blockquote'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:set-off">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'set-off'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:reg">
+  <span class="reg">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'reg'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:var">
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="empty(@type)"><xsl:value-of select="'var'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat('var ', string(@type))"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:num">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'num'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:gap">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
+    <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words  -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEchoSpan.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,112 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  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:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:mml="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms echo math mml svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="mode"></xsl:param>
+<xsl:param name="normalization"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:echo">
+  <span class="page">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:head|*:div|*:p|*:s|*:pb|*:cb|*:expan|*:emph|*:quote|*:q|*:blockquote|*:set-off|*:reg|*:var|*:num|*:gap|*:anchor|*:note|*:figure|*:caption|*:description|*:handwritten|*:place|*:person" mode="text">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="text"/>
+  </xsl:element>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*" mode="text">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="text"/>
+  </xsl:element>
+</xsl:template>
+
+<!-- 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="*:lb" mode="text">
+  <br/><xsl:apply-templates mode="text"/>
+</xsl:template>
+
+<!-- XHTML: remove the xhtml namespace   -->
+<xsl:template match="xhtml:*" mode="text">
+  <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
+  <xsl:variable name="isTable" select="name() = 'table'"/>
+  <xsl:choose>
+    <xsl:when test="(not($hasLabel)) or ($isTable and $hasLabel)">
+      <xsl:element name="{name()}" namespace="">
+        <xsl:copy-of select="@*"/>
+        <xsl:apply-templates mode="text"/>
+      </xsl:element>
+    </xsl:when>
+    <xsl:otherwise></xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+
+<!-- words  -->
+<xsl:template match="*:w" mode="text">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="formNotUrlEncoded" select="string(@form)"/>
+  <xsl:variable name="formRegularized" select="string(@formRegularized)"/>
+  <xsl:variable name="formNormalized" select="string(@formNormalized)"/>
+  <xsl:variable name="lemmas" select="string(@lemmas)"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$normalization = 'orig'"><xsl:apply-templates mode="text"/></xsl:when>
+      <xsl:when test="$normalization = 'reg' and $formRegularized = ''"><xsl:apply-templates mode="text"/></xsl:when>
+      <xsl:when test="$normalization = 'reg' and $formRegularized != ''"><xsl:sequence select="$formRegularized"/></xsl:when>
+      <xsl:when test="$normalization = 'norm'"><xsl:apply-templates mode="text"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates mode="text"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWord)"/>
+  <xsl:choose>
+    <xsl:when test="$dictionary = 'true' and $mode = 'tokenized'">
+      <span class="w">
+        <xsl:copy-of select="@*"/>
+        <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+        <xsl:sequence select="$displayWord"/>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:sequence select="$displayWord"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="text()" mode="text">
+  <xsl:value-of select="."/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageTei.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,686 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:TEI">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'TEI'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:expan|*:emph|*:q|*:quote|*:reg|*:num">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:teiHeader">
+  <!-- do nothing -->
+</xsl:template>
+
+<xsl:template match="*:text">
+  <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
+  <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
+  <xsl:variable name="textAncestors" select="./ancestor::*:text"/>
+  <xsl:variable name="bottomNotes" select="//*:note[contains(@place, 'foot') or empty(@place)]"/>
+  <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
+    <xsl:apply-templates/>
+    <xsl:if test="$contentStr = '' and empty($figures) and empty($textAncestors)">  <!-- test if div only contains empty nodes but no figures -->
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
+        <xsl:value-of select="'[Empty page]'"/>
+      </div>
+    </xsl:if>
+    <!--   Foot notes                      -->
+    <xsl:if test="$countBottomNotes > 0">
+      <div class="notes foot">
+        <xsl:for-each select="$bottomNotes">
+          <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+          <span>
+            <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+            <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+            <span>
+              <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+              <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+              <xsl:apply-templates/>
+            </span>
+          </span>
+        </xsl:for-each>
+      </div>
+    </xsl:if>
+  </div>
+  <!--   Dictionary                      -->
+  <xsl:if test="not(empty(//*:entry))">
+    <xsl:for-each select="//*:entry">
+      <xsl:sort select="*:form/*:orth"/>
+      <xsl:variable name="position" select="position()"/>
+      <span class="entry">
+        <xsl:apply-templates select="*:form"/>
+        <xsl:apply-templates select="*:sense"/>
+        <xsl:if test="not(empty(*:figure))">
+          <span class="entryDiv">
+            <span class="bf"><xsl:value-of select="'Figures: '"/></span>
+            <span class="entryDiv">
+              <xsl:for-each select="*:figure">
+                <xsl:variable name="href" select="*:graphic/@url"/>
+                <xsl:variable name="figDesc" select="string(*:figDesc)"/>
+                <xsl:if test="$href != ''">
+                  <div class="figure" style="margin-left:10px;">
+                    <a href="{$href}"><img alt="Figure: {$figDesc}" src="{$href}" width="200" height="200"/></a>
+                    <br/>
+                    <xsl:value-of select="'[Figure]: '"/><xsl:apply-templates select="*:head"/>
+                  </div>
+                </xsl:if>
+              </xsl:for-each>
+            </span>
+          </span>
+        </xsl:if>
+        <xsl:if test="not(empty(*:xr))">
+          <span class="entryDiv">
+            <span class="bf"><xsl:value-of select="'References: '"/></span>
+            <span class="entryDiv">
+              <xsl:for-each select="*:xr/*:ref">
+                <li><xsl:apply-templates select="."/></li>
+              </xsl:for-each>
+            </span>
+          </span>
+        </xsl:if>
+      </span>
+    </xsl:for-each>  
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number">
+    <xsl:choose>
+      <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="file">
+    <xsl:choose>
+      <xsl:when test="not(empty(@facs))"><xsl:value-of select="@facs"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <span class="figure">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:variable name="url">
+      <xsl:choose>
+        <xsl:when test="not(empty(@facs))"><xsl:value-of select="string(@facs)"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="string(graphic/@url)"/></xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="fileName" select="concat($echoFiguresDir, '/', $url)"/>
+    <xsl:variable name="digilibUrl">
+      <xsl:choose>
+        <xsl:when test="starts-with($url, 'http')"><xsl:value-of select="$url"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?fn=', $fileName)"/></xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="scalerUrl">
+      <xsl:choose>
+        <xsl:when test="starts-with($url, 'http')"><xsl:value-of select="$url"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <a href="{$digilibUrl}">
+      <img>
+        <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+      </img>
+    </a>
+    <xsl:if test="not(empty(@number))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
+          <xsl:value-of select="string(@number)"/>
+        </span>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
+          <xsl:value-of select="concat('[', 'Figure', ' ', string(@number), ']')"/>
+        </span>
+      </span>
+    </xsl:if>
+    <xsl:if test="not(empty(*:head))">
+      <span class="caption">
+        <xsl:for-each select="*:head">
+          <xsl:apply-templates/>
+        </xsl:for-each>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- segmentation   -->
+<xsl:template match="*:seg">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@rend = 'highlight'">
+        <xsl:attribute name="class"><xsl:value-of select="'seg highlight'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@rend = 'highlightPoint'">
+        <xsl:attribute name="class"><xsl:value-of select="'seg highlightPoint'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="class"><xsl:value-of select="'seg'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </span>
+</xsl:template>
+
+<!-- choice   -->
+<xsl:template match="*:choice">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'choice'"/></xsl:attribute>
+    <xsl:if test="not(empty(*:orig))">
+      <xsl:apply-templates select="*:orig"/>
+    </xsl:if>
+    <xsl:if test="not(empty(*:abbr))">
+      <xsl:apply-templates select="*:abbr"/>
+    </xsl:if>
+    <xsl:if test="not(empty(*:am))">
+      <xsl:apply-templates select="*:am"/>
+    </xsl:if>
+    <xsl:if test="not(empty(*:sic))">
+      <xsl:apply-templates select="*:sic"/>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- hi (highlighted)  -->
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="not(empty(@type)) and @type = 'elem'">
+      <div>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:when test="not(empty(@type)) and @type != 'elem'">
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:when>
+    <xsl:when test="@rend = 'initial'">
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="'initial'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:when>
+    <xsl:when test="@rend = 'bold'">
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="'bf'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- name (of type: place, person, ...)   -->
+<xsl:template match="*:name">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@type = 'place'">
+        <xsl:attribute name="class"><xsl:value-of select="'place'"/></xsl:attribute>
+        <xsl:attribute name="title"><xsl:value-of select="'Place'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@type = 'person'">
+        <xsl:attribute name="class"><xsl:value-of select="'person'"/></xsl:attribute>
+        <xsl:attribute name="title"><xsl:value-of select="'Person'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@type = 'org'">
+        <xsl:attribute name="class"><xsl:value-of select="'organization'"/></xsl:attribute>
+        <xsl:attribute name="title"><xsl:value-of select="'Organization'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="@type"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </span>
+</xsl:template>
+
+<!-- place, person, ...)   -->
+<xsl:template match="*:placeName">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'place'"/></xsl:attribute>
+    <xsl:attribute name="title"><xsl:value-of select="concat('Place: ', @type)"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+<xsl:template match="*:persName">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'person'"/></xsl:attribute>
+    <xsl:attribute name="title"><xsl:value-of select="'Person'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- term    -->
+<xsl:template match="*:term">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'term'"/></xsl:attribute>
+    <xsl:attribute name="title"><xsl:value-of select="'Terminology entry'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- line    -->
+<xsl:template match="*:lg">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lg'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:l">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'l'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+  <br/>
+</xsl:template>
+
+<!-- reference: sourounds it by parantheses so that it could be distinguished from word links within it  -->
+<xsl:template match="*:ref">
+  <xsl:variable name="refPos"><xsl:value-of select="count(./preceding::*:ref) + 1"/></xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'ref'"/></xsl:attribute>
+    <xsl:if test="not(empty(@target))">
+      <a class="ref">
+        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
+        <span class="super"><xsl:value-of select="concat('[', $refPos)"/></span>
+      </a>
+      <xsl:value-of select="' '"/>
+      <xsl:apply-templates/>
+      <xsl:value-of select="' '"/>
+      <a class="ref">
+        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
+        <span class="super"><xsl:value-of select="concat($refPos, ']')"/></span>
+      </a>
+    </xsl:if>
+    <xsl:if test="empty(@target)">
+      <xsl:apply-templates/>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- table    -->
+<xsl:template match="*:table">
+  <table>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(head))">
+      <caption align="top"><xsl:apply-templates select="*:head"/></caption>
+    </xsl:if>
+    <xsl:apply-templates select="*:row"/>
+  </table>
+</xsl:template>
+
+<xsl:template match="*:row">
+  <tr>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@role = 'label'">
+        <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@role = 'data' or empty(@role)">
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </tr>
+</xsl:template>
+
+<xsl:template match="*:cell">
+  <td>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@role = 'label' and empty(@cols)">
+        <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@role = 'label' and not(empty(@cols))">
+        <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
+        <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="(@role = 'data' or empty(@role)) and empty(@cols)">
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="(@role = 'data' or empty(@role)) and not(empty(@cols))">
+        <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </td>
+</xsl:template>
+
+<!-- dictionary    -->
+<xsl:template match="*:entry">
+  <!-- empty: handled in text tag    -->
+</xsl:template>
+
+<xsl:template match="*:form">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'form'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:orth">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'orth'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:sense">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'sense'"/></xsl:attribute>
+    <span class="entryDiv"><xsl:apply-templates select="*:def"/></span>
+    <span class="entryDiv"><xsl:apply-templates select="*:etym"/></span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:def">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'def'"/></xsl:attribute>
+    <span class="bf"><xsl:value-of select="'Definition: '"/></span>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:mentioned">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'mentioned'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:etym">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'etym'"/></xsl:attribute>
+    <span class="bf"><xsl:value-of select="'Etymology: '"/></span>
+    <span class="entryDiv">
+      <xsl:for-each select="*:cit">
+        <li><xsl:apply-templates select="*:quote"/><xsl:value-of select="' ('"/><xsl:apply-templates select="*:def"/><xsl:value-of select="')'"/></li>
+      </xsl:for-each>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:cit">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cit'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:note">
+  <xsl:variable name="position">
+    <xsl:choose>
+      <xsl:when test="empty(@place) and name() = 'note'"><xsl:value-of select="'foot'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="string(@place)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="type" select="'printed'"/>
+  <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
+  <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="concat('note ', $type, ' ', $position)"/></xsl:attribute>
+    <span class="noteSign">
+      <xsl:choose>
+        <xsl:when test="$position = 'foot'"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></xsl:when>
+        <xsl:otherwise><xsl:value-of select="$noteSign"/></xsl:otherwise>
+      </xsl:choose>
+    </span>
+    <xsl:if test="$position != 'foot'">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+        <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:foreign">
+  <xsl:variable name="xmllang" select="@xml:lang"/>
+  <xsl:variable name="language">
+    <xsl:choose>
+      <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:gap">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
+    <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words                            -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXhtml.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,240 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:saxon="http://saxon.sf.net/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs saxon dc dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<!-- the identity template -->
+<xsl:template match="@*|node()">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="*:html">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="*:body">
+  <!-- to set the xhtml namespace onto this dummy node -->
+  <page>
+    <xsl:apply-templates/>
+  </page>
+</xsl:template>
+
+<xsl:template match="*:expan|*:emph|*:q|*:quote|*:blockquote|*:set-off|*:reg|*:var|*:num|*:figure">
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:a">
+  <!-- empty element with only name attribute makes trouble -->
+  <xsl:variable name="name" select="@name"/>
+  <xsl:variable name="href" select="@href"/>
+  <xsl:choose>
+    <xsl:when test="not(empty($name)) and empty($href)">
+      <span>
+        <xsl:attribute name="id"><xsl:value-of select="$name"/></xsl:attribute>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <a class="ref">
+        <xsl:copy-of select="@*"/>
+        <xsl:apply-templates/>
+      </a>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <div>
+    <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number" select="count(./preceding::*:pb) + 1"/>
+  <xsl:variable name="file" select="$number"/>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+    </span>
+  </span>
+</xsl:template>
+
+<!--  MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:br">
+  <br>
+    <xsl:attribute name="class"><xsl:value-of select="'br'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:note">
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words                            -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXml.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<!-- transform to browser like xml display -->
+<xsl:template match="element()">
+  <xsl:variable name="elementName" select="name()"/>
+  <xsl:variable name="elementPresentation">
+    <xsl:choose>
+    <xsl:when test="element() = node() or text() != ''">
+      <xsl:value-of select="'&lt;'"/>
+      <span class="xml elementName"><xsl:value-of select="$elementName"/></span>
+      <xsl:apply-templates select="attribute()"/>
+      <xsl:value-of select="'&gt;'"/>
+      <xsl:apply-templates select="element()|text()|comment()|processing-instruction()"/>
+      <xsl:value-of select="'&lt;/'"/>
+      <span class="xml elementName"><xsl:value-of select="$elementName"/></span>
+      <xsl:value-of select="'&gt;'"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="'&lt;'"/>
+      <span class="xml elementName"><xsl:value-of select="$elementName"/></span>
+      <xsl:apply-templates select="attribute()"/>
+      <xsl:value-of select="'/&gt;'"/>
+    </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <ul class="xml element">
+    <xsl:sequence select="$elementPresentation"/>
+  </ul>
+</xsl:template>
+
+<xsl:template match="attribute()">
+  <xsl:variable name="attributeName" select="name()"/>
+  <span class="xml attributeName">
+    <xsl:value-of select="' '"/>
+    <xsl:value-of select="$attributeName"/>
+  </span>
+  <xsl:value-of select="'=&quot;'"/>
+  <span class="xml attributeValue"><xsl:value-of select="."/></span><xsl:value-of select="'&quot;'"/>
+</xsl:template>
+
+<xsl:template match="comment()">
+  <span class="xml comment">
+    <xsl:value-of select="'&lt;!-- '"/><xsl:value-of select="."/><xsl:value-of select="' --&gt;'"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="processing-instruction()">
+</xsl:template>
+
+<xsl:template match="*:w">
+  <xsl:apply-templates select="*:orig/node()"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/queryDocument.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+ 
+<xsl:param name="query"></xsl:param>
+<xsl:param name="flags"></xsl:param>
+<xsl:param name="outputFormat"></xsl:param>
+
+<xsl:variable name="apos">'</xsl:variable>
+<xsl:variable name="xpathQuery">
+  <xsl:choose>
+    <xsl:when test="$flags = ''"><xsl:value-of select="concat('//*:s[matches(.,', $apos, $query, $apos, ')]', '|', '//*:head[matches(.,', $apos, $query, $apos, ')]')"/></xsl:when>
+    <xsl:otherwise><xsl:value-of select="concat('//*:s[matches(.,', $apos, $query, $apos, ',', $apos, $flags, $apos, ')]', '|', '//*:head[matches(.,', $apos, $query, $apos, ',', $apos, $flags, $apos, ')]')"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+<xsl:variable name="queryResult" select="saxon:evaluate($xpathQuery)" xmlns:saxon="http://saxon.sf.net/"/>
+<xsl:variable name="queryResultSize"><xsl:value-of select="count($queryResult)"/></xsl:variable>
+<xsl:variable name="queryResultPageSize" select="20"/>
+<xsl:variable name="queryResultPages">
+  <xsl:choose>
+    <xsl:when test="$queryResultSize = 0"><xsl:value-of select="count($queryResult)"/></xsl:when>
+    <xsl:otherwise><xsl:value-of select="$queryResultSize idiv $queryResultPageSize + 1"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+<xsl:variable name="pageBreaks" select="saxon:evaluate('//*:pb')" xmlns:saxon="http://saxon.sf.net/"/>
+<xsl:variable name="queryResultHtml">
+<xsl:choose>
+  <xsl:when test="$outputFormat = 'html'">
+    <table>
+      <thead>
+        <tr>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">No.</button>
+          </th>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Path</button>
+          </th>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Hit</button>
+          </th>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Page</button>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <xsl:for-each select="$queryResult">
+          <xsl:variable name="hit" select="."/>
+          <tr>
+            <td align="left" valign="top"><xsl:value-of select="position()"/></td>
+            <td align="left" valign="top"><xsl:value-of select="saxon:path(.)" xmlns:saxon="http://saxon.sf.net/"/></td>
+            <td align="left" valign="top"><xsl:value-of select="."/></td>
+            <td align="left" valign="top"><xsl:value-of select="count(./preceding::*:pb)"/></td>     <!-- better performance: count($pageBreaks[. << $hit])  -->
+          </tr>
+        </xsl:for-each>    
+      </tbody>
+    </table>
+  </xsl:when>
+  <xsl:otherwise>
+    <result>
+      <query><xsl:value-of select="$query"/></query>
+      <flags><xsl:value-of select="$flags"/></flags>
+      <size><xsl:value-of select="$queryResultSize"/></size>
+      <page-size><xsl:value-of select="$queryResultPageSize"/></page-size>
+      <pages><xsl:value-of select="$queryResultPages"/></pages>
+      <pn>1</pn>
+      <hits>
+        <xsl:for-each select="$queryResult">
+          <xsl:variable name="hit" select="."/>
+          <hit>
+            <hitType><xsl:value-of select="'s'"/></hitType>
+            <pos><xsl:value-of select="position()"/></pos>
+            <pn><xsl:value-of select="count(./preceding::*:pb)"/></pn>
+            <hitId>xmlId</hitId>
+            <hitPos>4711</hitPos>
+            <hitString><xsl:value-of select="."/></hitString>
+            <hitSurroundsPB>false</hitSurroundsPB>
+          </hit>
+        </xsl:for-each>    
+      </hits>
+      <query-forms></query-forms>
+      <query-regularizations></query-regularizations>
+    </result>
+  </xsl:otherwise>
+</xsl:choose>
+</xsl:variable>
+<xsl:template match="/">
+  <xsl:sequence select="$queryResultHtml"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/replaceAnchor.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet 
+  version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xhtml"
+>
+
+<xsl:output method="xml" encoding="utf-8"/>
+
+<xsl:template match="@*|node()">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+<!-- insert figure number  -->
+<xsl:template match="*:figure">
+  <xsl:variable name="number" select="count(./preceding::*:figure) + 1"/>
+  <xsl:element name="{name()}" namespace="{namespace-uri()}"><!-- remove namespace in element and its subnodes  -->
+    <xsl:apply-templates select="@*"/>
+    <xsl:attribute name="number"><xsl:value-of select="$number"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- insert figure number  -->
+<xsl:template match="*:handwritten">
+  <xsl:variable name="number" select="count(./preceding::*:handwritten) + 1"/>
+  <xsl:element name="{name()}" namespace="{namespace-uri()}"><!-- remove namespace in element and its subnodes  -->
+    <xsl:apply-templates select="@*"/>
+    <xsl:attribute name="number"><xsl:value-of select="$number"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:anchor">
+  <xsl:variable name="type" select="@type"/>
+  <xsl:variable name="href" select="@xlink:href"/>
+  <xsl:choose>
+    <xsl:when test="$type = 'figure'">
+      <xsl:variable name="figure" select="//*:figure[@xlink:label = $href]"/>
+      <xsl:apply-templates select="$figure"/>
+    </xsl:when>
+    <xsl:when test="$type = 'handwritten'">
+      <xsl:variable name="handwritten" select="//*:handwritten[@xlink:label = $href]"/>
+      <xsl:apply-templates select="$handwritten"/>
+    </xsl:when>
+    <xsl:when test="$type = 'note'">
+      <xsl:variable name="note" select="//*:note[@xlink:label = $href]"/>
+      <xsl:sequence select="$note"/>
+    </xsl:when>
+    <xsl:when test="$type = 'table'">
+      <xsl:variable name="table" select="//xhtml:table[@xlink:label = $href]"/>
+      <xsl:sequence select="$table"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy>
+        <xsl:apply-templates select="@*|node()"/>
+      </xsl:copy>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- remove the anchored divs: div which contain a labeled figure, note, handwritten or table -->
+<xsl:template match="*:div">
+  <xsl:variable name="containingElems" select="*:figure|*:note|*:handwritten|xhtml:table"/>
+  <xsl:variable name="hasLabel" select="not(empty($containingElems[1]/@xlink:label))"/>
+  <xsl:choose>
+    <xsl:when test="$hasLabel"></xsl:when>
+    <xsl:otherwise>
+      <xsl:copy>
+        <xsl:apply-templates select="@*|node()"/>
+      </xsl:copy>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/toc.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,147 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet 
+  version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xhtml"
+>
+
+<xsl:output method="xml" encoding="utf-8" indent="yes"/>
+
+<xsl:template match="/">
+  <xsl:variable name="toc" select="//*:div[@type = 'section' or @type = 'chapter' or @type = 'part']"/>
+  <xsl:variable name="figures" select="//*:figure"/>
+  <xsl:variable name="notes" select="//*:note|//*:handwritten"/>
+  <xsl:variable name="pages" select="//*:pb"/>
+  <xsl:variable name="places" select="//*:place"/>
+  <list>
+    <xsl:if test="not(empty($toc))">
+      <list type ="toc">
+        <xsl:attribute name="count"><xsl:value-of select="count($toc)"/></xsl:attribute>
+        <head>Table of contents</head>
+        <xsl:apply-templates select="$toc"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($figures))">
+      <list type="figures">
+        <xsl:attribute name="count"><xsl:value-of select="count($figures)"/></xsl:attribute>
+        <head>Figures</head>
+        <xsl:apply-templates select="$figures"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($notes))">
+      <list type="notes">
+        <xsl:attribute name="count"><xsl:value-of select="count($notes)"/></xsl:attribute>
+        <head>Notes</head>
+        <xsl:apply-templates select="$notes"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($pages))">
+      <list type="pages">
+        <xsl:attribute name="count"><xsl:value-of select="count($pages)"/></xsl:attribute>
+        <head>Pages</head>
+        <xsl:apply-templates select="$pages"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($places))">
+      <list type="places">
+        <xsl:attribute name="count"><xsl:value-of select="count($places)"/></xsl:attribute>
+        <head>Places</head>
+        <xsl:apply-templates select="$places"/>
+      </list>
+    </xsl:if>
+  </list>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <xsl:variable name="number" select="@number"/>
+  <item>
+    <xsl:if test="not(empty($number))"><xsl:attribute name="n"><xsl:value-of select="$number"/></xsl:attribute></xsl:if>
+    <xsl:apply-templates select="*:caption"/>
+    <xsl:apply-templates select="*:description"/>
+    <xsl:apply-templates select="*:variables"/>
+    <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:caption"><xsl:value-of select="' '"/>
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="*:description">
+  <xsl:apply-templates/><xsl:value-of select="' '"/>
+</xsl:template>
+
+<xsl:template match="*:variables">
+  <xsl:apply-templates/><xsl:value-of select="' '"/>
+</xsl:template>
+
+<xsl:template match="*:note|*:handwritten">
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <xsl:variable name="number" select="@number"/>
+  <xsl:variable name="position" select="@position"/>
+  <xsl:variable name="type">
+    <xsl:choose>
+      <xsl:when test="name() = 'note'"><xsl:value-of select="'printed'"/></xsl:when>
+      <xsl:when test="name() = 'handwritten'"><xsl:value-of select="'handwritten'"/></xsl:when>
+      <xsl:otherwise></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <item>
+    <xsl:if test="not(empty($type))"><xsl:attribute name="type"><xsl:value-of select="$type"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($position))"><xsl:attribute name="position"><xsl:value-of select="$position"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($number))"><xsl:attribute name="n"><xsl:value-of select="$number"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:place">
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <xsl:variable name="id" select="@id"/>
+  <item>
+    <xsl:if test="not(empty($id))"><xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute></xsl:if>
+    <content><xsl:apply-templates/></content>
+    <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:variable name="level"><xsl:number level="multiple" count="*:div[@type = 'section' or @type = 'chapter' or @type = 'part']" format="1."/></xsl:variable>
+  <xsl:variable name="depth" select="string-length(replace($level, '[^\\.]', ''))"/>
+  <xsl:variable name="pb" select="./preceding::*:pb[1]"/>
+  <xsl:variable name="o" select="$pb/@o"/>
+  <xsl:variable name="oNorm" select="$pb/@o-norm"/>
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <item>
+    <xsl:if test="not(empty($level))"><xsl:attribute name="n"><xsl:value-of select="$level"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($level))"><xsl:attribute name="lv"><xsl:value-of select="$depth"/></xsl:attribute></xsl:if>
+    <xsl:apply-templates select="*:head"/>
+    <xsl:if test="not(empty($page))">
+      <ref>
+        <xsl:if test="not(empty($o))"><xsl:attribute name="o"><xsl:value-of select="$o"/></xsl:attribute></xsl:if>
+        <xsl:if test="not(empty($oNorm))"><xsl:attribute name="o-norm"><xsl:value-of select="$oNorm"/></xsl:attribute></xsl:if>
+        <xsl:value-of select="$page"/>
+      </ref>
+    </xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <xsl:apply-templates/><xsl:value-of select="' '"/>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="page" select="count(./preceding::*:pb) + 1"/>
+  <item>
+    <xsl:attribute name="n"><xsl:value-of select="$page"/></xsl:attribute>
+    <xsl:if test="not(empty(@o))"><xsl:attribute name="o"><xsl:value-of select="@o"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(@o-norm))"><xsl:attribute name="o-norm"><xsl:value-of select="@o-norm"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(@file))"><xsl:attribute name="file"><xsl:value-of select="@file"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(@facs))"><xsl:attribute name="file"><xsl:value-of select="@facs"/></xsl:attribute></xsl:if>
+  </item>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/tocHtml.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet 
+  version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="type"></xsl:param>
+
+<xsl:template match="/">
+  <xsl:apply-templates select="//*:list[@type = $type]/head"/>
+  <xsl:apply-templates select="//*:list[@type = $type]/item"/>
+</xsl:template>
+
+<xsl:template match="*:item">
+  <xsl:variable name="n" select="@n"/>
+  <xsl:variable name="level" select="@lv"/>
+  <div>
+    <xsl:attribute name="class"><xsl:value-of select="'item'"/></xsl:attribute>
+    <xsl:value-of select="concat($n, ' ')"/>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:ref">
+  <xsl:variable name="o" select="@o"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="'ref'"/></xsl:attribute>
+    <xsl:value-of select="'Page: '"/>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/transform/tocOut.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet 
+  version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+<xsl:output method="xhtml"/>
+
+<xsl:param name="type"></xsl:param>
+<xsl:param name="outputFormat"></xsl:param>
+
+<xsl:template match="/">
+  <xsl:choose>
+    <xsl:when test="$outputFormat = 'html'">
+      <xsl:apply-templates select="//*:list[@type = $type]/item" mode="html"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:sequence select="//*:list[@type = $type]"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*:item" mode="html">
+  <xsl:variable name="n" select="@n"/>
+  <xsl:variable name="level" select="@lv"/>
+  <div>
+    <xsl:attribute name="class"><xsl:value-of select="'tocItem'"/></xsl:attribute>
+    <xsl:value-of select="concat($n, ' ')"/>
+    <xsl:apply-templates mode="html"/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:ref" mode="html">
+  <xsl:variable name="pageOrig" select="@o"/>
+  <xsl:variable name="page" select="text()"/>
+  <xsl:variable name="pageHref" select="concat('#page', $page)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="'tocPageRef'"/></xsl:attribute>
+    <xsl:value-of select="'Page: '"/>
+    <a href="{$pageHref}"><xsl:apply-templates mode="html"/></a>
+  </span>
+</xsl:template>
+
+</xsl:stylesheet>
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/cms/translator/MicrosoftTranslator.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/build/classes/de/mpg/mpiwg/berlin/mpdl/exception/ApplicationException.class has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/dist/mpiwg-mpdl-cms.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-codec-1.3.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-collections-3.2.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-collections-LICENSE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-collections-NOTICE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+Apache Commons Collections
+Copyright 2001-2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-httpclient-3.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-httpclient-LICENSE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,176 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-httpclient-NOTICE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+Apache Jakarta HttpClient
+Copyright 1999-2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-io-2.0.1.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-lang3-3.0.1.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-logging-1.1.1.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-logging-LICENSE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/lib/commons-logging-NOTICE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,6 @@
+Apache Commons Logging
+Copyright 2003-2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/core-renderer.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/httpclient-4.1.2.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/httpcore-4.1.2.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/iText-2.0.8.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/json_simple-1.1.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-core-3.5.0-javadoc.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-core-3.5.0-sources.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-core-3.5.0.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-highlighter-3.5.0-javadoc.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-highlighter-3.5.0.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-memory-3.5.0.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/lucene-queries-3.5.0.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/microsoft-translator-java-api-0.4.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/mpiwg-mpdl-lt.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/mpiwg-mpdl-xml.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/quartz-1.6.5.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/lib/quartz-LICENSE.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/lib/saxon.txt	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,3 @@
+Saxon:
+
+Release 9.1.0.5 (free version): releases < 9.1.0.7 support saxon extension functions
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/saxon9-dom.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/saxon9-s9api.jar has changed
Binary file software/mpdl-services-new/mpiwg-mpdl-cms/lib/saxon9.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/constants.properties	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,5 @@
+dataDir=/Users/jwillenborg/mpdl/data/lt
+documentsDir=/Users/jwillenborg/mpdl/data/xml/documents
+luceneDocumentsDir=/Users/jwillenborg/mpdl/data/xml/lucene/documents
+luceneNodesDir=/Users/jwillenborg/mpdl/data/xml/lucene/nodes
+confDir=/Users/jwillenborg/mpdl/data/collectionConfs
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/CollectionReader.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,122 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.confmanager;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.general.Constants;
+import de.mpg.mpiwg.berlin.mpdl.cms.harvester.PathExtractor;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+public class CollectionReader {
+
+  ConfManagerResultWrapper cmrw;
+  private HashMap<String, ConfManagerResultWrapper> wrapperContainer;
+  private static CollectionReader collectionReader;
+
+  private CollectionReader() {
+    wrapperContainer = new HashMap<String, ConfManagerResultWrapper>();
+    readConfFiles();
+  }
+
+  public static CollectionReader getInstance() {
+    if (collectionReader == null)
+      collectionReader = new CollectionReader();
+    return collectionReader;
+  }
+
+  private void readConfFiles(){
+    System.out.println("---------------");
+    System.out.println("reading configuration files...");
+
+    // holt alle konfiguratiuonsdateien aus dem konf-Ordner
+    PathExtractor ext = new PathExtractor();
+    List<String> configsList = ext.extractPathLocally(Constants.getInstance().getConfDir());
+    System.out.println("Anzahl der konfugirationsdateien : " + configsList.size());
+    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+    // docFactory.setNamespaceAware(true);
+    DocumentBuilder builder = null;
+
+    File configFile = null;
+    for (String configXml : configsList) {
+      System.out.println("reading : " + configXml);
+      try {
+        builder = docFactory.newDocumentBuilder();
+      } catch (ParserConfigurationException e) {
+        e.printStackTrace();
+      }
+      configFile = new File(configXml);
+      Document document = null;
+        try {
+          document = builder.parse(configFile);
+        } catch (SAXException e) {
+          e.printStackTrace();
+        } catch (IOException e) {
+          e.printStackTrace();
+        }
+        cmrw = new ConfManagerResultWrapper();
+
+        NodeList idlist = document.getElementsByTagName("collectionId");
+        // darf jeweils nur ein node enthalten sein
+        Node idNode = idlist.item(0);
+        if(idNode != null){
+          if (!idNode.getTextContent().equals("")) {
+            cmrw.setCollectionId(idNode.getTextContent());
+          }
+        }
+        NodeList nodeliste = document.getElementsByTagName("mainLanguage");
+        // darf jeweils nur ein node enthalten sein
+        Node langNode = nodeliste.item(0);
+        if(langNode != null){
+          if (!langNode.getTextContent().equals("")) {
+            cmrw.setMainLanguage(langNode.getTextContent());
+          }
+        }
+        NodeList collNamelist = document.getElementsByTagName("name");
+        // darf jeweils nur ein node enthalten sein
+        Node nameNode = collNamelist.item(0);
+        if(nameNode != null){
+          if (!nameNode.getTextContent().equals("")) {
+            cmrw.setCollectionName(nameNode.getTextContent());
+          }
+        }
+        
+        NodeList fieldNodes = document.getElementsByTagName("field");
+        ArrayList<String> fields = new ArrayList<String>();
+        fields = new ArrayList<String>();
+        if(fieldNodes != null){
+          for (int i = 0; i < fieldNodes.getLength(); i++) {
+            if (!fieldNodes.item(i).getTextContent().equals("")) {
+              fields.add((fieldNodes.item(i).getTextContent().trim()));
+            }
+          }
+        }
+        cmrw.setFields(fields);
+
+        NodeList nodeli = document.getElementsByTagName("collectionDataUrl");
+        Node dataNode = nodeli.item(0);
+        if(dataNode != null){
+          if (!dataNode.getTextContent().trim().equals("")) {
+            cmrw.setCollectionDataUrl(dataNode.getTextContent());
+          }
+        }
+        
+        wrapperContainer.put(cmrw.getCollectionId(), cmrw);
+    }
+  }
+
+  public ConfManagerResultWrapper getResultWrapper(String collectionId) {
+    ConfManagerResultWrapper cmrw = wrapperContainer.get(collectionId);
+    return cmrw;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManager.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,139 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.confmanager;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPathExpressionException;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.harvester.PathExtractor;
+
+import de.mpg.mpiwg.berlin.mpdl.xml.xquery.XQueryEvaluator;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.general.Constants;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+public class ConfManager {
+  private ConfManagerResultWrapper cmrw;
+  private HashMap<String, ConfManagerResultWrapper> wrapperContainer;
+  private static ConfManager confManager;
+
+  private ConfManager() {
+    wrapperContainer = new HashMap<String, ConfManagerResultWrapper>();
+    try {
+      checkCollectionConfFiles();
+    } catch (XPathExpressionException e) {
+      e.printStackTrace();
+    }
+  }
+
+  public static ConfManager getInstance(){
+    if(confManager == null)
+      confManager = new ConfManager();
+    return confManager;
+  }
+  
+  /**
+   * checks if an update of a project is necessary by checking configuration
+   * file
+   * 
+   * @throws XPathExpressionException
+   */
+  private void checkCollectionConfFiles() throws XPathExpressionException {
+    System.out.println("---------------");
+    System.out.println("checking configuration files...");
+    // holt alle Konfiguratiuonsdateien aus dem konf-Ordner
+    PathExtractor ext = new PathExtractor();
+    List<String> configsList = ext.extractPathLocally(Constants.getInstance().getConfDir());
+    System.out.println("Anzahl der Konfigurationsdateien : " + configsList.size());
+    try {
+      File configFile = null;
+      // Ueberprueft alle Konf-dateien auf update und fuehrt es bei Bedarf aus
+      for (String configXml : configsList) {
+        System.out.println("checking : " + configXml);
+        XQueryEvaluator xQueryEvaluator = new XQueryEvaluator();
+        configFile = new File(configXml);
+        URL srcUrl = configFile.toURI().toURL();
+        String update = xQueryEvaluator.evaluateAsString(srcUrl, "//collection/update/text()");
+        if (update != null && update.equals("true")) {
+          System.out.println("update tag is set on : " + update);
+          cmrw = new ConfManagerResultWrapper();
+          String collectionId = xQueryEvaluator.evaluateAsString(srcUrl, "//collectionId/text()");
+          if (collectionId != null) {
+            cmrw.setCollectionId(collectionId);
+          }
+          String mainLanguage = xQueryEvaluator.evaluateAsString(srcUrl, "//mainLanguage/text()");
+          if (mainLanguage != null) {
+            cmrw.setMainLanguage(mainLanguage);
+          }
+          String name = xQueryEvaluator.evaluateAsString(srcUrl, "//name/text()");
+          if (name != null) {
+            cmrw.setCollectionName(name);
+          }
+          String fieldsStr = xQueryEvaluator.evaluateAsStringValueJoined(srcUrl, "//field");
+          ArrayList<String> fields = new ArrayList<String>();
+          if (fields != null) {
+            fieldsStr = fieldsStr.trim();
+            String[] fieldsArray = fieldsStr.split(" ");
+            for (int i=0; i<fieldsArray.length; i++) {
+              String field = fieldsArray[i];
+              fields.add(field);
+            }
+            cmrw.setFields(fields);
+          }
+          String collectionDataUrl = xQueryEvaluator.evaluateAsString(srcUrl, "//specifyUrl/collectionDataUrl/text()");
+          if (collectionDataUrl != null) {
+            cmrw.setCollectionDataUrl(collectionDataUrl);
+            String excludesStr = xQueryEvaluator.evaluateAsStringValueJoined(srcUrl, "//specifyUrl/exclude");
+            if(collectionDataUrl.endsWith("/"))
+              extractUrlsFromCollections(collectionDataUrl, cmrw, excludesStr);
+            else{
+              List<String> collectionUrls = new ArrayList<String>();
+              collectionUrls.add(collectionDataUrl);
+              cmrw.setCollectionUrls(collectionUrls);
+            }
+            // flag im Konfigurations-File auf false setzen durch serialisierung in das File
+            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder = docFactory.newDocumentBuilder();
+            Document configFileDocument = builder.parse(configFile);
+            NodeList updateNodeList = configFileDocument.getElementsByTagName("update");
+            Node n = updateNodeList.item(0);
+            n.setTextContent("false");
+            FileOutputStream os = new FileOutputStream(configFile);
+            XMLSerializer ser = new XMLSerializer(os, null);
+            ser.serialize(configFileDocument);  //  Vorsicht: wenn es auf true ist: es wird alles neu indexiert
+          }
+          wrapperContainer.put(collectionId, cmrw);
+        }
+      }
+    } catch(Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  /**
+   * der Extractor holt alle Projekt zugehoerigen Urls
+   */
+  private void extractUrlsFromCollections(String collectionDataUrl, ConfManagerResultWrapper cmrw, String excludesStr) {
+    System.out.println("collecting urls of resources that need update...");
+    if(!collectionDataUrl.equals("")){
+      PathExtractor extractor = new PathExtractor();
+      List<String> collectionUrls = extractor.initExtractor(collectionDataUrl, excludesStr);
+      cmrw.setCollectionUrls(collectionUrls);
+    }
+  }
+
+  public ConfManagerResultWrapper getResultWrapper(String collectionId) {
+    ConfManagerResultWrapper cmrw = wrapperContainer.get(collectionId);
+    return cmrw;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/confmanager/ConfManagerResultWrapper.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,93 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.confmanager;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ConfManagerResultWrapper {
+
+  private List<String> collectionUrls;
+  private String collectionId;
+  private String collectionName;
+  private String collectionDataUrl;
+  private String mainLanguage;
+  private ArrayList<String> fields;
+  private List<String> formats;
+  private List<String> excludeField;
+
+  
+  public ConfManagerResultWrapper(){
+    collectionUrls = new ArrayList<String>();
+    collectionId = "";
+    collectionName = "";
+    collectionDataUrl = "";
+    mainLanguage = "";
+    fields = new ArrayList<String>();
+    formats = new ArrayList<String>();
+    excludeField = new ArrayList<String>();
+  }
+  
+  public List<String> getCollectionUrls() {
+    return collectionUrls;
+  }
+
+  public String getCollectionId() {
+    return collectionId;
+  }
+
+  public String getCollectionName() {
+    return collectionName;
+  }
+
+  public void setCollectionId(String collectionId){
+    this.collectionId = collectionId;
+  }
+  
+  public void setCollectionUrls(List<String> collectionUrls){
+    this.collectionUrls = collectionUrls;
+  }
+
+  public void setCollectionName(String collectionName) {
+    this.collectionName = collectionName;
+  }
+
+  public String getCollectiondataUrl() {
+    return collectionDataUrl;
+  }
+
+  public void setCollectionDataUrl(String collectiondataUrl) {
+    this.collectionDataUrl = collectiondataUrl;
+  }
+
+  public List<String> getFormats() {
+    return formats;
+  }
+
+  public void setFormats(List<String> formats) {
+    this.formats = formats;
+  }
+
+  public List<String> getExcludeField() {
+    return excludeField;
+  }
+
+  public void setExcludeField(List<String> excludeField) {
+    this.excludeField = excludeField;
+  }
+  
+  public String getMainLanguage() {
+    return mainLanguage;
+  }
+
+  public void setMainLanguage(String mainLanguage) {
+    this.mainLanguage = mainLanguage;
+  }
+
+  public ArrayList<String> getFields() {
+    return fields;
+  }
+
+  public void setFields(ArrayList<String> fields) {
+    this.fields = fields;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/Document.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,38 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.document;
+
+import java.util.ArrayList;
+
+import org.apache.lucene.document.Fieldable;
+
+public class Document {
+  private org.apache.lucene.document.Document document;
+  private ArrayList<String> hitFragments;
+  
+  public Document(org.apache.lucene.document.Document luceneDocument) {
+    this.document = luceneDocument;
+  }
+
+  public org.apache.lucene.document.Document getDocument() {
+    return document;
+  }
+
+  public Fieldable getFieldable(String field) {
+    if (document != null)
+      return document.getFieldable(field);
+    else 
+      return null;
+  }
+  
+  public void setDocument(org.apache.lucene.document.Document document) {
+    this.document = document;
+  }
+
+  public ArrayList<String> getHitFragments() {
+    return hitFragments;
+  }
+
+  public void setHitFragments(ArrayList<String> hitFragments) {
+    this.hitFragments = hitFragments;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/DocumentHandler.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,927 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.document;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import net.sf.saxon.s9api.Axis;
+import net.sf.saxon.s9api.QName;
+import net.sf.saxon.s9api.XdmNode;
+import net.sf.saxon.s9api.XdmNodeKind;
+import net.sf.saxon.s9api.XdmSequenceIterator;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.io.FileUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import com.sun.org.apache.xerces.internal.parsers.SAXParser;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.lt.general.Language;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.WordContentHandler;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.XmlTokenizer;
+import de.mpg.mpiwg.berlin.mpdl.util.StringUtils;
+import de.mpg.mpiwg.berlin.mpdl.util.Util;
+import de.mpg.mpiwg.berlin.mpdl.xml.xquery.XQueryEvaluator;
+import de.mpg.mpiwg.berlin.mpdl.cms.general.Constants;
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.scheduler.CmsDocOperation;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.GetFragmentsContentHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.PageTransformer;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.XslResourceTransformer;
+
+/**
+ * Handler for documents (singleton). 
+ */
+public class DocumentHandler {
+  private static Logger LOGGER = Logger.getLogger(DocumentHandler.class.getName()); 
+  private static List<String> EXCLUDED_PROJECT_DOCS = 
+    Arrays.asList("/echo/zh/Min_chan_luyi_1_7MCGW0WG.xml", // the Saxon transfomer has heavy problems with some characters in CJK Unified Ideographs Extension B, e.g.: line 309 (second reg on page 16)
+     "/echo/zh/Min_chan_luyi_2_U7Y9NQ9V.xml", 
+     "/echo/zh/Min_chan_luyi_3_2FP9M172.xml", 
+     "/echo/zh/Min_chan_luyi_4_FXA6FSFH.xml",
+     "/echo/zh/Min_chan_luyi_5_VG6NY5XD.xml",
+     "/echo/zh/Xifa_shenji.xml",
+     "/echo/zh/Yulei_tushuo_1_HXX4MGZW.xml",
+     "/echo/zh/Yulei_tushuo_2_FN1CTY5C.xml");
+  private long beginOfOperation;
+  private long endOfOperation;
+  
+  public void doOperation(CmsDocOperation docOperation) throws ApplicationException {
+    String operationName = docOperation.getName();  
+    if (operationName.equals("create")) {
+      create(docOperation);
+    } else if (operationName.equals("delete")) {
+      delete(docOperation);
+    } else if (operationName.equals("importDirectory")) {
+      importDirectory(docOperation);
+    } else if (operationName.equals("createPdf")) {
+      createPdf(docOperation);
+    } else if (operationName.equals("createAllPdfInDirectory")) {
+      createAllPdfInDirectory(docOperation);
+    }
+  }
+  
+  private void importDirectory(CmsDocOperation docOperation) throws ApplicationException {
+    try {
+      LOGGER.info("Start of DocumentHandler. This operation could be time consuming because documents are indexed (normal indexing times are 1-10 minutes for a document)");
+      beginOperation();
+      String localDocumentsUrlStr = docOperation.getSrcUrl(); // start directory: file:/a/local/directory
+      String collectionNames = docOperation.getCollectionNames();  // e.g. "echo"
+      File localDocumentsDir = new File(new URI(localDocumentsUrlStr));
+      boolean docDirExists = localDocumentsDir.exists();
+      if (! docDirExists) 
+        throw new ApplicationException("Document directory:" + localDocumentsUrlStr + " does not exists. Please use a directory that exists and perform the operation again.");
+      String[] fileExtensions = {"xml"};
+      Iterator<File> iterFiles = FileUtils.iterateFiles(localDocumentsDir, fileExtensions, true);
+      int i = 0;
+      while(iterFiles.hasNext()) {
+        i++;
+        File xmlFile = iterFiles.next();
+        String xmlFileStr = xmlFile.getPath();
+        int relativePos = (int) localDocumentsDir.getPath().length();
+        String docId = xmlFileStr.substring(relativePos);  // relative path name starting from localDocumentsDir, e.g. /tei/de/Test_1789.xml
+        String xmlFileUrlStr = xmlFile.toURI().toURL().toString();
+        CmsDocOperation createDocOperation = new CmsDocOperation("create", xmlFileUrlStr, null, docId);
+        createDocOperation.setCollectionNames(collectionNames);
+        try {
+          doOperation(createDocOperation);
+          Date now = new Date();
+          LOGGER.info("Document " + i + ": " + docId + " successfully imported (" + now.toString() + ")");
+        } catch (Exception e) {
+          LOGGER.info("Document " + i + ": " + docId + " has problems:");
+          e.printStackTrace();
+        }
+      }
+      endOperation();
+      LOGGER.info("The DocumentHandler needed: " + (endOfOperation - beginOfOperation) + " ms" );
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  private void createAllPdfInDirectory(CmsDocOperation docOperation) throws ApplicationException {
+    try {
+      LOGGER.info("Start of generating Pdf-Documents. This operation could be time consuming because Pdf generation needs some time.");
+      beginOperation();
+      String localDocumentsUrlStr = docOperation.getSrcUrl(); // start directory: file:/a/local/directory
+      String collectionNames = docOperation.getCollectionNames();  // e.g. "echo"
+      File localDocumentsDir = new File(new URI(localDocumentsUrlStr));
+      boolean docDirExists = localDocumentsDir.exists();
+      if (! docDirExists) 
+        throw new ApplicationException("Document directory:" + localDocumentsUrlStr + " does not exists. Please use a directory that exists and perform the operation again.");
+      String[] fileExtensions = {"xml"};
+      Iterator<File> iterFiles = FileUtils.iterateFiles(localDocumentsDir, fileExtensions, true);
+      int i = 0;
+      while(iterFiles.hasNext()) {
+        i++;
+        File xmlFile = iterFiles.next();
+        String xmlFileStr = xmlFile.getPath();
+        int relativePos = (int) localDocumentsDir.getPath().length();
+        String docId = xmlFileStr.substring(relativePos);  // relative path name starting from localDocumentsDir, e.g. /tei/de/Test_1789.xml
+        CmsDocOperation createPdfOperation = new CmsDocOperation("createPdf", null, null, docId);
+        createPdfOperation.setCollectionNames(collectionNames);
+        try {
+          doOperation(createPdfOperation);
+          Date now = new Date();
+          LOGGER.info("Pdf document " + i + ": " + docId + " successfully created (" + now.toString() + ")");
+        } catch (Exception e) {
+          LOGGER.info("Pdf document " + i + ": " + docId + " has problems:");
+          e.printStackTrace();
+        }
+      }
+      endOperation();
+      LOGGER.info("The Pdf generation needed: " + (endOfOperation - beginOfOperation) + " ms" );
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  private boolean isProjectDoc(String docId) {
+    boolean isProjectDoc = true;
+    if (EXCLUDED_PROJECT_DOCS.contains(docId)) 
+      return false;
+    return isProjectDoc;
+  }
+  
+  private void create(CmsDocOperation docOperation) throws ApplicationException {
+    try {
+      String operationName = docOperation.getName();  
+      String srcUrlStr = docOperation.getSrcUrl(); 
+      String docId = docOperation.getDocIdentifier();
+      if (! isProjectDoc(docId)) {
+        LOGGER.info("Operation: " + operationName + " not performed on: " + docId + ". Cause: document is excluded as project doc");
+        return;
+      }
+      String mainLanguage = docOperation.getMainLanguage();
+      if (mainLanguage == null) {
+        mainLanguage = getMainLanguage(docId);
+      }
+      String[] elementNames = docOperation.getElementNames();
+      if (elementNames == null) {
+        String[] defaultElementNames = {"s", "head", "caption", "variables", "description"};
+        docOperation.setElementNames(defaultElementNames); // default
+      }
+      String docDirName = getDocDir(docId);
+      String docDestFileName = getDocFullFileName(docId); 
+      URL srcUrl = null;
+      String protocol = null;
+      if (srcUrlStr != null && ! srcUrlStr.equals("empty")) {
+        srcUrl = new URL(srcUrlStr);
+        protocol = srcUrl.getProtocol();
+      }
+      File docDestFile = new File(docDestFileName);
+      // parse validation on file
+      XQueryEvaluator xQueryEvaluator = new XQueryEvaluator();
+      XdmNode docNode = xQueryEvaluator.parse(srcUrl); // if it is not parseable an exception with a detail message is thrown 
+      String docType = getNodeType(docNode);  // archimedes, echo, TEI, html ... 
+      docType = docType.trim();
+      if (docType == null) {
+        docOperation.setErrorMessage("file type of: " + srcUrlStr + "is not supported");
+        return;
+      }
+      // perform operation on file system
+      if (protocol.equals("file")) {
+        docOperation.setStatus("upload file: " + srcUrlStr + " to CMS");
+      } else {
+        docOperation.setStatus("download file from: " + srcUrlStr + " to CMS");
+      }
+      FileUtils.copyURLToFile(srcUrl, docDestFile, 100000, 100000);
+
+      // replace anchor in echo documents and also add the number attribute to figures
+      String docDestFileNameUpgrade = docDestFileName + ".upgrade";
+      File docDestFileUpgrade = new File(docDestFileNameUpgrade);
+      XslResourceTransformer replaceAnchorTransformer = new XslResourceTransformer("replaceAnchor.xsl");
+      String docDestFileUrlStr = docDestFile.getPath();
+      String result = replaceAnchorTransformer.transform(docDestFileUrlStr);
+      FileUtils.writeStringToFile(docDestFileUpgrade, result, "utf-8");
+      
+      MetadataRecord mdRecord = new MetadataRecord();
+      mdRecord.setDocId(docId);
+      mdRecord.setCollectionNames(docOperation.getCollectionNames());
+      mdRecord.setType("text/xml");
+
+      // generate toc file (toc, figure, handwritten)
+      XslResourceTransformer tocTransformer = new XslResourceTransformer("toc.xsl");
+      File tocFile = new File(docDirName + "/toc.xml");
+      String tocResult = tocTransformer.transform(docDestFileNameUpgrade);
+      FileUtils.writeStringToFile(tocFile, tocResult, "utf-8");
+
+      // Get metadata info of the xml document
+      docOperation.setStatus("extract metadata of: " + srcUrlStr + " to CMS");
+      XQueryEvaluator xQueryEvaluator2 = new XQueryEvaluator();
+      mdRecord = getMetadataRecord(docDestFileUpgrade, docType, mdRecord, xQueryEvaluator2);
+      String mdRecordLanguage = mdRecord.getLanguage();
+      if (mdRecordLanguage == null && mainLanguage != null)
+        mdRecord.setLanguage(mainLanguage);
+      
+      // save all pages as single xml files (untokenized and tokenized)
+      docOperation.setStatus("extract page fragments of: " + srcUrlStr + " to CMS");
+      File docDir = new File(docDirName + "/pages");
+      FileUtils.deleteQuietly(docDir);  // first delete pages directory
+      Hashtable<Integer, StringBuilder> pageFragments = getFragments(docDestFileNameUpgrade, "pb");
+      int pageCount = pageFragments.size();
+      if (pageCount == 0) {
+        // no pb element is found: then the whole document is the first page
+        String docXmlStr = FileUtils.readFileToString(docDestFileUpgrade, "utf-8");
+        docXmlStr = docXmlStr.replaceAll("<\\?xml.*?\\?>", "");  // remove the xml declaration if it exists
+        pageFragments = new Hashtable<Integer, StringBuilder>();
+        pageFragments.put(new Integer(1), new StringBuilder(docXmlStr));
+        pageCount = 1;
+      }
+      PageTransformer pageTransformer = new PageTransformer();
+      for (int page=1; page<=pageCount; page++) {
+        String fragment = pageFragments.get(new Integer(page)).toString();
+        fragment = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + fragment;
+        String docPageFileName = docDirName + "/pages/page-" + page + ".xml";
+        File docPageFile = new File(docPageFileName);
+        FileUtils.writeStringToFile(docPageFile, fragment, "utf-8");
+        String language = mdRecord.getLanguage();
+        String tokenizedXmlStr = tokenizeWithLemmas(fragment, language);  // xml fragment enriched with <w> elements
+        tokenizedXmlStr = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + tokenizedXmlStr;
+        tokenizedXmlStr = enrichWordsOrigRegNorm(tokenizedXmlStr);  // xml string: enrich <w> elements with normalization info (orig, reg, norm)
+        String docPageTokenizedFileName = docDirName + "/pages/page-" + page + "-morph.xml";
+        File docPageTokenizedFile = new File(docPageTokenizedFileName);
+        FileUtils.writeStringToFile(docPageTokenizedFile, tokenizedXmlStr, "utf-8");
+        String docPageHtmlFileName = docDirName + "/pages/page-" + page + ".html";
+        File docPageHtmlFile = new File(docPageHtmlFileName);
+        String htmlStr = pageTransformer.transform(tokenizedXmlStr, mdRecord, page, "html");
+        FileUtils.writeStringToFile(docPageHtmlFile, htmlStr, "utf-8");
+      }
+      
+      // perform operation on Lucene
+      docOperation.setStatus(operationName + " document: " + docId + " in CMS");
+      docOperation.setMdRecord(mdRecord);
+      IndexHandler indexHandler = IndexHandler.getInstance();
+      indexHandler.indexDocument(docOperation);
+
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  private void delete(CmsDocOperation docOperation) throws ApplicationException {
+    String operationName = docOperation.getName();  
+    String docIdentifier = docOperation.getDocIdentifier();
+    if (docIdentifier == null || docIdentifier.trim().equals(""))
+      throw new ApplicationException("Your document identifier is empty. Please specify a document identifier for your document.");
+    String docDirStr = getDocDir(docIdentifier);
+    File docDir = new File(docDirStr);
+    boolean docExists = docDir.exists();
+    if (! docExists) {
+      throw new ApplicationException("Document:" + docIdentifier + " does not exists. Please use a name that exists and perform the operation \"Delete\" again.");
+    }
+    // perform operation on file system
+    docOperation.setStatus(operationName + " document: " + docIdentifier + " in CMS");
+    FileUtils.deleteQuietly(docDir);
+      
+    // perform operation on Lucene
+    IndexHandler indexHandler = IndexHandler.getInstance();
+    indexHandler.deleteDocument(docOperation);
+      
+  }
+  
+  private void createPdf(CmsDocOperation docOperation) throws ApplicationException {
+    String docId = docOperation.getDocIdentifier();
+    String operationName = docOperation.getName();
+    if (docId == null || docId.trim().equals(""))
+      throw new ApplicationException("Your document identifier is empty. Please specify a document identifier for your document.");
+    if (! isProjectDoc(docId)) {
+      LOGGER.info("Operation: " + operationName + " not performed on: " + docId + ". Cause: document is excluded as project doc");
+      return;
+    }
+    IndexHandler indexHandler = IndexHandler.getInstance();
+    MetadataRecord mdRecord = indexHandler.getDocMetadata(docId);
+    docOperation.setStatus("create PDF and HTML versions of the document: " + docId);
+    PdfHandler pdfHandler = PdfHandler.getInstance();
+    pdfHandler.createFile(true, true, mdRecord);  // generate Pdf + Html document
+  }
+  
+  private MetadataRecord getMetadataRecord(File xmlFile, String schemaName, MetadataRecord mdRecord, XQueryEvaluator xQueryEvaluator) throws ApplicationException {
+    if (schemaName == null)
+      return mdRecord;
+    try {
+      URL srcUrl = xmlFile.toURI().toURL();
+      if (schemaName.equals("archimedes"))
+        mdRecord = getMetadataRecordArch(xQueryEvaluator, srcUrl, mdRecord);
+      else if (schemaName.equals("echo"))
+        mdRecord = getMetadataRecordEcho(xQueryEvaluator, srcUrl, mdRecord);
+      else if (schemaName.equals("TEI"))
+        mdRecord = getMetadataRecordTei(xQueryEvaluator, srcUrl, mdRecord);
+      else if (schemaName.equals("html"))
+        mdRecord = getMetadataRecordHtml(xQueryEvaluator, srcUrl, mdRecord);
+      else
+        mdRecord.setSchemaName("diverse"); // all other cases: set docType to schemaName
+    } catch (MalformedURLException e) {
+      throw new ApplicationException(e);
+    }
+    mdRecord.setLastModified(new Date());
+    return mdRecord;
+  }
+
+  private MetadataRecord getMetadataRecordArch(XQueryEvaluator xQueryEvaluator, URL srcUrl, MetadataRecord mdRecord) throws ApplicationException {
+    String metadataXmlStr = xQueryEvaluator.evaluateAsString(srcUrl, "/archimedes//info");
+    if (metadataXmlStr != null) {
+      String identifier = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/info/locator");
+      if (identifier != null)
+        identifier = StringUtils.deresolveXmlEntities(identifier);
+      String creator = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/info/author");
+      if (creator != null)
+        creator = StringUtils.deresolveXmlEntities(creator);
+      String title = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/info/title");
+      if (title != null)
+        title = StringUtils.deresolveXmlEntities(title);
+      String language = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/info/lang[1]");
+      if (language != null)
+        language = StringUtils.deresolveXmlEntities(language);
+      String place = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/info/place");
+      if (place != null)
+        place = StringUtils.deresolveXmlEntities(place);
+      String yearStr = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/info/date");
+      Date date = null; 
+      if (yearStr != null && ! yearStr.equals("")) {
+        yearStr = StringUtils.deresolveXmlEntities(yearStr);
+        yearStr = new Util().toYearStr(yearStr);  // test if possible etc
+        if (yearStr != null) {
+          try {
+            date = new Util().toDate(yearStr + "-01-01T00:00:00.000Z");
+          } catch (Exception e) {
+            // nothing
+          }
+        }
+      }
+      String rights = "open access";
+      String license = "http://echo.mpiwg-berlin.mpg.de/policy/oa_basics/declaration";
+      String accessRights = "free";
+
+      mdRecord.setIdentifier(identifier);
+      mdRecord.setLanguage(language);
+      mdRecord.setCreator(creator);
+      mdRecord.setTitle(title);
+      mdRecord.setPublisher(place);
+      mdRecord.setRights(rights);
+      mdRecord.setDate(date);
+      mdRecord.setLicense(license);
+      mdRecord.setAccessRights(accessRights);
+
+      // get echo metadata
+      String echoDir = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/info/echodir");
+      String docId = mdRecord.getDocId();
+      String echoIdTmp = docId;
+      if (docId != null && ! docId.isEmpty()) {
+        int start = docId.lastIndexOf("/");
+        if (start != -1)
+          start = start + 1;
+        else 
+          start = 0;
+        int end = docId.lastIndexOf(".");
+        if (end == -1)
+          end = docId.length();
+        echoIdTmp = docId.substring(start, end);
+      }
+      String echoId = "/permanent/archimedes/" + echoIdTmp;
+      if (echoIdTmp == null || echoIdTmp.isEmpty())
+        echoId = null;
+      if (echoDir != null && ! echoDir.isEmpty()) {
+        echoId = echoDir;
+      }
+      mdRecord = getEchoMetadata(xQueryEvaluator, echoId, mdRecord);
+    }
+    String pageCountStr = xQueryEvaluator.evaluateAsString(srcUrl, "count(//pb)");
+    int pageCount = Integer.valueOf(pageCountStr);
+    mdRecord.setPageCount(pageCount);
+    mdRecord.setSchemaName("archimedes");
+    return mdRecord;
+  }
+  
+  private MetadataRecord getMetadataRecordEcho(XQueryEvaluator xQueryEvaluator, URL srcUrl, MetadataRecord mdRecord) throws ApplicationException {
+    String metadataXmlStr = xQueryEvaluator.evaluateAsString(srcUrl, "/*:echo/*:metadata");
+    if (metadataXmlStr != null) {
+      String identifier = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:metadata/*:identifier");
+      if (identifier != null) {
+        identifier = StringUtils.deresolveXmlEntities(identifier);
+      }
+      String creator = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:metadata/*:creator");
+      if (creator != null)
+        creator = StringUtils.deresolveXmlEntities(creator);
+      String title = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:metadata/*:title");
+      if (title != null)
+        title = StringUtils.deresolveXmlEntities(title);
+      String language = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:metadata/*:language[1]");
+      if (language != null)
+        language = StringUtils.deresolveXmlEntities(language);
+      String yearStr = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:metadata/*:date");
+      Date date = null; 
+      if (yearStr != null && ! yearStr.equals("")) {
+        yearStr = StringUtils.deresolveXmlEntities(yearStr);
+        yearStr = new Util().toYearStr(yearStr);  // test if possible etc
+        if (yearStr != null) {
+          try {
+            date = new Util().toDate(yearStr + "-01-01T00:00:00.000Z");
+          } catch (Exception e) {
+            // nothing
+          }
+        }
+      }
+      String rights = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:metadata/*:rights");
+      if (rights != null)
+        rights = StringUtils.deresolveXmlEntities(rights);
+      String license = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:metadata/*:license");
+      if (license != null)
+        license = StringUtils.deresolveXmlEntities(license);
+      String accessRights = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:metadata/*:accessRights");
+      if (accessRights != null)
+        accessRights = StringUtils.deresolveXmlEntities(accessRights);
+
+      mdRecord.setIdentifier(identifier);
+      mdRecord.setLanguage(language);
+      mdRecord.setCreator(creator);
+      mdRecord.setTitle(title);
+      mdRecord.setRights(rights);
+      mdRecord.setDate(date);
+      mdRecord.setLicense(license);
+      mdRecord.setAccessRights(accessRights);
+
+      // get echo metadata
+      String echoDir = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:metadata/*:echodir");
+      String echoIdTmp = identifier;
+      if (identifier != null && ! identifier.isEmpty()) {
+        int start = identifier.indexOf("ECHO:");
+        if (start != -1)
+          start = start + 5;
+        else 
+          start = 0;
+        int end = identifier.lastIndexOf(".");
+        if (end == -1)
+          end = identifier.length();
+        echoIdTmp = identifier.substring(start, end);
+      }
+      String echoId = "/permanent/library/" + echoIdTmp;
+      if (echoIdTmp == null || echoIdTmp.isEmpty())
+        echoId = null;
+      if (echoDir != null && ! echoDir.isEmpty()) {
+        echoId = echoDir;
+      }
+      mdRecord = getEchoMetadata(xQueryEvaluator, echoId, mdRecord);
+    }
+    String pageCountStr = xQueryEvaluator.evaluateAsString(srcUrl, "count(//*:pb)");
+    int pageCount = Integer.valueOf(pageCountStr);
+    mdRecord.setPageCount(pageCount);
+    mdRecord.setSchemaName("echo");
+    return mdRecord;
+  }
+
+  private MetadataRecord getMetadataRecordTei(XQueryEvaluator xQueryEvaluator, URL srcUrl, MetadataRecord mdRecord) throws ApplicationException {
+    String metadataXmlStr = xQueryEvaluator.evaluateAsString(srcUrl, "/*:TEI/*:teiHeader");
+    if (metadataXmlStr != null) {
+      String identifier = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:teiHeader/*:fileDesc/*:publicationStmt/*:idno");
+      if (identifier != null) {
+        identifier = StringUtils.deresolveXmlEntities(identifier);
+        identifier = deleteSpecialChars(identifier);
+      }
+      String creator = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:teiHeader/*:fileDesc/*:titleStmt/*:author");
+      if (creator != null)
+        creator = StringUtils.deresolveXmlEntities(creator);
+      String title = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:teiHeader/*:fileDesc/*:titleStmt/*:title");
+      if (title != null)
+        title = StringUtils.deresolveXmlEntities(title);
+      String language = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/*:teiHeader/*:profileDesc/*:langUsage/*:language[1]/@ident)");
+      if (language != null && language.isEmpty())
+        language = null;
+      if (language != null) {
+        language = language.toLowerCase();
+        if (language.length() == 5) {  // e.g. "de-DE or en-US"
+          if (language.substring(2, 3).equals("-")) {
+            String lang = language.substring(0, 2);
+            language = Language.getInstance().getISO639Code(lang);
+          }
+        }
+      }
+      String place = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:teiHeader/*:fileDesc/*:publicationStmt/*:pubPlace");
+      if (place != null)
+        place = StringUtils.deresolveXmlEntities(place);
+      String yearStr = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:teiHeader/*:fileDesc/*:publicationStmt/*:date");
+      Date date = null; 
+      if (yearStr != null && ! yearStr.equals("")) {
+        yearStr = StringUtils.deresolveXmlEntities(yearStr);
+        yearStr = new Util().toYearStr(yearStr);  // test if possible etc
+        if (yearStr != null) {
+          try {
+            date = new Util().toDate(yearStr + "-01-01T00:00:00.000Z");
+          } catch (Exception e) {
+            // nothing
+          }
+        }
+      }
+      String subject = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/*:teiHeader/*:profileDesc/*:textClass/*:keywords/*:term)");
+      if (subject != null)
+        subject = StringUtils.deresolveXmlEntities(subject);
+      String rights = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "/*:teiHeader/*:fileDesc/*:publicationStmt/*:availability");
+      if (rights == null)
+        rights = "open access";
+      rights = StringUtils.deresolveXmlEntities(rights);
+      String license = "http://echo.mpiwg-berlin.mpg.de/policy/oa_basics/declaration";
+      String accessRights = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/*:teiHeader/*:fileDesc/*:publicationStmt/*:availability/@status)");
+      if (accessRights == null) 
+        accessRights = "free";
+      accessRights = StringUtils.deresolveXmlEntities(accessRights);
+
+      mdRecord.setIdentifier(identifier);
+      mdRecord.setLanguage(language);
+      mdRecord.setCreator(creator);
+      mdRecord.setTitle(title);
+      mdRecord.setPublisher(place);
+      mdRecord.setRights(rights);
+      mdRecord.setDate(date);
+      mdRecord.setSubject(subject);
+      mdRecord.setLicense(license);
+      mdRecord.setAccessRights(accessRights);
+
+      // get echo metadata
+      mdRecord = getEchoMetadata(xQueryEvaluator, identifier, mdRecord);  // identifier is echoDir
+    }
+    String pageCountStr = xQueryEvaluator.evaluateAsString(srcUrl, "count(//*:pb)");
+    int pageCount = Integer.valueOf(pageCountStr);
+    mdRecord.setPageCount(pageCount);
+    mdRecord.setSchemaName("TEI");
+    return mdRecord;
+  }
+
+  private MetadataRecord getMetadataRecordHtml(XQueryEvaluator xQueryEvaluator, URL srcUrl, MetadataRecord mdRecord) throws ApplicationException {
+    String metadataXmlStr = xQueryEvaluator.evaluateAsString(srcUrl, "/html/head");
+    if (metadataXmlStr != null) {
+      String identifier = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/meta[@name = 'DC.identifier']/@content)");
+      if (identifier != null && ! identifier.isEmpty())
+        identifier = StringUtils.deresolveXmlEntities(identifier);
+      String creator = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/meta[@name = 'DC.creator']/@content)");
+      if (creator != null && ! creator.isEmpty())
+        creator = StringUtils.deresolveXmlEntities(creator);
+      String title = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/meta[@name = 'DC.title']/@content)");
+      if (title != null && ! title.isEmpty())
+        title = StringUtils.deresolveXmlEntities(title);
+      String language = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/meta[@name = 'DC.language']/@content)");
+      if (language != null && language.isEmpty())
+        language = null;
+      if (language != null && ! language.isEmpty())
+        language = StringUtils.deresolveXmlEntities(language);
+      String publisher = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/meta[@name = 'DC.publisher']/@content)");
+      if (publisher != null)
+        publisher = StringUtils.deresolveXmlEntities(publisher);
+      String yearStr = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/meta[@name = 'DC.date']/@content)");
+      Date date = null; 
+      if (yearStr != null && ! yearStr.equals("")) {
+        yearStr = StringUtils.deresolveXmlEntities(yearStr);
+        yearStr = new Util().toYearStr(yearStr);  // test if possible etc
+        if (yearStr != null) {
+          try {
+            date = new Util().toDate(yearStr + "-01-01T00:00:00.000Z");
+          } catch (Exception e) {
+            // nothing
+          }
+        }
+      }
+      String subject = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/meta[@name = 'DC.subject']/@content)");
+      if (subject != null)
+        subject = StringUtils.deresolveXmlEntities(subject);
+      String rights = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/meta[@name = 'DC.rights']/@content)");
+      if (rights != null && ! rights.isEmpty())
+        rights = StringUtils.deresolveXmlEntities(rights);
+      String license = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/meta[@name = 'DC.license']/@content)");
+      if (license != null && ! license.isEmpty())
+        license = StringUtils.deresolveXmlEntities(license);
+      String accessRights = xQueryEvaluator.evaluateAsStringValueJoined(metadataXmlStr, "string(/meta[@name = 'DC.accessRights']/@content)");
+      if (accessRights != null && ! accessRights.isEmpty())
+        accessRights = StringUtils.deresolveXmlEntities(accessRights);
+
+      mdRecord.setIdentifier(identifier);
+      mdRecord.setLanguage(language);
+      mdRecord.setCreator(creator);
+      mdRecord.setTitle(title);
+      mdRecord.setPublisher(publisher);
+      mdRecord.setRights(rights);
+      mdRecord.setDate(date);
+      mdRecord.setSubject(subject);
+      mdRecord.setLicense(license);
+      mdRecord.setAccessRights(accessRights);
+      
+      // get echo metadata
+      mdRecord = getEchoMetadata(xQueryEvaluator, identifier, mdRecord);  // identifier is echoDir
+    }
+    String pageCountStr = xQueryEvaluator.evaluateAsString(srcUrl, "count(//pb)");
+    int pageCount = Integer.valueOf(pageCountStr);
+    mdRecord.setPageCount(pageCount);
+    mdRecord.setSchemaName("html");
+    return mdRecord;
+  }
+
+  private MetadataRecord getEchoMetadata(XQueryEvaluator xQueryEvaluator, String echoDir, MetadataRecord mdRecord) throws ApplicationException {
+    if (echoDir == null || echoDir.isEmpty()) {
+      String docId = mdRecord.getDocId();
+      echoDir = getEchoDir(xQueryEvaluator, docId);
+      if (echoDir == null)
+        return mdRecord;
+    }
+    String urLTexter = "http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Texter?fn=" + echoDir + "/index.meta";
+    String echoIndexMetaStr = performGetRequest(urLTexter);
+    String echoPageImageDir = null;
+    String echoFiguresDir = null;
+    String mpiwgDocId = null;
+    if (echoIndexMetaStr != null) {
+      if (echoIndexMetaStr.equals("XXXXTimeoutXXXX"))
+        return null;
+      else if (echoIndexMetaStr.equals("XXXXUrlErrorXXXX"))
+        return mdRecord;
+      echoPageImageDir = xQueryEvaluator.evaluateAsStringValueJoined(echoIndexMetaStr, "/resource/meta/texttool/image");
+      if (echoPageImageDir != null)
+        echoPageImageDir = echoDir + "/" + echoPageImageDir;
+      else
+        echoPageImageDir = echoDir + "/" + "pageimg"; // default
+      echoFiguresDir = xQueryEvaluator.evaluateAsStringValueJoined(echoIndexMetaStr, "/resource/meta/texttool/figures");
+      if (echoFiguresDir != null)
+        echoFiguresDir = echoDir + "/" + echoFiguresDir;
+      else
+        echoFiguresDir = echoDir + "/" + "figures"; // default
+      mpiwgDocId = xQueryEvaluator.evaluateAsStringValueJoined(echoIndexMetaStr, "/resource/meta/dri[@type = 'mpiwg']");
+    }
+    mdRecord.setEchoId(echoDir);
+    mdRecord.setEchoPageImageDir(echoPageImageDir);
+    mdRecord.setEchoFiguresDir(echoFiguresDir);
+    mdRecord.setMpiwgDocId(mpiwgDocId);
+    return mdRecord;
+  }
+  
+  private String getEchoDir(XQueryEvaluator xQueryEvaluator, String docId) throws ApplicationException {
+    String echoDir = null;
+    String urLTextUrlPath = "http://md.mpiwg-berlin.mpg.de/purls/searchSolr?text-url-path=" + docId + "&format=short";
+    String resultXmlStr = performGetRequest(urLTextUrlPath);
+    if (resultXmlStr != null) {
+      if (resultXmlStr.equals("XXXXTimeoutXXXX"))
+        return null;
+      else if (resultXmlStr.equals("XXXXUrlErrorXXXX"))
+        return null;
+      String archivePath = xQueryEvaluator.evaluateAsStringValueJoined(resultXmlStr, "//archive-path");
+      if (archivePath != null) {
+        archivePath = archivePath.replaceAll("/mpiwg/online", "");
+        if (archivePath.isEmpty())
+          echoDir = null;
+        else
+          echoDir = archivePath;
+      }
+    }
+    return echoDir;
+  }
+  
+  private String getNodeType(XdmNode node) {
+    String nodeType = null;
+    XdmSequenceIterator iter = node.axisIterator(Axis.CHILD);
+    if (iter != null) {
+      while (iter.hasNext()) {
+        XdmNode firstChild = (XdmNode) iter.next();
+        if (firstChild != null) {
+          XdmNodeKind nodeKind = firstChild.getNodeKind();
+          if (nodeKind.ordinal() == XdmNodeKind.ELEMENT.ordinal()) {
+            QName nodeQName = firstChild.getNodeName();
+            nodeType = nodeQName.getLocalName();
+          }
+        }
+      }
+    }
+    return nodeType;
+  }
+  
+  public String getDocFullFileName(String docId) {
+    String docDir = getDocDir(docId);
+    String docFileName = getDocFileName(docId);
+    String docFullFileName = docDir + "/" + docFileName; 
+    return docFullFileName;
+  }
+  
+  public String getFullFileName(String docId, String type) {
+    String docDir = getDocDir(docId);
+    String docFileName = getDocFileName(docId);
+    int lastDot = docFileName.lastIndexOf(".");
+    String docFileNameWithoutExtension = docFileName.substring(0, lastDot);
+    String fullFileName = docDir + "/" + docFileNameWithoutExtension + ".xml";
+    if (type != null && ! type.equals("toc")) {
+      fullFileName = docDir + "/" + docFileNameWithoutExtension + "." + type;
+    } else if (type != null && type.equals("toc")) {
+      fullFileName = docDir + "/toc.xml";
+    }
+    return fullFileName;
+  }
+  
+  public String getDocDir(String docId) {
+    String documentsDirectory = Constants.getInstance().getDocumentsDir();
+    String subDir = docId;
+    if (docId.contains(".")) {
+      int index = docId.lastIndexOf(".");
+      subDir = docId.substring(0, index);
+    }
+    if (! subDir.startsWith("/"))
+      subDir = "/" + subDir;
+    String docDir = documentsDirectory + subDir;
+    return docDir;
+  }
+
+  public String getDocFileName(String docId) {
+    String docFileName = docId;
+    int index = docId.lastIndexOf("/");
+    if (index != -1) {
+      docFileName = docId.substring(index + 1);
+    }
+    return docFileName;
+  } 
+  
+  private String getMainLanguage(String docId) {
+    String mainLang = null;
+    int to = docId.lastIndexOf("/");
+    if (to != -1) {
+      String preStr = docId.substring(0, to);
+      int from = preStr.lastIndexOf("/");
+      if (from != -1) 
+        mainLang = preStr.substring(from + 1, to);
+    }
+    return mainLang;
+  } 
+  
+  private String deleteSpecialChars(String inputStr) {
+    StringBuilder buf = new StringBuilder();
+    for (int i = 0; i < inputStr.length(); i++) {
+      char c = inputStr.charAt(i);
+      String replace = new String();
+      switch (c) {
+        case '@': replace = ""; break; 
+        case ' ': replace = ""; break; 
+        case ';': replace = ""; break; 
+        default: replace += c; break;
+      }
+      buf.append(replace);
+    }
+    return buf.toString();
+  }
+
+  private Hashtable<Integer, StringBuilder> getFragments(String fileName, String milestoneElementName) throws ApplicationException {
+    try {
+      GetFragmentsContentHandler getFragmentsContentHandler = new GetFragmentsContentHandler(milestoneElementName);
+      XMLReader xmlParser = new SAXParser();
+      xmlParser.setContentHandler(getFragmentsContentHandler);
+      StringReader bla = new StringReader(FileUtils.readFileToString(new File(fileName), "utf-8"));
+      InputSource inputSource = new InputSource(bla);
+      xmlParser.parse(inputSource);
+      Hashtable<Integer, StringBuilder> resultFragments = getFragmentsContentHandler.getResultPages();
+      return resultFragments;
+    } catch (SAXException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+
+  private String tokenizeWithLemmas(String xmlStr, String language) throws ApplicationException {
+    StringReader strReader = new StringReader(xmlStr);
+    XmlTokenizer xmlTokenizer = new XmlTokenizer(strReader);
+    xmlTokenizer.setLanguage(language);
+    String[] outputOptionsWithLemmas = {"withLemmas"}; // so all tokens are fetched with lemmas (costs performance)
+    // non word breaking elements; 
+    // TODO examine bugs with emph, figure, hi : 
+    // e.g. "... der <hi rend="i">Capi-<lb n="16"/>talist.</hi> Es ..."
+    // e.g. page 30 in /echo/la/Cataneo_1600.xml
+    String[] nwbElements = {"lb", "br", "cb"};  
+    xmlTokenizer.setNWBElements(nwbElements);
+    xmlTokenizer.setOutputOptions(outputOptionsWithLemmas); 
+    xmlTokenizer.tokenize();  
+    String retStr = xmlTokenizer.getXmlResult();
+    return retStr;
+  }
+  
+  private String enrichWordsOrigRegNorm(String xmlStr) throws ApplicationException {
+    try {
+      WordContentHandler wordContentHandler = new WordContentHandler();
+      XMLReader xmlParser = new SAXParser();
+      xmlParser.setContentHandler(wordContentHandler);
+      StringReader strReader = new StringReader(xmlStr);
+      InputSource inputSource = new InputSource(strReader);
+      xmlParser.parse(inputSource);
+      String result = wordContentHandler.getResult();
+      return result;
+    } catch (SAXException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  private String performGetRequest(String url) throws ApplicationException {
+    String resultStr = null;
+    try {
+      boolean urlIsOk = checkUri(url, 2000); // if url doesn't answer after 2 seconds
+      if (! urlIsOk)
+        return "XXXXTimeoutXXXX";
+      HttpClient httpClient = new HttpClient();
+      GetMethod method = new GetMethod(url);
+      httpClient.executeMethod(method); 
+      int statusCode = method.getStatusCode();
+      if (statusCode >= 400)
+        return "XXXXUrlErrorXXXX";
+      byte[] resultBytes = method.getResponseBody();
+      resultStr = new String(resultBytes, "utf-8");
+      method.releaseConnection();
+    } catch (HttpException e) {
+      throw new ApplicationException(e);      
+    } catch (IOException e) {
+      throw new ApplicationException(e);      
+    }
+    return resultStr;
+  } 
+
+  private boolean checkUri(String uriStr, int timeoutMilliseconds) throws ApplicationException {
+    boolean isOk = true;
+    try {
+      URI uri = new URI(uriStr);
+      HttpGet httpGet = new HttpGet(uri);
+      HttpParams httpParameters = new BasicHttpParams();
+      // Set the timeout in milliseconds until a connection is established.
+      // The default value is zero, that means the timeout is not used. 
+      int timeoutConnection = 2000;
+      HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
+      // Set the default socket timeout (SO_TIMEOUT) 
+      // in milliseconds which is the timeout for waiting for data.
+      int timeoutSocket = 2000;
+      HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
+      DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
+      HttpResponse response = httpClient.execute(httpGet);
+    } catch (IOException e) {
+      isOk = false;  // if timeout exception is thrown
+    } catch (URISyntaxException e) {
+      throw new ApplicationException(e);
+    }
+    return isOk;
+  }
+
+  /**
+   * Write string into destFile. If directory for that destFile does not exist 
+   * it creates this directory including parent directories. 
+   * @param str string to write
+   * @param destFileName destination file name
+   * @throws ApplicationException
+   */
+  private void saveFile(String str, String destFileName) throws ApplicationException {
+    OutputStreamWriter out = null;
+    try {
+      if (str == null)
+        return;  // do nothing
+      File destFile = new File(destFileName);
+      File destDir = new File(destFile.getParent()); 
+      if (! destDir.exists()) {
+        destDir.mkdirs();  // create the directory including parent directories which do not exist
+      }
+      out = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(destFile)), "utf-8");
+      out.write(str);
+      out.flush();
+    } catch (FileNotFoundException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    } finally {
+      try { 
+        if (out != null)
+          out.close(); 
+        } catch (Exception e) { 
+          // nothing: always close the stream at the end of the method
+        }  
+    }
+  }
+
+  private void beginOperation() {
+    beginOfOperation = new Date().getTime();
+  }
+
+  private void endOperation() {
+    endOfOperation = new Date().getTime();
+  }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/Hits.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,60 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.document;
+
+import java.util.ArrayList;
+
+import org.apache.lucene.search.Query;
+
+public class Hits {
+  private ArrayList<Document> hits;
+  private Query query;
+  private int from;
+  private int to;
+  private int size = 0;
+  
+  public Hits(ArrayList<Document> hits, int from, int to) {
+    this.hits = hits;
+    this.from = from;
+    this.to = to;
+  }
+
+  public int getSize() {
+    return size;
+  }
+
+  public void setSize(int size) {
+    this.size = size;
+  }
+
+  public Query getQuery() {
+    return query;
+  }
+
+  public void setQuery(Query query) {
+    this.query = query;
+  }
+
+  public ArrayList<Document> getHits() {
+    return hits;
+  }
+
+  public void setHits(ArrayList<Document> hits) {
+    this.hits = hits;
+  }
+
+  public int getFrom() {
+    return from;
+  }
+
+  public void setFrom(int from) {
+    this.from = from;
+  }
+
+  public int getTo() {
+    return to;
+  }
+
+  public void setTo(int to) {
+    this.to = to;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/MetadataRecord.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,217 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.document;
+
+import java.util.Calendar;
+import java.util.Date;
+
+public class MetadataRecord {
+  private String docId;  // local id: document identifier in index system, e.g. /echo/la/Benedetti_1585.xml
+  private String identifier;  // local id: identifier field in documents metadata: e.g. /echo:echo/echo:metadata/dcterms:identifier  
+  private String uri;  // global id: document URI (uniform resource identifier), e.g. http://de.wikipedia.org/wiki/Ramones
+  private String language;
+  private String creator;  // author
+  private String title;
+  private String description;  // abstract etc.
+  private String subject;  // subject keywords from the title or description or content or subject lists (thesaurus etc.)
+  private String publisher; // publisher with place: e.g. Springer, New York
+  private String type; // mime type: e.g. text/xml  // TODO ist eigentlich das Feld "format" --> zus. instance variable "format" definieren
+  private String rights; // e.g. open access
+  private Date date; // creation date, modification date, etc.
+  private String license;  // e.g. http://echo.mpiwg-berlin.mpg.de/policy/oa_basics/declaration
+  private String accessRights;  // e.g. free  
+  private String collectionNames; // e.g. "collection1 collection7"
+  private String schemaName; // e.g. TEI, echo, html, or archimedes
+  private Date lastModified;
+  private int pageCount;
+  private String echoId;  // document identifier in echo system: directory name, e.g. /permanent/library/163127KK  
+  private String echoPageImageDir;  // document page image directory in echo system: directory name, e.g. /permanent/library/163127KK/pageimg 
+  private String echoFiguresDir;  // document figures directory in echo system: directory name, e.g. /permanent/library/163127KK/figures 
+  private String mpiwgDocId;  // mpiwg docId in echo system: e.g. MPIWG:U7FWNX06 
+ 
+  public String getDocId() {
+    return docId;
+  }
+
+  public void setDocId(String docId) {
+    this.docId = docId;
+  }
+
+  public String getUri() {
+    return uri;
+  }
+
+  public void setUri(String uri) {
+    this.uri = uri;
+  }
+
+  public String getRights() {
+    return rights;
+  }
+
+  public void setRights(String rights) {
+    this.rights = rights;
+  }
+
+  public int getPageCount() {
+    return pageCount;
+  }
+
+  public void setPageCount(int pageCount) {
+    this.pageCount = pageCount;
+  }
+
+  public String getLicense() {
+    return license;
+  }
+
+  public void setLicense(String license) {
+    this.license = license;
+  }
+
+  public String getAccessRights() {
+    return accessRights;
+  }
+
+  public void setAccessRights(String accessRights) {
+    this.accessRights = accessRights;
+  }
+
+  public String getCreator() {
+    return creator;
+  }
+
+  public void setCreator(String creator) {
+    this.creator = creator;
+  }
+
+  public String getTitle() {
+    return title;
+  }
+
+  public void setTitle(String title) {
+    this.title = title;
+  }
+
+  public Date getDate() {
+    return date;
+  }
+
+  public void setDate(Date date) {
+    this.date = date;
+  }
+
+  public String getYear() {
+    String year = null;
+    if (date != null) {
+      Calendar cal = Calendar.getInstance();
+      cal.setTime(date);
+      int iYear = cal.get(Calendar.YEAR);
+      year = "" + iYear;
+    }
+    return year;
+  }
+  
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  public String getSubject() {
+    return subject;
+  }
+
+  public void setSubject(String subject) {
+    this.subject = subject;
+  }
+
+  public String getCollectionNames() {
+    return collectionNames;
+  }
+
+  public void setCollectionNames(String collectionNames) {
+    this.collectionNames = collectionNames;
+  }
+
+  public String getIdentifier() {
+    return identifier;
+  }
+
+  public void setIdentifier(String identifier) {
+    this.identifier = identifier;
+  }
+
+  public String getLanguage() {
+    return language;
+  }
+
+  public void setLanguage(String language) {
+    this.language = language;
+  }
+
+  public String getPublisher() {
+    return publisher;
+  }
+
+  public void setPublisher(String publisher) {
+    this.publisher = publisher;
+  }
+
+  public String getType() {
+    return type;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+  }
+
+  public String getSchemaName() {
+    return schemaName;
+  }
+
+  public void setSchemaName(String schemaName) {
+    this.schemaName = schemaName;
+  }
+
+  public Date getLastModified() {
+    return lastModified;
+  }
+
+  public void setLastModified(Date lastModified) {
+    this.lastModified = lastModified;
+  }
+
+  public String getEchoId() {
+    return echoId;
+  }
+
+  public void setEchoId(String echoId) {
+    this.echoId = echoId;
+  }
+
+  public String getEchoPageImageDir() {
+    return echoPageImageDir;
+  }
+
+  public void setEchoPageImageDir(String echoPageImageDir) {
+    this.echoPageImageDir = echoPageImageDir;
+  }
+
+  public String getEchoFiguresDir() {
+    return echoFiguresDir;
+  }
+
+  public void setEchoFiguresDir(String echoFiguresDir) {
+    this.echoFiguresDir = echoFiguresDir;
+  }
+
+  public String getMpiwgDocId() {
+    return mpiwgDocId;
+  }
+
+  public void setMpiwgDocId(String mpiwgDocId) {
+    this.mpiwgDocId = mpiwgDocId;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandler.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,403 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.document;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Hashtable;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.io.FileUtils;
+import org.xhtmlrenderer.layout.SharedContext;
+import org.xhtmlrenderer.pdf.ITextFontResolver;
+import org.xhtmlrenderer.pdf.ITextRenderer;
+import org.xhtmlrenderer.util.XRRuntimeException;
+
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.pdf.BaseFont;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.cms.general.Constants;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.PageTransformer;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.TocTransformer;
+
+public class PdfHandler {
+  private static PdfHandler instance;
+  private static String CSS_SHOW_WORD_URL = "http://thrax.rz-berlin.mpg.de/mpiwg-mpdl-cms-web/css/pageOrig.css";
+  private static String CSS_URL = "http://thrax.rz-berlin.mpg.de/mpiwg-mpdl-cms-web/css/page.css";
+  // private static String CSS_DOCUVIEWER_URL = "http://echo.mpiwg-berlin.mpg.de/ECHOdocuView/template/docuviewer_css";
+  private ITextRenderer renderer = new ITextRenderer();
+  private Hashtable<String, String> fontFileNames;
+  private DocumentHandler docHandler;
+  private TocTransformer tocTransformer;
+  private PageTransformer pageTransformer;    
+
+  public static PdfHandler getInstance() throws ApplicationException {
+    if (instance == null) {
+      instance = new PdfHandler();
+      instance.init();
+    }
+    return instance;
+  }
+
+  public void init() throws ApplicationException {
+    renderer = new ITextRenderer();
+    SharedContext rendererSharedContext = renderer.getSharedContext();
+    PdfHandlerUserAgent mpdlUserAgent = new PdfHandlerUserAgent();  // user agent to get a callback handle to the web access of images (getImageResource(url))
+    mpdlUserAgent.setSharedContext(rendererSharedContext);
+    rendererSharedContext.setUserAgentCallback(mpdlUserAgent);
+    fontFileNames = new Hashtable<String, String>();
+    String fontJunicodeFileName = Constants.getInstance().getDocumentsDir() + "/../fonts/Junicode-Regular.ttf";
+    String fontJunicodeBoldFileName = Constants.getInstance().getDocumentsDir() + "/../fonts/Junicode-Bold.ttf";
+    String fontJunicodeItalicFileName = Constants.getInstance().getDocumentsDir() + "/../fonts/Junicode-Italic.ttf";
+    String fontJunicodeBoldItalicFileName = Constants.getInstance().getDocumentsDir() + "/../fonts/Junicode-BoldItalic.ttf";
+    String fontSunExtAFileName = Constants.getInstance().getDocumentsDir() + "/../fonts/Sun-ExtA.ttf";  // chinese symbols
+    String fontSunExtBFileName = Constants.getInstance().getDocumentsDir() + "/../fonts/Sun-ExtB.ttf";  // chinese symbols
+    String fontDejaVuFileName = Constants.getInstance().getDocumentsDir() + "/../fonts/DejaVuSans.ttf";  // arabic symbols
+    setFont(fontJunicodeFileName);
+    setFont(fontJunicodeBoldFileName);
+    setFont(fontJunicodeItalicFileName);
+    setFont(fontJunicodeBoldItalicFileName);  // if set then some not bold italic characters are shown bold (e.g. in Benedetti_1585.xml)
+    setFont(fontSunExtAFileName);
+    setFont(fontSunExtBFileName);
+    setFont(fontDejaVuFileName);
+    docHandler = new DocumentHandler();
+    tocTransformer = new TocTransformer();
+    pageTransformer = new PageTransformer();    
+  }
+  
+  public void createFile(boolean pdf, boolean html, MetadataRecord mdRecord) throws ApplicationException {
+    OutputStream osPdf = null;
+    OutputStream osHtml = null;
+    OutputStream osHtmlPdf = null;
+    String docId = mdRecord.getDocId();
+    String language = mdRecord.getLanguage();
+    if (docId == null)
+      throw new ApplicationException("Pdf/Html-Generation failed: no docId given in mdRecord");
+    String docDir = docHandler.getDocDir(docId);
+    String docFileName = docHandler.getDocFileName(docId);
+    int lastDot = docFileName.lastIndexOf(".");
+    String docFileNameWithoutExtension = docFileName.substring(0, lastDot);
+    String docIdExtension = docFileName.substring(lastDot + 1);
+    String destFileNamePdf = docDir + "/" + docFileNameWithoutExtension + ".pdf";
+    String destFileNameHtml = docDir + "/" + docFileNameWithoutExtension + ".html";
+    if (docIdExtension != null && docIdExtension.equals("html")) {
+      destFileNameHtml = docDir + "/" + docFileNameWithoutExtension + "-gen.html";
+    }
+    String destFileNameHtmlPdfTmp = docDir + "/" + docFileNameWithoutExtension + "-4Pdf.html";
+    try {
+      // start document
+      if (pdf) {
+        osPdf = new FileOutputStream(new File(destFileNamePdf));
+        osHtmlPdf = new FileOutputStream(new File(destFileNameHtmlPdfTmp));
+      }
+      if (html)
+        osHtml = new FileOutputStream(new File(destFileNameHtml));
+      int countPages = mdRecord.getPageCount();
+      // style page
+      String pageStyleHtml = "float:left; clear:both; border: thin solid #808080; width: 21.0cm; margin-top: 0.2cm; margin-bottom: 1cm; margin-left: 0.7cm; margin-right: 0.7cm; padding: 0.2cm;";
+      // firstPage
+      String firstPageHtml = getFirstPageHtmlByEchodocuView(mdRecord);
+      String mdRecordStr = getMdRecordString(mdRecord);
+      String htmlHeadStr = getHtmlHead(null, mdRecordStr);
+      String fontStyle = getFontStyle(language);
+      if(pdf) {
+        write("<html>" + htmlHeadStr + "<body style=\"" + fontStyle +  "\">", osHtmlPdf);
+        // first page
+        if (firstPageHtml == null)
+          firstPageHtml = getFirstPageHtml(mdRecord, false);  // long first page
+        write(firstPageHtml, osHtmlPdf);
+      }
+      if (html) {
+        write("<html>" + htmlHeadStr + "<body style=\"" + fontStyle +  "\">", osHtml);
+        // first page
+        write("<div style=\"" + pageStyleHtml + "\">", osHtml);
+        if (firstPageHtml == null)
+          firstPageHtml = getFirstPageHtml(mdRecord, true);  // short first page
+        write(firstPageHtml, osHtml);
+        write("</div>", osHtml);
+      }
+      // table of content of document
+      String htmlToc = getTocHtml(mdRecord);
+      if (html && htmlToc != null) {
+        write("<div style=\"" + pageStyleHtml + "\">", osHtml);
+        write(htmlToc, osHtml);
+        write("</div>", osHtml);
+      }
+      if(pdf && htmlToc != null) {
+        write(htmlToc, osHtmlPdf);
+      }
+      // all pages of the document
+      for(int i=1; i<=countPages; i++) {
+        String htmlPageFragment = getPageFragmentHtml(mdRecord, i, pageTransformer);
+        htmlPageFragment = "<div id=\"page" + i + "\" class=\"page\">" + htmlPageFragment + "</div>";
+        if (html) {
+          write("<div style=\"" + "clear:both; text-align:right; width:21.0cm; font-weight:bold;" + "\">", osHtml);
+          write("</div>", osHtml);
+          write("<div style=\"" + pageStyleHtml + "\">", osHtml);
+          write(htmlPageFragment, osHtml);
+          write("</div>", osHtml);
+        }
+        if(pdf) {
+          write(htmlPageFragment, osHtmlPdf);
+        }
+      }
+      if (html) {
+        write("</body></html>", osHtml);
+      }
+      // create PDF document
+      if(pdf) {
+        write("</body></html>", osHtmlPdf);
+        osHtmlPdf.close();
+        renderer.setDocument(new File(destFileNameHtmlPdfTmp));
+        renderer.layout();  // takes the most time
+        renderer.createPDF(osPdf);
+      }
+    } catch (Exception e) {
+      init();
+      String message = e.getMessage();
+      if (message != null && message.indexOf("digilib") > 0 && message.indexOf("500") > 0) {
+        throw new ApplicationException("fetch image is not possible: " + message);
+      }
+      throw new ApplicationException(e);
+    } finally {
+      try {
+        osHtmlPdf.close();
+        osPdf.close();
+        osHtml.close();
+        FileUtils.deleteQuietly(new File(destFileNameHtmlPdfTmp));
+      } catch (IOException e) {
+        // nothing
+      }
+    }
+  }
+
+  private String getFirstPageHtmlByEchodocuView(MetadataRecord mdRecord) {
+    String firstPageHtml = null;
+    try {
+      // Url to Echo viewer
+      String echoId = mdRecord.getEchoId();
+      if (echoId == null)
+        return null;
+      String urlDocuView = "http://echo.mpiwg-berlin.mpg.de/ECHOdocuView?url=" + echoId + "&viewMode=indexonly";
+      String wholeFirstPageHtml = performGetRequest(urlDocuView);
+      if (wholeFirstPageHtml != null & wholeFirstPageHtml.equals("XXXXUrlErrorXXXX"))
+        return null;
+      int from = wholeFirstPageHtml.indexOf("<body>");
+      int to = wholeFirstPageHtml.indexOf("</body>");
+      if (from != -1 && to != -1) {
+        firstPageHtml = "<div>" + wholeFirstPageHtml.substring(from + 6, to) + "</div>";
+      }
+    } catch (ApplicationException e) {
+      // nothing
+    }
+    return firstPageHtml;
+  }
+  
+  private String getFirstPageHtml(MetadataRecord mdRecord, boolean shortPage) {
+    String author = mdRecord.getCreator();
+    String title = mdRecord.getTitle();
+    String year = mdRecord.getYear();
+    String firstPageHtml = "<div class=\"firstPage\">";
+    firstPageHtml = firstPageHtml + "<h2 style=\"text-align:center\">" + "Max Planck Institute for the History of Science" + "</h2>";
+    firstPageHtml = firstPageHtml + "<p style=\"text-align:center\">" + "Max-Planck-Institut fŸr Wissenschaftsgeschichte" + "</p>";
+    firstPageHtml = firstPageHtml + "<br></br>";
+    firstPageHtml = firstPageHtml + "<br></br>";
+    if (! shortPage) {
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+    }
+    if (author != null) {
+      firstPageHtml = firstPageHtml + "<h2 style=\"text-align:center\">" + author + "</h2>";
+    }
+    if (title != null) {
+      firstPageHtml = firstPageHtml + "<h2 style=\"text-align:center\">" + title + "</h2>";
+    }
+    if (year != null) {
+      firstPageHtml = firstPageHtml + "<h2 style=\"text-align:center\">" + year + "</h2>";
+    }
+    if (! shortPage) {
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+      firstPageHtml = firstPageHtml + "<br></br>";
+    }
+    firstPageHtml = firstPageHtml + "<br></br>";
+    firstPageHtml = firstPageHtml + "<br></br>";
+    firstPageHtml = firstPageHtml + "<br></br>";
+    firstPageHtml = firstPageHtml + "<br></br>";
+    // Url to Echo viewer
+    String echoId = mdRecord.getEchoId();
+    String urlDocuView = "http://echo.mpiwg-berlin.mpg.de/ECHOdocuView";
+    String document = "?url=" + echoId;
+    String urlDoc = urlDocuView + document;
+    String echoLink = "<a href=\"" + urlDoc + "\">" +  urlDocuView + " <br></br>" + document + "</a>";
+    if (echoId == null)
+      echoLink = "<a href=\"http://echo.mpiwg-berlin.mpg.de\">" +  "http://echo.mpiwg-berlin.mpg.de" + "</a>";
+    firstPageHtml = firstPageHtml + "<p style=\"font:11pt sans-serif;\">Document link: <br></br>" + echoLink + "</p>";
+    firstPageHtml = firstPageHtml + "</div>";
+    return firstPageHtml;
+  }
+  
+  private String getTocHtml(MetadataRecord mdRecord) throws ApplicationException {
+    String htmlStr = null;
+    try {
+      String docId = mdRecord.getDocId();
+      String tocFileName = docHandler.getFullFileName(docId, "toc");
+      File tocFile = new File(tocFileName);
+      String tocStr = FileUtils.readFileToString(tocFile, "utf-8");
+      String htmlToc = tocTransformer.transform(tocStr, "toc", "html");
+      if (htmlToc != null && ! htmlToc.isEmpty()) {
+        htmlStr = "<div class=\"tocPage\">" + "<text style=\"font-weight:bold; font-size:20pt; margin-left:2%; \">Table of contents</text>" + htmlToc + "</div>";
+      }
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+    return htmlStr;
+  }
+  
+  private String getPageFragmentHtml(MetadataRecord mdRecord, int pageNumber, PageTransformer pageTransformer) throws ApplicationException {
+    String pageHtmlStrFragment = null;
+    try {
+      String docId = mdRecord.getDocId();
+      String docDir = docHandler.getDocDir(docId);
+      String docPageTokenizedFileName = docDir + "/pages/page-" + pageNumber + "-morph.xml";
+      File docPageTokenizedFile = new File(docPageTokenizedFileName);
+      String tokenizedXmlStr = FileUtils.readFileToString(docPageTokenizedFile, "utf-8");
+      pageTransformer.setDisplayWordOptions("orig"); // only orig word spans are build so that the HTML is not too huge for PDF generation 
+      pageHtmlStrFragment = pageTransformer.transform(tokenizedXmlStr, mdRecord, pageNumber, "html");
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+    return pageHtmlStrFragment;
+  }
+  
+  private String getMdRecordString(MetadataRecord mdRecord) {
+    String author = mdRecord.getCreator();
+    String title = mdRecord.getTitle();
+    String year = mdRecord.getYear();
+    String mdRecordStr = "";
+    if (mdRecord != null) {
+      if (author != null && ! author.equals("")) {
+        mdRecordStr = mdRecordStr + author;
+      }
+      if (title != null && ! title.equals("")) {
+        mdRecordStr = mdRecordStr + ". " + title;
+      }
+      if (year != null && ! year.equals("")) {
+        mdRecordStr = mdRecordStr + ". " + year + ".";
+      }
+      if (mdRecordStr.isEmpty()) {
+        String docId = mdRecord.getDocId(); 
+        mdRecordStr = mdRecordStr + docId;
+      }
+    }
+    return mdRecordStr;
+  }
+  
+  private String getHtmlHead(String stylePageStr, String titleStr) {
+    String htmlStr = "<head>";
+    if (stylePageStr != null)
+      htmlStr = htmlStr + "<style type=\"text/css\">" + stylePageStr + "</style>";
+    htmlStr = htmlStr + "<title>" + titleStr + "</title>";
+    htmlStr = htmlStr + "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + CSS_SHOW_WORD_URL + "\"/>";
+    htmlStr = htmlStr + "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + CSS_URL + "\"/>";
+    htmlStr = htmlStr + "</head>";
+    return htmlStr;
+  }
+
+  private String getFontStyle(String language) {
+    String fontFamily = "Junicode";
+    if (language != null && language.equals("ar"))
+      fontFamily = "DejaVu Sans";
+    else if (language != null && (language.equals("zh") || language.equals("zho-Hant")))
+      fontFamily = "Sun-ExtA, Sun-ExtB";
+    return "font-size:11pt; font-family:" + fontFamily + ";";
+  }
+  
+  private void write(String str, OutputStream out) throws ApplicationException {
+    try {
+      byte[] bytes = str.getBytes("utf-8");
+      out.write(bytes, 0, bytes.length);
+      out.flush();
+    } catch (UnsupportedEncodingException e) {
+      throw new ApplicationException(e);
+    } catch (FileNotFoundException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    } 
+  }
+
+  private void setFont(String fontFileName) throws ApplicationException {
+    try {
+      String existingFontFileName = fontFileNames.get(fontFileName);
+      if (existingFontFileName == null) {
+        fontFileNames.put(fontFileName, fontFileName);
+        ITextFontResolver fontResolver = renderer.getFontResolver();
+        fontResolver.addFont(fontFileName, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);  // Identy_H is Unicode Horizontal; not_embedded means not embedded in the PDF doc
+      }
+    } catch (XRRuntimeException e) {
+      init();
+      String message = e.getMessage();
+      if (message.indexOf("digilib") > 0 && message.indexOf("500") > 0) {
+        throw new ApplicationException("fetch image is not possible: please try again later");
+      }
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      init();
+      String message = e.getMessage();
+      if (message.indexOf("digilib") > 0 && message.indexOf("500") > 0) {
+        throw new ApplicationException("fetch image is not possible: " + message);
+      }
+      throw new ApplicationException(e);
+    } catch (DocumentException e) {
+      init();
+      String message = e.getMessage();
+      if (message.indexOf("digilib") > 0 && message.indexOf("500") > 0) {
+        throw new ApplicationException("fetch image is not possible: " + message);
+      }
+      throw new ApplicationException(e);
+    }
+  }
+
+  private String performGetRequest(String url) throws ApplicationException {
+    String resultStr = null;
+    try {
+      HttpClient httpClient = new HttpClient();
+      GetMethod method = new GetMethod(url);
+      httpClient.executeMethod(method); 
+      int statusCode = method.getStatusCode();
+      if (statusCode >= 400)
+        return "XXXXUrlErrorXXXX";
+      byte[] resultBytes = method.getResponseBody();
+      resultStr = new String(resultBytes, "utf-8");
+      method.releaseConnection();
+    } catch (HttpException e) {
+      throw new ApplicationException(e);      
+    } catch (IOException e) {
+      throw new ApplicationException(e);      
+    }
+    return resultStr;
+  } 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/PdfHandlerUserAgent.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,149 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.document;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.logging.Logger;
+
+import org.xhtmlrenderer.layout.SharedContext;
+import org.xhtmlrenderer.pdf.ITextFSImage;
+import org.xhtmlrenderer.pdf.ITextOutputDevice;
+import org.xhtmlrenderer.pdf.PDFAsImage;
+import org.xhtmlrenderer.resource.ImageResource;
+import org.xhtmlrenderer.swing.NaiveUserAgent;
+
+import com.lowagie.text.Image;
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.PdfReader;
+
+public class PdfHandlerUserAgent extends NaiveUserAgent {
+  private static final int IMAGE_CACHE_CAPACITY = 32;
+  private static final float DEFAULT_DOTS_PER_POINT = 20f * 4f / 3f;
+  private static Logger LOGGER = Logger.getLogger(PdfHandlerUserAgent.class.getName()); 
+  private SharedContext sharedContext;
+  private ITextOutputDevice outputDevice;
+  
+  public PdfHandlerUserAgent() {
+    super(IMAGE_CACHE_CAPACITY);
+    outputDevice = new ITextOutputDevice(DEFAULT_DOTS_PER_POINT);
+  }
+  
+  @SuppressWarnings("unchecked")
+  public ImageResource getImageResource(String inputUri) {
+    ImageResource resource = null;
+    String uri = resolveURI(inputUri);
+    resource = (ImageResource) _imageCache.get(uri);
+    if (resource == null) {
+      InputStream is = resolveAndOpenStream(uri);
+      if (is != null) {
+        try {
+          URL url = new URL(uri);
+          if (url.getPath() != null && url.getPath().toLowerCase().endsWith(".pdf")) {
+            PdfReader reader = outputDevice.getReader(url);
+            PDFAsImage image = new PDFAsImage(url);
+            Rectangle rect = reader.getPageSizeWithRotation(1);
+            image.setInitialWidth(rect.getWidth()*outputDevice.getDotsPerPoint());
+            image.setInitialHeight(rect.getHeight()*outputDevice.getDotsPerPoint());
+            resource = new ImageResource(image);
+          } else {
+            Image image = getImage(url);
+            if (image == null)
+              return null;
+            scaleToOutputResolution(image);
+            resource = new ImageResource(new ITextFSImage(image));
+          }
+          _imageCache.put(uri, resource);
+        } catch (IOException e) {
+          LOGGER.severe("Can't get image file: unexpected problem for URI: '" + uri + "': " + e.getMessage());
+        } finally {
+          try {
+            if (is != null)
+              is.close();
+          } catch (IOException e) {
+            // ignore
+          }  
+        }
+      }
+    }
+    if (resource == null) {
+      resource = new ImageResource(null);
+    }
+    return resource;
+  }
+  
+  private void scaleToOutputResolution(Image image) {
+    float factor = sharedContext.getDotsPerPixel();
+    image.scaleAbsolute(image.getPlainWidth() * factor, image.getPlainHeight() * factor);
+  }
+
+  public SharedContext getSharedContext() {
+    return sharedContext;
+  }
+
+  public void setSharedContext(SharedContext sharedContext) {
+    this.sharedContext = sharedContext;
+  }
+  
+  private Image getImage(URL url) {
+    Image image = null;
+    try {
+      image = Image.getInstance(url);
+    } catch (Exception e) {
+      try {
+        Thread.sleep(1000);
+      } catch (InterruptedException ee) {
+        // nothing
+      }
+      LOGGER.severe("first retry to get image for URL '" + url.toString() + "': " + e.getMessage());
+      try {
+        image = Image.getInstance(url);
+      } catch (Exception e2) {
+        try {
+          Thread.sleep(1000);
+        } catch (InterruptedException ee) {
+          // nothing
+        }
+        LOGGER.severe("second retry to get image for URL '" + url.toString() + "': " + e.getMessage());
+        try {
+          image = Image.getInstance(url);
+        } catch (Exception e3) {
+          LOGGER.severe("third retry to get image for URL '" + url.toString() + "': " + e.getMessage());
+          return null;
+        }
+      }
+    }
+    return image;
+  }
+
+  protected InputStream resolveAndOpenStream(String inputUri) {
+    InputStream is = null;
+    String uri = resolveURI(inputUri);
+    try {
+      is = new URL(uri).openStream();
+    } catch (Exception e) {
+      try {
+        Thread.sleep(1000);
+      } catch (InterruptedException ee) {
+        // nothing
+      }
+      LOGGER.severe("first retry to open stream for URL '" + uri + "': " + e.getMessage());
+      try {
+        is = new URL(uri).openStream();
+      } catch (Exception e2) {
+        try {
+          Thread.sleep(1000);
+        } catch (InterruptedException ee) {
+          // nothing
+        }
+        LOGGER.severe("second retry to open stream for URL '" + uri + "': " + e.getMessage());
+        try {
+          is = new URL(uri).openStream();
+        } catch (Exception e3) {
+          LOGGER.severe("third retry to open stream for URL '" + uri + "': " + e.getMessage());
+          return null;
+        }
+      }
+    }
+    return is;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/document/Token.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,29 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.document;
+
+import org.apache.lucene.index.Term;
+
+public class Token {
+  private Term term;
+  private int freq = -1;
+  
+  public Token(Term term) {
+    this.term = term;
+  }
+
+  public Term getTerm() {
+    return term;
+  }
+
+  public void setTerm(Term term) {
+    this.term = term;
+  }
+
+  public int getFreq() {
+    return freq;
+  }
+
+  public void setFreq(int freq) {
+    this.freq = freq;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/general/Constants.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,55 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.general;
+
+import java.net.URL;
+import java.util.Properties;
+
+import de.mpg.mpiwg.berlin.mpdl.util.Util;
+
+public class Constants {
+  private static Constants instance;
+  private Properties properties;
+
+  public static Constants getInstance() {
+    if (instance == null) {
+      instance = new Constants();
+      instance.init();
+    }
+    return instance;
+  }
+  
+  private void init() {
+    URL url = Constants.class.getClassLoader().getResource("constants.properties"); 
+    if (url != null) {
+      String propertiesFileName = url.toString().substring(5);
+      properties = (new Util()).getProperties(propertiesFileName);
+    }
+  }
+  
+  public String getDocumentsDir() {
+    if (properties != null)
+      return properties.getProperty("documentsDir");
+    else 
+      return "no properties file";
+  }
+
+  public String getLuceneDocumentsDir() {
+    if (properties != null)
+      return properties.getProperty("luceneDocumentsDir");
+    else 
+      return "no properties file";
+  }
+
+  public String getLuceneNodesDir() {
+    if (properties != null)
+      return properties.getProperty("luceneNodesDir");
+    else 
+      return "no properties file";
+  }
+
+  public String getConfDir() {
+    if (properties != null)
+      return properties.getProperty("confDir");
+    else 
+      return "no properties file";
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/harvester/PathExtractor.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,137 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.harvester;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+public class PathExtractor {
+  private List<String> ressourceLoc;
+  String excludes;
+
+  public PathExtractor() {
+
+  }
+
+  public List<String> initExtractor(String startingUri, String excludes) {
+    this.excludes = excludes;
+    ressourceLoc = new ArrayList<String>();
+    // parameter necessery, because it's recursive, thus changing the uri
+    extractDocLocations(startingUri);
+    System.out.println("extracing resource locations done.");
+    return this.ressourceLoc;
+  }
+
+  /**
+   * recursive Method to extract the path of the resources
+   * 
+   * @param startUrl
+   */
+  private void extractDocLocations(String startUrl) {
+    HttpClient client = new DefaultHttpClient();
+    HttpGet httpget = new HttpGet(startUrl);
+    HttpResponse resp = null;
+    try {
+      resp = client.execute(httpget);
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    HttpEntity entity = resp.getEntity();
+    if (entity != null) {
+      XMLInputFactory iFactory = XMLInputFactory.newInstance();
+      XMLStreamReader reader = null;
+      try {
+        reader = iFactory.createXMLStreamReader(entity.getContent());
+      } catch (IllegalStateException e1) {
+        e1.printStackTrace();
+      } catch (XMLStreamException e1) {
+        e1.printStackTrace();
+      } catch (IOException e1) {
+        e1.printStackTrace();
+      }
+
+      try {
+        while (true) {
+          int event = reader.next();
+          if (event == XMLStreamConstants.END_DOCUMENT) {
+            reader.close();
+            break;
+          }
+          if (event == XMLStreamConstants.START_ELEMENT) {
+            if ((reader.getAttributeValue(null, "name")) != null) {
+              if (reader.getLocalName().equals("collection") && !(startUrl.endsWith(reader.getAttributeValue(null, "name")))) {
+                if(!(this.excludes.contains(reader.getAttributeValue(null, "name").toLowerCase()))){
+                  if (reader.getAttributeValue(null, "name").startsWith("/")) {
+                    client.getConnectionManager().closeExpiredConnections();
+                    extractDocLocations(startUrl + reader.getAttributeValue(null, "name"));
+                  } else {
+                    client.getConnectionManager().closeExpiredConnections();
+                    if (!startUrl.endsWith("/")) {
+                      extractDocLocations(startUrl + "/" + reader.getAttributeValue(null, "name"));
+                    } else {
+                      extractDocLocations(startUrl + reader.getAttributeValue(null, "name"));
+                    }
+                  }
+                }
+              }
+              if (reader.getLocalName().equals("resource")) {
+                if (!startUrl.endsWith("/")) {
+                  ressourceLoc.add(startUrl + "/" + reader.getAttributeValue(null, "name"));
+                } else {
+                  ressourceLoc.add(startUrl + reader.getAttributeValue(null, "name"));
+                }
+              }
+            }
+          }
+          if (event == XMLStreamConstants.ATTRIBUTE) {
+            // System.out.println("localName : "+reader.getLocalName());
+          }
+        }
+      } catch (XMLStreamException e) {
+        e.printStackTrace();
+      }
+    }
+  }
+
+  /**
+   * extrahiert ebenso wie extractDocLocations(String startUri) Pfade, tut dies
+   * aber local und nicht über HTTP
+   * 
+   * @return
+   */
+  public List<String> extractPathLocally(String startUrl) {
+    List<String> pathList = new ArrayList<String>();
+
+    // home verzeichnis pfad über system variable
+    // String loc = System.getenv("HOME")+"/wsp/configs";
+    // out.println("hom variable + conf datei : "+loc);
+    File f = new File(startUrl);
+    // out.println("readable : "+Boolean.toString(f.canRead()));
+    // out.println("readable : "+f.isDirectory());
+    if (f.isDirectory()) {
+      File[] filelist = f.listFiles();
+      for (File file : filelist) {
+        if (file.getName().toLowerCase().contains("config")) {
+          if (!startUrl.endsWith("/")) {
+            pathList.add(startUrl + "/" + file.getName());
+          } else {
+            pathList.add(startUrl + file.getName());
+          }
+        }
+      }
+    }
+    return pathList;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/lucene/IndexHandler.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,1463 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.lucene;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.KeywordAnalyzer;
+import org.apache.lucene.analysis.PerFieldAnalyzerWrapper;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldSelector;
+import org.apache.lucene.document.Fieldable;
+import org.apache.lucene.document.SetBasedFieldSelector;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.IndexWriterConfig.OpenMode;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermEnum;
+import org.apache.lucene.index.TermFreqVector;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.FuzzyQuery;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.PhraseQuery;
+import org.apache.lucene.search.PrefixQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.SearcherManager;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TermRangeQuery;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.search.highlight.Highlighter;
+import org.apache.lucene.search.highlight.QueryScorer;
+import org.apache.lucene.search.highlight.SimpleHTMLFormatter;
+import org.apache.lucene.search.highlight.TextFragment;
+import org.apache.lucene.search.highlight.TokenSources;
+import org.apache.lucene.search.similar.MoreLikeThis;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.util.Version;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import com.sun.org.apache.xerces.internal.parsers.SAXParser;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.confmanager.CollectionReader;
+import de.mpg.mpiwg.berlin.mpdl.cms.confmanager.ConfManagerResultWrapper;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.DocumentHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Hits;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.MetadataRecord;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Token;
+import de.mpg.mpiwg.berlin.mpdl.cms.general.Constants;
+import de.mpg.mpiwg.berlin.mpdl.cms.scheduler.CmsDocOperation;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.XslResourceTransformer;
+import de.mpg.mpiwg.berlin.mpdl.cms.translator.MicrosoftTranslator;
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.db.LexHandler;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Form;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Lemma;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.norm.Normalizer;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.WordContentHandler;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.XmlTokenizer;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.XmlTokenizerContentHandler;
+import de.mpg.mpiwg.berlin.mpdl.util.StringUtils;
+import de.mpg.mpiwg.berlin.mpdl.util.Util;
+
+public class IndexHandler {
+  private static IndexHandler instance;
+  private IndexWriter documentsIndexWriter;
+  private IndexWriter nodesIndexWriter;
+  private SearcherManager documentsSearcherManager;
+  private SearcherManager nodesSearcherManager;
+  private IndexReader documentsIndexReader;
+  private PerFieldAnalyzerWrapper documentsPerFieldAnalyzer;
+  private PerFieldAnalyzerWrapper nodesPerFieldAnalyzer;
+
+
+  public static IndexHandler getInstance() throws ApplicationException {
+    if (instance == null) {
+      instance = new IndexHandler();
+      instance.init();
+    }
+    return instance;
+  }
+
+  private void init() throws ApplicationException {
+    documentsIndexWriter = getDocumentsWriter();
+    documentsIndexWriter.setMaxFieldLength(1000000);
+    nodesIndexWriter = getNodesWriter();
+    nodesIndexWriter.setMaxFieldLength(1000000);
+    documentsSearcherManager = getNewSearcherManager(documentsIndexWriter);
+    nodesSearcherManager = getNewSearcherManager(nodesIndexWriter);
+    documentsIndexReader = getDocumentsReader();
+  }
+
+  public void indexDocument(CmsDocOperation docOperation) throws ApplicationException {
+    try {
+      // first delete document in documentsIndex and nodesIndex
+      deleteDocumentLocal(docOperation);
+      indexDocumentLocal(docOperation);
+      documentsIndexWriter.commit();
+      nodesIndexWriter.commit();
+    } catch (Exception e) {
+      try {
+        documentsIndexWriter.rollback();
+        nodesIndexWriter.rollback();
+      } catch (Exception ex) {
+        // nothing
+      }
+      throw new ApplicationException(e);
+    }
+  }
+
+  private void indexDocumentLocal(CmsDocOperation docOperation) throws ApplicationException {
+    FileReader fr = null;
+    try {
+      MetadataRecord mdRecord = docOperation.getMdRecord();
+      String docId = mdRecord.getDocId();
+      DocumentHandler docHandler = new DocumentHandler();
+      String docFileName = docHandler.getDocFullFileName(docId) + ".upgrade";
+      // add document to documentsIndex
+      Document doc = new Document();
+      Field docIdField = new Field("docId", docId, Field.Store.YES, Field.Index.ANALYZED);
+      doc.add(docIdField);
+      String docIdSortedStr = docId.toLowerCase();  // so that sorting is lower case
+      Field docIdFieldSorted = new Field("docIdSorted", docIdSortedStr, Field.Store.YES, Field.Index.NOT_ANALYZED);
+      doc.add(docIdFieldSorted);
+      String identifier = mdRecord.getIdentifier();
+      if (identifier != null) {
+        Field identifierField = new Field("identifier", identifier, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(identifierField);
+      }
+      String uri = docOperation.getSrcUrl();
+      if (uri != null) {
+        Field uriField = new Field("uri", uri, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(uriField);
+      }
+      String collectionNames = docOperation.getCollectionNames();
+      if (collectionNames != null) {
+        Field collectionNamesField = new Field("collectionNames", collectionNames, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(collectionNamesField);
+      }
+      if (mdRecord.getCreator() != null) {
+        String authorStr = mdRecord.getCreator();
+        Field authorField = new Field("author", authorStr, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+        doc.add(authorField);
+        if (authorStr != null)
+          authorStr = authorStr.toLowerCase();  // so that sorting is lower case
+        Field authorFieldSorted = new Field("authorSorted", authorStr, Field.Store.YES, Field.Index.NOT_ANALYZED);
+        doc.add(authorFieldSorted);
+      }
+      if (mdRecord.getTitle() != null) {
+        String titleStr = mdRecord.getTitle();
+        Field titleField = new Field("title", titleStr, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+        doc.add(titleField);
+        if (titleStr != null)
+          titleStr = titleStr.toLowerCase();  // so that sorting is lower case
+        Field titleFieldSorted = new Field("titleSorted", titleStr, Field.Store.YES, Field.Index.NOT_ANALYZED);
+        doc.add(titleFieldSorted);
+      }
+      if (mdRecord.getLanguage() != null) {
+        String langStr =  mdRecord.getLanguage();
+        if (langStr != null)
+          langStr = langStr.toLowerCase();  // all language codes are lower case
+        Field languageField = new Field("language",langStr, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(languageField);
+        Field languageFieldSorted = new Field("languageSorted", langStr, Field.Store.YES, Field.Index.NOT_ANALYZED);
+        doc.add(languageFieldSorted);
+      }
+      if (mdRecord.getPublisher() != null) {
+        String publisherStr = mdRecord.getPublisher();
+        Field publisherField = new Field("publisher", publisherStr, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(publisherField);
+        if (publisherStr != null)
+          publisherStr = publisherStr.toLowerCase();  // so that sorting is lower case
+        Field publisherFieldSorted = new Field("publisherSorted", publisherStr, Field.Store.YES, Field.Index.NOT_ANALYZED);
+        doc.add(publisherFieldSorted);
+      }
+      if (mdRecord.getYear() != null) {
+        Field dateField = new Field("date", mdRecord.getYear(), Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(dateField);
+        Field dateFieldSorted = new Field("dateSorted", mdRecord.getYear(), Field.Store.YES, Field.Index.NOT_ANALYZED);
+        doc.add(dateFieldSorted);
+      }
+      if (mdRecord.getSubject() != null) {
+        Field subjectField = new Field("subject", mdRecord.getSubject(), Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(subjectField);
+      }
+      if (mdRecord.getRights() != null) {
+        Field rightsField = new Field("rights", mdRecord.getRights(), Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(rightsField);
+      }
+      if (mdRecord.getLicense() != null) {
+        Field licenseField = new Field("license", mdRecord.getLicense(), Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(licenseField);
+      }
+      if (mdRecord.getAccessRights() != null) {
+        Field accessRightsField = new Field("accessRights", mdRecord.getAccessRights(), Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(accessRightsField);
+      }
+      String echoId = mdRecord.getEchoId();
+      if (echoId != null) {
+        Field echoIdField = new Field("echoId", echoId, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(echoIdField);
+      }
+      String echoPageImageDir = mdRecord.getEchoPageImageDir();
+      if (echoPageImageDir != null) {
+        Field echoPageImageDirField = new Field("echoPageImageDir", echoPageImageDir, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(echoPageImageDirField);
+      }
+      String echoFiguresDir = mdRecord.getEchoFiguresDir();
+      if (echoFiguresDir != null) {
+        Field echoFiguresDirField = new Field("echoFiguresDir", echoFiguresDir, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(echoFiguresDirField);
+      }
+      String mpiwgDocId = mdRecord.getMpiwgDocId();
+      if (mpiwgDocId != null) {
+        Field mpiwgDocIdField = new Field("mpiwgDocId", mpiwgDocId, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(mpiwgDocIdField);
+      }
+      if (mdRecord.getLastModified() != null) {
+        Date lastModified = mdRecord.getLastModified();
+        String xsDateStr = new Util().toXsDate(lastModified);
+        Field lastModifiedField = new Field("lastModified", xsDateStr, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(lastModifiedField);
+        long time = lastModified.getTime();
+        String timeStr = String.valueOf(time);
+        Field lastModifiedFieldSorted = new Field("lastModifiedSorted", timeStr, Field.Store.YES, Field.Index.NOT_ANALYZED);
+        doc.add(lastModifiedFieldSorted);
+      }
+      if (mdRecord.getSchemaName() != null) {
+        String schemNameStr = mdRecord.getSchemaName();
+        Field schemaField = new Field("schemaName", schemNameStr, Field.Store.YES, Field.Index.ANALYZED);
+        doc.add(schemaField);
+        if (schemNameStr != null)
+          schemNameStr = schemNameStr.toLowerCase();  // so that sorting is lower case
+        Field schemaFieldSorted = new Field("schemaNameSorted", schemNameStr, Field.Store.YES, Field.Index.NOT_ANALYZED);
+        doc.add(schemaFieldSorted);
+      }
+
+      String language = mdRecord.getLanguage();
+      InputStreamReader docFileReader = new InputStreamReader(new FileInputStream(docFileName), "utf-8");
+      // to guarantee that utf-8 is used (if not done, it does not work on Tomcat which has another default charset)
+      XmlTokenizer docXmlTokenizer = new XmlTokenizer(docFileReader);
+      docXmlTokenizer.setDocIdentifier(docId);
+      docXmlTokenizer.setLanguage(language);
+      docXmlTokenizer.setOutputFormat("string");
+      String[] outputOptionsWithLemmas = { "withLemmas" }; // so all tokens are
+      // fetched with lemmas (costs performance)
+      docXmlTokenizer.setOutputOptions(outputOptionsWithLemmas);
+      String[] normFunctionNone = { "none" };
+      docXmlTokenizer.setNormFunctions(normFunctionNone);
+      docXmlTokenizer.tokenize();
+
+      int pageCount = docXmlTokenizer.getPageCount();
+      if (pageCount == 0)
+        pageCount = 1;  // each document at least has one page
+      String pageCountStr = String.valueOf(pageCount);
+      Field pageCountField = new Field("pageCount", pageCountStr, Field.Store.YES, Field.Index.ANALYZED);
+      doc.add(pageCountField);
+
+      String[] outputOptionsEmpty = {};
+      docXmlTokenizer.setOutputOptions(outputOptionsEmpty); 
+      // must be set to null so that the normalization function works
+      String docTokensOrig = docXmlTokenizer.getStringResult();
+      String[] normFunctionReg = { "reg" };
+      docXmlTokenizer.setNormFunctions(normFunctionReg);
+      String docTokensReg = docXmlTokenizer.getStringResult();
+      String[] normFunctionNorm = { "norm" };
+      docXmlTokenizer.setNormFunctions(normFunctionNorm);
+      String docTokensNorm = docXmlTokenizer.getStringResult();
+      docXmlTokenizer.setOutputOptions(outputOptionsWithLemmas);
+      String docTokensMorph = docXmlTokenizer.getStringResult();
+
+      Field tokenOrigField = new Field("tokenOrig", docTokensOrig, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+      Field tokenRegField = new Field("tokenReg", docTokensReg, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+      Field tokenNormField = new Field("tokenNorm", docTokensNorm, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+      Field tokenMorphField = new Field("tokenMorph", docTokensMorph, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+      doc.add(tokenOrigField);
+      doc.add(tokenRegField);
+      doc.add(tokenNormField);
+      doc.add(tokenMorphField);
+
+      // save original content of the doc file
+      File docFile = new File(docFileName);
+      String contentXml = FileUtils.readFileToString(docFile, "utf-8");
+      Field contentXmlField = new Field("xmlContent", contentXml, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+      doc.add(contentXmlField);
+
+      // generate original chars content
+      XslResourceTransformer charsTransformer = new XslResourceTransformer("chars.xsl");
+      String content = charsTransformer.transform(docFileName);
+      Field contentField = new Field("content", content, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+      doc.add(contentField);
+      
+      documentsIndexWriter.addDocument(doc);
+
+      // add all elements with the specified names of the document to nodesIndex
+      String[] elementNamesArray = docOperation.getElementNames();
+      String elementNames = "";
+      for (int i = 0; i < elementNamesArray.length; i++) {
+        String elemName = elementNamesArray[i];
+        elementNames = elementNames + elemName + " ";
+      }
+      elementNames = elementNames.substring(0, elementNames.length() - 1);
+      ArrayList<XmlTokenizerContentHandler.Element> elements = docXmlTokenizer.getElements(elementNames);
+      for (int i = 0; i < elements.size(); i++) {
+        XmlTokenizerContentHandler.Element element = elements.get(i);
+        Document nodeDoc = new Document();
+        nodeDoc.add(docIdField);
+        String nodeLanguage = element.lang;
+        if (nodeLanguage == null)
+          nodeLanguage = language;
+        String nodePageNumber = String.valueOf(element.pageNumber);
+        String nodeLineNumber = String.valueOf(element.lineNumber);
+        String nodeElementName = String.valueOf(element.name);
+        String nodeElementDocPosition = String.valueOf(element.docPosition);
+        String nodeElementAbsolutePosition = String.valueOf(element.position);
+        String nodeElementPagePosition = String.valueOf(element.pagePosition);
+        String nodeElementPosition = String.valueOf(element.elemPosition);
+        String nodeXmlId = element.xmlId;
+        String nodeXpath = element.xpath;
+        String nodeXmlContent = element.toXmlString();
+        String nodeTokensOrig = element.getTokensStr("orig");
+        String nodeTokensReg = element.getTokensStr("reg");
+        String nodeTokensNorm = element.getTokensStr("norm");
+        String nodeTokensMorph = element.getTokensStr("morph");
+        if (nodeLanguage != null) {
+          Field nodeLanguageField = new Field("language", nodeLanguage, Field.Store.YES, Field.Index.ANALYZED);
+          nodeDoc.add(nodeLanguageField);
+        }
+        Field nodePageNumberField = new Field("pageNumber", nodePageNumber, Field.Store.YES, Field.Index.ANALYZED);
+        nodeDoc.add(nodePageNumberField);
+        Field nodeLineNumberField = new Field("lineNumber", nodeLineNumber, Field.Store.YES, Field.Index.ANALYZED);
+        nodeDoc.add(nodeLineNumberField);
+        Field nodeElementNameField = new Field("elementName", nodeElementName, Field.Store.YES, Field.Index.ANALYZED);
+        nodeDoc.add(nodeElementNameField);
+        Field nodeElementDocPositionField = new Field("elementDocPosition", nodeElementDocPosition, Field.Store.YES, Field.Index.ANALYZED);
+        nodeDoc.add(nodeElementDocPositionField);
+        Field nodeElementDocPositionFieldSorted = new Field("elementDocPositionSorted", nodeElementDocPosition, Field.Store.YES, Field.Index.NOT_ANALYZED);
+        nodeDoc.add(nodeElementDocPositionFieldSorted);
+        Field nodeElementAbsolutePositionField = new Field("elementAbsolutePosition", nodeElementAbsolutePosition, Field.Store.YES, Field.Index.ANALYZED);
+        nodeDoc.add(nodeElementAbsolutePositionField);
+        Field nodeElementPagePositionField = new Field("elementPagePosition", nodeElementPagePosition, Field.Store.YES, Field.Index.ANALYZED);
+        nodeDoc.add(nodeElementPagePositionField);
+        Field nodeElementPositionField = new Field("elementPosition", nodeElementPosition, Field.Store.YES, Field.Index.ANALYZED);
+        nodeDoc.add(nodeElementPositionField);
+        if (nodeXmlId != null) {
+          Field nodeXmlIdField = new Field("xmlId", nodeXmlId, Field.Store.YES, Field.Index.ANALYZED);
+          nodeDoc.add(nodeXmlIdField);
+        }
+        if (nodeXpath != null) {
+          Field nodeXpathField = new Field("xpath", nodeXpath, Field.Store.YES, Field.Index.ANALYZED);
+          nodeDoc.add(nodeXpathField);
+        }
+        if (nodeXmlContent != null) {
+          Field nodeXmlContentField = new Field("xmlContent", nodeXmlContent, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+          nodeDoc.add(nodeXmlContentField);
+        }
+        if (nodeXmlContent != null) {
+          String nodeXmlContentTokenized = toTokenizedXmlString(nodeXmlContent, nodeLanguage);
+          byte[] blabla = nodeXmlContentTokenized.getBytes("utf-8");  // TODO why is tokenizedXmlStr not already utf-8 on page 444 Benedetti ?
+          nodeXmlContentTokenized = new String(blabla, "utf-8");
+          nodeXmlContentTokenized = enrichWordsOrigRegNorm(nodeXmlContentTokenized);
+          Field nodeXmlContentTokenizedField = new Field("xmlContentTokenized", nodeXmlContentTokenized, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+          nodeDoc.add(nodeXmlContentTokenizedField);
+        }
+        if (nodeTokensOrig != null) {
+          Field nodeTokenOrigField = new Field("tokenOrig", nodeTokensOrig, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+          nodeDoc.add(nodeTokenOrigField);
+        }
+        if (nodeTokensReg != null) {
+          Field nodeTokenRegField = new Field("tokenReg", nodeTokensReg, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+          nodeDoc.add(nodeTokenRegField);
+        }
+        if (nodeTokensNorm != null) {
+          Field nodeTokenNormField = new Field("tokenNorm", nodeTokensNorm, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+          nodeDoc.add(nodeTokenNormField);
+        }
+        if (nodeTokensMorph != null) {
+          Field nodeTokenMorphField = new Field("tokenMorph", nodeTokensMorph, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
+          nodeDoc.add(nodeTokenMorphField);
+        }
+
+        nodesIndexWriter.addDocument(nodeDoc);
+      }
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    } finally {
+      try {
+        if (fr != null)
+          fr.close();
+      } catch (Exception e) {
+        // nothing
+      }
+    }
+  }
+
+  public void deleteDocument(CmsDocOperation docOperation) throws ApplicationException {
+    try {
+      deleteDocumentLocal(docOperation);
+      documentsIndexWriter.commit();
+      nodesIndexWriter.commit();
+    } catch (Exception e) {
+      try {
+        documentsIndexWriter.rollback();
+        nodesIndexWriter.rollback();
+      } catch (Exception ex) {
+        // nothing
+      }
+      throw new ApplicationException(e);
+    }
+  }
+
+  private void deleteDocumentLocal(CmsDocOperation docOperation) throws ApplicationException {
+    String docId = docOperation.getDocIdentifier();
+    try {
+      Term termIdentifier = new Term("docId", docId);
+      documentsIndexWriter.deleteDocuments(termIdentifier);
+      nodesIndexWriter.deleteDocuments(termIdentifier);
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+  }
+
+  public Hits queryDocuments(String queryStr, String[] sortFieldNames, String language, int from, int to, boolean withHitFragments, boolean translate) throws ApplicationException {
+    Hits hits = null;
+    IndexSearcher searcher = null;
+    try {
+      makeDocumentsSearcherManagerUpToDate();
+      searcher = documentsSearcherManager.acquire();
+      String defaultQueryFieldName = "tokenOrig";
+      QueryParser queryParser = new QueryParser(Version.LUCENE_35, defaultQueryFieldName, documentsPerFieldAnalyzer);
+      Query query = null;
+      if (queryStr.equals("*")) {
+        query = new MatchAllDocsQuery();
+      } else {
+        query = queryParser.parse(queryStr);
+      }
+      Query morphQuery = buildMorphQuery(query, language, false, translate);
+      Query highlighterQuery = buildMorphQuery(query, language, true, translate);
+      if (query instanceof PhraseQuery || query instanceof PrefixQuery || query instanceof FuzzyQuery || query instanceof TermRangeQuery) {
+        highlighterQuery = query;  // TODO wenn sie rekursiv enthalten sind 
+      }
+      String beginHitMark = "!!!BEGIN_HIT!!!";
+      String endHitMark = "!!!END_HIT!!!";
+      SimpleHTMLFormatter htmlFormatter = new SimpleHTMLFormatter(beginHitMark, endHitMark);  // marks should not contain xml special chars
+      QueryScorer queryScorer = new QueryScorer(highlighterQuery);
+      Highlighter highlighter = new Highlighter(htmlFormatter, queryScorer);
+      TopDocs resultDocs = null;
+      if (sortFieldNames != null) {
+        Sort sort = buildSort(sortFieldNames, "doc");  // build sort criteria 
+        resultDocs = searcher.search(morphQuery, 10000, sort);
+      } else {
+        resultDocs = searcher.search(morphQuery, 10000);
+      }
+      resultDocs.setMaxScore(1);
+      int toTmp = to;
+      if (resultDocs.scoreDocs.length <= to)
+        toTmp = resultDocs.scoreDocs.length - 1;
+      if (resultDocs != null) {
+        ArrayList<de.mpg.mpiwg.berlin.mpdl.cms.document.Document>  docs = new ArrayList<de.mpg.mpiwg.berlin.mpdl.cms.document.Document>();
+        for (int i=from; i<=toTmp; i++) {
+          int docID = resultDocs.scoreDocs[i].doc;
+          FieldSelector docFieldSelector = getDocFieldSelector();
+          Document luceneDoc = searcher.doc(docID, docFieldSelector);
+          de.mpg.mpiwg.berlin.mpdl.cms.document.Document doc = new de.mpg.mpiwg.berlin.mpdl.cms.document.Document(luceneDoc);
+          if (withHitFragments) {
+            ArrayList<String> hitFragments = new ArrayList<String>();
+            Fieldable docContentField = luceneDoc.getFieldable("content");
+            if (docContentField != null) {
+              String docContent = docContentField.stringValue();
+              TokenStream tokenStream = TokenSources.getAnyTokenStream(this.documentsIndexReader, docID, docContentField.name(), luceneDoc, documentsPerFieldAnalyzer);
+              // highlighter.setMaxDocCharsToAnalyze(100000);  // the first 100000 chars are fetched maximal, but performance is not really better
+              TextFragment[] textfragments = highlighter.getBestTextFragments(tokenStream, docContent, false, 5);
+              if (textfragments.length > 0) {
+                for (int j=0; j<textfragments.length; j++) {
+                  String textFragment = textfragments[j].toString().trim();
+                  textFragment = StringUtils.deresolveXmlEntities(textFragment);
+                  textFragment = textFragment.replaceAll(beginHitMark, "<span class=\"highlight hit\">");
+                  textFragment = textFragment.replaceAll(endHitMark, "</span>");
+                  hitFragments.add(checkHitFragment(textFragment));
+                }
+              }
+            }
+            if (! hitFragments.isEmpty())
+              doc.setHitFragments(hitFragments);
+          }
+          docs.add(doc);
+        }
+        if (docs != null) {
+          hits = new Hits(docs, from, to);
+          hits.setSize(resultDocs.scoreDocs.length);
+          hits.setQuery(morphQuery);
+        }
+      }
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    } finally {
+      try {
+        if (searcher != null)
+          documentsSearcherManager.release(searcher);
+      } catch (IOException e) {
+        // nothing
+      }
+    }
+    // Do not use searcher after this!
+    searcher = null;
+    return hits;
+  }
+
+  public Hits queryDocument(String docId, String queryStr, int from, int to) throws ApplicationException {
+    Hits hits = null;
+    IndexSearcher searcher = null;
+    MetadataRecord docMetadataRecord = getDocMetadata(docId);
+    if (docMetadataRecord == null)
+      return null;  // no document with that docId is in index
+    try {
+      makeNodesSearcherManagerUpToDate();
+      searcher = nodesSearcherManager.acquire();
+      String fieldNameDocId = "docId";
+      Query queryDocId = new QueryParser(Version.LUCENE_35, fieldNameDocId, nodesPerFieldAnalyzer).parse(docId);
+      String defaultQueryFieldName = "tokenOrig";
+      Query query = new QueryParser(Version.LUCENE_35, defaultQueryFieldName, nodesPerFieldAnalyzer).parse(queryStr);
+      String language = docMetadataRecord.getLanguage();
+      if (language == null || language.equals("")) {
+        String collectionNames = docMetadataRecord.getCollectionNames();
+        ConfManagerResultWrapper collectionInfo = CollectionReader.getInstance().getResultWrapper(collectionNames);
+        if (collectionInfo != null) {
+          String mainLang = collectionInfo.getMainLanguage();
+          if (mainLang != null)
+            language = mainLang;
+        } 
+      }
+      Query morphQuery = buildMorphQuery(query, language);
+      BooleanQuery queryDoc = new BooleanQuery();
+      queryDoc.add(queryDocId, BooleanClause.Occur.MUST);
+      queryDoc.add(morphQuery, BooleanClause.Occur.MUST);
+      String[] sortFieldNames = {"elementDocPosition"};
+      Sort sortByPosition = buildSort(sortFieldNames, "node");
+      TopDocs topDocs = searcher.search(queryDoc, 100000, sortByPosition);
+      topDocs.setMaxScore(1);
+      int toTmp = to;
+      if (topDocs.scoreDocs.length <= to)
+        toTmp = topDocs.scoreDocs.length - 1;
+      if (topDocs != null) {
+        ArrayList<de.mpg.mpiwg.berlin.mpdl.cms.document.Document>  docs = new ArrayList<de.mpg.mpiwg.berlin.mpdl.cms.document.Document>();
+        for (int i=from; i<=toTmp; i++) {
+          int docID = topDocs.scoreDocs[i].doc;
+          FieldSelector nodeFieldSelector = getNodeFieldSelector();
+          Document luceneDoc = searcher.doc(docID, nodeFieldSelector);
+          de.mpg.mpiwg.berlin.mpdl.cms.document.Document doc = new de.mpg.mpiwg.berlin.mpdl.cms.document.Document(luceneDoc);
+          docs.add(doc);
+        }
+        if (docs != null) {
+          hits = new Hits(docs, from, to);
+          hits.setSize(topDocs.scoreDocs.length);
+        }
+      }
+      searcher.close();
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    } finally {
+      try {
+        if (searcher != null)
+          documentsSearcherManager.release(searcher);
+      } catch (IOException e) {
+        // nothing
+      }
+    }
+    // Do not use searcher after this!
+    searcher = null;
+    return hits;
+  }
+
+  public Hits moreLikeThis(String docId, int from, int to) throws ApplicationException {
+    Hits hits = null;
+    ArrayList<de.mpg.mpiwg.berlin.mpdl.cms.document.Document>  wspDocs = null;
+    IndexSearcher searcher1 = null;
+    IndexSearcher searcher2 = null;
+    try {
+      makeDocumentsSearcherManagerUpToDate();
+      searcher1 = documentsSearcherManager.acquire();
+      String fieldNameDocId = "docId";
+      Query queryDocId = new QueryParser(Version.LUCENE_35, fieldNameDocId, documentsPerFieldAnalyzer).parse(docId);
+      TopDocs topDocs = searcher1.search(queryDocId, 100000);
+      topDocs.setMaxScore(1);
+      int docID = -1;
+      if (topDocs != null && topDocs.scoreDocs != null && topDocs.scoreDocs.length > 0) {
+        docID = topDocs.scoreDocs[0].doc;
+      }
+      makeDocumentsSearcherManagerUpToDate();
+      searcher2 = documentsSearcherManager.acquire();
+      MoreLikeThis mlt = new MoreLikeThis(documentsIndexReader);  // TODO documentsIndexReader is ok ?
+      mlt.setFieldNames(new String[]{"content"});  // similarity function works against these fields
+      mlt.setMinWordLen(2);
+      mlt.setBoost(true);
+      Query queryMoreLikeThis = mlt.like(docID);
+      TopDocs moreLikeThisDocs = searcher2.search(queryMoreLikeThis, 10);
+      moreLikeThisDocs.setMaxScore(10);
+      if (moreLikeThisDocs != null) { 
+        if (wspDocs == null)
+          wspDocs = new ArrayList<de.mpg.mpiwg.berlin.mpdl.cms.document.Document>();
+        for (int i=0; i<moreLikeThisDocs.scoreDocs.length; i++) {
+          int docIdent = moreLikeThisDocs.scoreDocs[i].doc;
+          Document luceneDoc = searcher2.doc(docIdent);
+          de.mpg.mpiwg.berlin.mpdl.cms.document.Document wspDoc = new de.mpg.mpiwg.berlin.mpdl.cms.document.Document(luceneDoc);
+          wspDocs.add(wspDoc);
+        }
+      }
+      if (wspDocs != null) {
+        hits = new Hits(wspDocs, from, to);
+        hits.setSize(moreLikeThisDocs.scoreDocs.length);
+      }
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    } finally {
+      try {
+        if (searcher1 != null)
+          documentsSearcherManager.release(searcher1);
+        if (searcher2 != null)
+          documentsSearcherManager.release(searcher2);
+      } catch (IOException e) {
+        // nothing
+      }
+    }
+    // Do not use searcher after this!
+    searcher1 = null;
+    searcher2 = null;    
+    return hits;
+  }
+  
+  public MetadataRecord getDocMetadata(String docId) throws ApplicationException {
+    MetadataRecord mdRecord = null;
+    Document doc = getDocument(docId);
+    if (doc != null) {
+      String identifier = null;
+      Fieldable identifierField = doc.getFieldable("identifier");
+      if (identifierField != null)
+        identifier = identifierField.stringValue();
+      String uri = null;
+      Fieldable uriField = doc.getFieldable("uri");
+      if (uriField != null)
+        uri = uriField.stringValue();
+      String collectionNames = null;
+      Fieldable collectionNamesField = doc.getFieldable("collectionNames");
+      if (collectionNamesField != null)
+        collectionNames = collectionNamesField.stringValue();
+      String author = null;
+      Fieldable authorField = doc.getFieldable("author");
+      if (authorField != null)
+        author = authorField.stringValue();
+      String title = null;
+      Fieldable titleField = doc.getFieldable("title");
+      if (titleField != null)
+        title = titleField.stringValue();
+      String language = null;
+      Fieldable languageField = doc.getFieldable("language");
+      if (languageField != null)
+        language = languageField.stringValue();
+      else {
+        ConfManagerResultWrapper collectionInfo = CollectionReader.getInstance().getResultWrapper(collectionNames);
+        if (collectionInfo != null) {
+          String mainLang = collectionInfo.getMainLanguage();
+          if (mainLang != null)
+            language = mainLang;
+        } 
+      }
+      String publisher = null;
+      Fieldable publisherField = doc.getFieldable("publisher");
+      if (publisherField != null)
+        publisher = publisherField.stringValue();
+      Date yearDate = null;
+      Fieldable dateField = doc.getFieldable("date");
+      if (dateField != null) {
+        String dateStr = dateField.stringValue();
+        if (dateStr != null && !dateStr.equals("")) {
+          dateStr = StringUtils.deresolveXmlEntities(dateStr);
+          String yearStr = new Util().toYearStr(dateStr); // test if possible
+          // etc
+          if (yearStr != null) {
+            yearDate = new Util().toDate(yearStr + "-01-01T00:00:00.000Z");
+          }
+        }
+      }
+      String rights = null;
+      Fieldable rightsField = doc.getFieldable("rights");
+      if (rightsField != null)
+        rights = rightsField.stringValue();
+      String license = null;
+      Fieldable licenseField = doc.getFieldable("license");
+      if (licenseField != null)
+        license = licenseField.stringValue();
+      String accessRights = null;
+      Fieldable accessRightsField = doc.getFieldable("accessRights");
+      if (accessRightsField != null)
+        accessRights = accessRightsField.stringValue();
+      String echoId = null;
+      Fieldable echoIdField = doc.getFieldable("echoId");
+      if (echoIdField != null)
+        echoId = echoIdField.stringValue();
+      String echoPageImageDir = null;
+      Fieldable echoPageImageDirField = doc.getFieldable("echoPageImageDir");
+      if (echoPageImageDirField != null)
+        echoPageImageDir = echoPageImageDirField.stringValue();
+      String echoFiguresDir = null;
+      Fieldable echoFiguresDirField = doc.getFieldable("echoFiguresDir");
+      if (echoFiguresDirField != null)
+        echoFiguresDir = echoFiguresDirField.stringValue();
+      String mpiwgDocId = null;
+      Fieldable mpiwgDocIdField = doc.getFieldable("mpiwgDocId");
+      if (mpiwgDocIdField != null)
+        mpiwgDocId = mpiwgDocIdField.stringValue();
+      int pageCount = -1;
+      Fieldable pageCountField = doc.getFieldable("pageCount");
+      if (pageCountField != null) {
+        String pageCountStr = pageCountField.stringValue();
+        pageCount = Integer.valueOf(pageCountStr);
+      }
+      String schemaName = null;
+      Fieldable schemaNameField = doc.getFieldable("schemaName");
+      if (schemaNameField != null)
+        schemaName = schemaNameField.stringValue();
+      Date lastModified = null;
+      Fieldable lastModifiedField = doc.getFieldable("lastModified");
+      if (lastModifiedField != null) {
+        String lastModifiedXSDateStr = lastModifiedField.stringValue();
+        lastModified = new Util().toDate(lastModifiedXSDateStr);
+      }
+      mdRecord = new MetadataRecord();
+      mdRecord.setDocId(docId);
+      mdRecord.setUri(uri);
+      mdRecord.setIdentifier(identifier);
+      mdRecord.setCollectionNames(collectionNames);
+      mdRecord.setCreator(author);
+      mdRecord.setTitle(title);
+      mdRecord.setDate(yearDate);
+      mdRecord.setLanguage(language);
+      mdRecord.setPublisher(publisher);
+      mdRecord.setLicense(license);
+      mdRecord.setRights(rights);
+      mdRecord.setAccessRights(accessRights);
+      mdRecord.setEchoId(echoId);
+      mdRecord.setEchoPageImageDir(echoPageImageDir);
+      mdRecord.setEchoFiguresDir(echoFiguresDir);
+      mdRecord.setMpiwgDocId(mpiwgDocId);
+      mdRecord.setPageCount(pageCount);
+      mdRecord.setSchemaName(schemaName);
+      mdRecord.setLastModified(lastModified);
+    }
+    return mdRecord;
+  }
+
+  public ArrayList<Token> getToken(String fieldName, String value, int count) throws ApplicationException {
+    ArrayList<Token> retToken = null;
+    int counter = 0;
+    TermEnum terms = null;
+    try {
+      if (value == null)
+        value = "";
+      Term term = new Term(fieldName, value);
+      makeIndexReaderUpToDate();
+      terms = documentsIndexReader.terms(term);
+      while (terms != null && fieldName != null && fieldName.equals(terms.term().field()) && counter < count) {
+        if (retToken == null)
+          retToken = new ArrayList<Token>();
+        Term termContent = terms.term();
+        Token token = new Token(termContent);
+        retToken.add(token);
+        counter++;
+        if (!terms.next())
+          break;
+      }
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    } finally {
+      if (terms != null) {
+        try {
+          terms.close();
+        } catch (IOException e) {
+          // nothing
+        }
+      }
+    }
+    return retToken;
+  }
+
+  public ArrayList<Token> getToken(String docId, String fieldName, String value, int count) throws ApplicationException {
+    ArrayList<Token> retToken = null;
+    if (value == null)
+      value = "";
+    int counter = 0;
+    IndexSearcher searcher = null;
+    try {
+      makeDocumentsSearcherManagerUpToDate();
+      makeIndexReaderUpToDate();
+      searcher = documentsSearcherManager.acquire();
+      Query queryDocId = new TermQuery(new Term("docId", docId));
+      TopDocs topDocs = searcher.search(queryDocId, 1);
+      if (topDocs != null) {
+        int docIdInt = topDocs.scoreDocs[0].doc;
+        TermFreqVector termFreqVector = documentsIndexReader.getTermFreqVector(docIdInt, fieldName);
+        if (termFreqVector != null) {
+          String[] terms = termFreqVector.getTerms();
+          int[] freqs = termFreqVector.getTermFrequencies();
+          boolean success = false;
+          if (terms != null) {
+            retToken = new ArrayList<Token>();
+            for (int i = 0; i < terms.length; i++) {
+              String termStr = terms[i];
+              if (termStr.startsWith(value))
+                success = true;
+              if (success) {
+                counter++;
+                int freq = freqs[i];
+                Term t = new Term(fieldName, termStr);
+                Token tok = new Token(t);
+                tok.setFreq(freq);
+                retToken.add(tok);
+              }
+              if (counter >= count)
+                break;
+            }
+          }
+        }
+      }
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    } finally {
+      try {
+        if (searcher != null)
+          documentsSearcherManager.release(searcher);
+      } catch (IOException e) {
+        // nothing
+      }
+    }
+    // Do not use searcher after this!
+    searcher = null;
+    return retToken;
+  }
+
+  public void end() throws ApplicationException {
+    try {
+      if (documentsIndexWriter != null)
+        documentsIndexWriter.close();
+      if (nodesIndexWriter != null)
+        nodesIndexWriter.close();
+      if (documentsSearcherManager != null)
+        documentsSearcherManager.close();
+      if (nodesSearcherManager != null)
+        nodesSearcherManager.close();
+      if (documentsIndexReader != null)
+        documentsIndexReader.close();
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+
+  private Query buildMorphQuery(Query query, String language) throws ApplicationException {
+    return buildMorphQuery(query, language, false, false);
+  }
+
+  private Query buildMorphQuery(Query query, String language, boolean withAllForms, boolean translate) throws ApplicationException {
+    Query morphQuery = null;
+    if (query instanceof TermQuery) {
+      TermQuery termQuery = (TermQuery) query;
+      morphQuery = buildMorphQuery(termQuery, language, withAllForms, translate);
+    } else if (query instanceof BooleanQuery) {
+      BooleanQuery booleanQuery = (BooleanQuery) query;
+      morphQuery = buildMorphQuery(booleanQuery, language, withAllForms, translate);
+    } else {
+      morphQuery = query; // all other cases: PrefixQuery, PhraseQuery, FuzzyQuery, TermRangeQuery, ...
+    }
+    return morphQuery;
+  }
+
+  private Query buildMorphQuery(TermQuery inputTermQuery, String fromLang, boolean withAllForms, boolean translate) throws ApplicationException {
+    String[] toLanguages = {"deu", "eng", "fra"};  // TODO
+    String fromLanguage = null;
+    String inputTerm = inputTermQuery.getTerm().text();
+    if (fromLang == null) {
+      String detectedLang = MicrosoftTranslator.detectLanguageCode(inputTerm);
+      if (detectedLang != null)
+        fromLanguage = detectedLang;
+    } else {
+      fromLanguage = fromLang;
+    }
+    LexHandler lexHandler = LexHandler.getInstance();
+    String fieldName = inputTermQuery.getTerm().field();
+    ArrayList<TermQuery> queryTerms = new ArrayList<TermQuery>();
+    if (fieldName != null && fieldName.equals("tokenMorph")) {
+      ArrayList<Lemma> lemmas = lexHandler.getLemmas(inputTerm, "form", fromLanguage, Normalizer.DICTIONARY, true);
+      if (lemmas == null) {  // if no lemmas are found then do a query in tokenOrig TODO should this really be done ?
+        if (translate) {
+          String[] terms = {inputTerm};
+          ArrayList<String> translatedTerms = MicrosoftTranslator.translate(terms, fromLanguage, toLanguages);
+          for (int i=0; i<translatedTerms.size(); i++) {
+            String translatedTerm = translatedTerms.get(i);
+            Term translatedTermTokenOrig = new Term("tokenOrig", translatedTerm);
+            TermQuery translatedTermQueryInTokenOrig = new TermQuery(translatedTermTokenOrig);
+            queryTerms.add(translatedTermQueryInTokenOrig);
+          }
+        } else {
+          Term termTokenOrig = new Term("tokenOrig", inputTerm);
+          TermQuery termQueryInTokenOrig = new TermQuery(termTokenOrig);
+          queryTerms.add(termQueryInTokenOrig);
+        }
+      } else {
+        if (translate) {
+          ArrayList<String> morphTerms = new ArrayList<String>();
+          for (int i=0; i<lemmas.size(); i++) {
+            Lemma lemma = lemmas.get(i);
+            if (withAllForms) { // all word forms are put into the query as boolean or clauses: needed in fragments search when all forms should be highlighted
+              ArrayList<Form> forms = lemma.getFormsList();
+              for (int j=0; j<forms.size(); j++) {
+                Form form = forms.get(j);
+                String formName = form.getFormName();
+                morphTerms.add(formName);
+              } 
+            } else {
+              String lemmaName = lemma.getLemmaName();
+              morphTerms.add(lemmaName);
+            }
+          }
+          String[] morphTermsArray = morphTerms.toArray(new String[morphTerms.size()]);
+          ArrayList<String> translatedMorphTerms = MicrosoftTranslator.translate(morphTermsArray, fromLanguage, toLanguages);
+          for (int i=0; i<translatedMorphTerms.size(); i++) {
+            String translatedMorphTermStr = translatedMorphTerms.get(i);
+            Term translatedMorphTerm = new Term(fieldName, translatedMorphTermStr);
+            TermQuery translatedMorphTermQuery = new TermQuery(translatedMorphTerm);
+            queryTerms.add(translatedMorphTermQuery);
+          }
+        } else {
+          for (int i = 0; i < lemmas.size(); i++) {
+            Lemma lemma = lemmas.get(i);
+            if (withAllForms) { // all word forms are put into the query as boolean or clauses: needed in fragments search when all forms should be highlighted
+              ArrayList<Form> forms = lemma.getFormsList();
+              for (int j=0; j<forms.size(); j++) {
+                Form form = forms.get(j);
+                Term formTerm = new Term(fieldName, form.getFormName());
+                TermQuery morphTermQuery = new TermQuery(formTerm);
+                queryTerms.add(morphTermQuery);
+              } 
+            } else {
+              Term lemmaTerm = new Term(fieldName, lemma.getLemmaName());
+              TermQuery morphTermQuery = new TermQuery(lemmaTerm);
+              queryTerms.add(morphTermQuery);
+            }
+          }
+        }
+      }
+    } else {
+      // if it is not the morph field then do a normal query 
+      if (translate) {
+        String inputTermQueryField = inputTermQuery.getTerm().field();
+        String inputTermQueryStr = inputTermQuery.getTerm().text();
+        String[] terms = {inputTermQueryStr};
+        ArrayList<String> translatedTerms = MicrosoftTranslator.translate(terms, fromLanguage, toLanguages);
+        for (int i=0; i<translatedTerms.size(); i++) {
+          String translatedTerm = translatedTerms.get(i);
+          Term translatedTermTokenOrig = new Term(inputTermQueryField, translatedTerm);
+          TermQuery translatedTermQueryInTokenOrig = new TermQuery(translatedTermTokenOrig);
+          queryTerms.add(translatedTermQueryInTokenOrig);
+        }
+      } else {
+        queryTerms.add(inputTermQuery);
+      }
+      //TODO ?? perhaps other fields should also be queried morphological e.g. title etc.
+    }
+    Query retQuery = buildBooleanShouldQuery(queryTerms);
+    return retQuery;
+  }
+
+  private Query buildBooleanShouldQuery(ArrayList<TermQuery> queryTerms) throws ApplicationException {
+    BooleanQuery retBooleanQuery = new BooleanQuery();
+    for (int i = 0; i < queryTerms.size(); i++) {
+      TermQuery termQuery = queryTerms.get(i);
+      retBooleanQuery.add(termQuery, BooleanClause.Occur.SHOULD);
+    }
+    return retBooleanQuery;
+  }
+  
+  private Query buildMorphQuery(BooleanQuery query, String language, boolean withAllForms, boolean translate) throws ApplicationException {
+    BooleanQuery morphBooleanQuery = new BooleanQuery();
+    BooleanClause[] booleanClauses = query.getClauses();
+    for (int i = 0; i < booleanClauses.length; i++) {
+      BooleanClause boolClause = booleanClauses[i];
+      Query q = boolClause.getQuery();
+      Query morphQuery = buildMorphQuery(q, language, withAllForms, translate);
+      BooleanClause.Occur occur = boolClause.getOccur();
+      morphBooleanQuery.add(morphQuery, occur);
+    }
+    return morphBooleanQuery;
+  }
+
+  public ArrayList<String> fetchTerms(String queryStr) throws ApplicationException {
+    ArrayList<String> terms = null;
+    String defaultQueryFieldName = "tokenOrig";
+    try {
+      Query query = new QueryParser(Version.LUCENE_35, defaultQueryFieldName, nodesPerFieldAnalyzer).parse(queryStr);
+      terms = fetchTerms(query);
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return terms;
+  }
+
+  /**
+   * recursively fetch all terms of the query
+   * 
+   * @param query
+   * @return
+   */
+  private ArrayList<String> fetchTerms(Query query) throws ApplicationException {
+    ArrayList<String> terms = new ArrayList<String>();
+    if (query instanceof TermQuery) {
+      TermQuery termQuery = (TermQuery) query;
+      String termQueryStr = termQuery.getTerm().text();
+      terms.add(termQueryStr);
+    } else if (query instanceof BooleanQuery) {
+      BooleanQuery booleanQuery = (BooleanQuery) query;
+      terms = fetchTerms(booleanQuery);
+    } else {
+      String queryStr = query.toString();
+      terms.add(queryStr); // all other cases: PrefixQuery, PhraseQuery,
+      // FuzzyQuery, TermRangeQuery, ...
+    }
+    return terms;
+  }
+
+  private ArrayList<String> fetchTerms(BooleanQuery query) throws ApplicationException {
+    ArrayList<String> terms = new ArrayList<String>();
+    BooleanClause[] booleanClauses = query.getClauses();
+    for (int i = 0; i < booleanClauses.length; i++) {
+      BooleanClause boolClause = booleanClauses[i];
+      Query q = boolClause.getQuery();
+      ArrayList<String> qTerms = fetchTerms(q);
+      BooleanClause.Occur occur = boolClause.getOccur();
+      if (occur == BooleanClause.Occur.SHOULD || occur == BooleanClause.Occur.MUST)
+        terms.addAll(qTerms);
+    }
+    return terms;
+  }
+
+  public ArrayList<String> fetchTerms(String queryStr, String language) throws ApplicationException {
+    ArrayList<String> terms = null;
+    String defaultQueryFieldName = "tokenOrig";
+    try {
+      Query query = new QueryParser(Version.LUCENE_35, defaultQueryFieldName, nodesPerFieldAnalyzer).parse(queryStr);
+      terms = fetchTerms(query, language);
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return terms;
+  }
+
+  /**
+   * recursively fetch all terms of the query
+   * 
+   * @param query
+   * @return
+   */
+  private ArrayList<String> fetchTerms(Query query, String language) throws ApplicationException {
+    ArrayList<String> terms = new ArrayList<String>();
+    if (query instanceof TermQuery) {
+      TermQuery termQuery = (TermQuery) query;
+      terms = fetchTerms(termQuery, language);
+    } else if (query instanceof BooleanQuery) {
+      BooleanQuery booleanQuery = (BooleanQuery) query;
+      terms = fetchTerms(booleanQuery, language);
+    } else {
+      String queryStr = query.toString();
+      terms.add(queryStr); 
+      // all other cases: PrefixQuery, PhraseQuery, FuzzyQuery, TermRangeQuery, ...
+    }
+    return terms;
+  }
+
+  private ArrayList<String> fetchTerms(TermQuery termQuery, String language) throws ApplicationException {
+    if (language == null)
+      language = "eng";
+    ArrayList<String> terms = new ArrayList<String>();
+    Term termQueryTerm = termQuery.getTerm();
+    String term = termQuery.getTerm().text();
+    String fieldName = termQueryTerm.field();
+    if (fieldName != null && fieldName.equals("tokenMorph")) {
+      LexHandler lexHandler = LexHandler.getInstance();
+      ArrayList<Lemma> lemmas = lexHandler.getLemmas(term, "form", language, Normalizer.DICTIONARY, true); 
+      // TODO : language über den translator service holen
+      if (lemmas == null) {
+        terms.add(term);
+      } else {
+        for (int i = 0; i < lemmas.size(); i++) {
+          Lemma lemma = lemmas.get(i);
+          ArrayList<Form> forms = lemma.getFormsList();
+          for (int j = 0; j < forms.size(); j++) {
+            Form form = forms.get(j);
+            String formName = form.getFormName();
+            terms.add(formName);
+          }
+        }
+      }
+    } else {
+      terms.add(term);
+    }
+    return terms;
+  }
+
+  private ArrayList<String> fetchTerms(BooleanQuery query, String language) throws ApplicationException {
+    ArrayList<String> terms = new ArrayList<String>();
+    BooleanClause[] booleanClauses = query.getClauses();
+    for (int i = 0; i < booleanClauses.length; i++) {
+      BooleanClause boolClause = booleanClauses[i];
+      Query q = boolClause.getQuery();
+      ArrayList<String> qTerms = fetchTerms(q, language);
+      BooleanClause.Occur occur = boolClause.getOccur();
+      if (occur == BooleanClause.Occur.SHOULD || occur == BooleanClause.Occur.MUST)
+        terms.addAll(qTerms);
+    }
+    return terms;
+  }
+
+  private Document getDocument(String docId) throws ApplicationException {
+    Document doc = null;
+    IndexSearcher searcher = null;
+    try {
+      makeDocumentsSearcherManagerUpToDate();
+      searcher = documentsSearcherManager.acquire();
+      String fieldNameDocId = "docId";
+      Query queryDocId = new QueryParser(Version.LUCENE_35, fieldNameDocId, documentsPerFieldAnalyzer).parse(docId);
+      TopDocs topDocs = searcher.search(queryDocId, 100000);
+      topDocs.setMaxScore(1);
+      if (topDocs != null && topDocs.scoreDocs != null && topDocs.scoreDocs.length > 0) {
+        int docID = topDocs.scoreDocs[0].doc;
+        FieldSelector docFieldSelector = getDocFieldSelector();
+        doc = searcher.doc(docID, docFieldSelector);
+      }
+      searcher.close();
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    } finally {
+      try {
+        if (searcher != null)
+          documentsSearcherManager.release(searcher);
+      } catch (IOException e) {
+        // nothing
+      }
+    }
+    // Do not use searcher after this!
+    searcher = null;
+    return doc;
+  }
+  
+  private IndexWriter getDocumentsWriter() throws ApplicationException {
+    IndexWriter writer = null;
+    String luceneDocsDirectoryStr = Constants.getInstance().getLuceneDocumentsDir();
+    File luceneDocsDirectory = new File(luceneDocsDirectoryStr);
+    try {
+      Map<String, Analyzer> documentsFieldAnalyzers = new HashMap<String, Analyzer>();
+      documentsFieldAnalyzers.put("docId", new KeywordAnalyzer());
+      documentsFieldAnalyzers.put("identifier", new KeywordAnalyzer());
+      documentsFieldAnalyzers.put("uri", new KeywordAnalyzer());
+      documentsFieldAnalyzers.put("collectionNames", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("author", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("title", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("language", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("publisher", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("date", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("subject", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("rights", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("license", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("accessRights", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("echoId", new KeywordAnalyzer());
+      documentsFieldAnalyzers.put("echoPageImageDir", new KeywordAnalyzer());
+      documentsFieldAnalyzers.put("echoFiguresDir", new KeywordAnalyzer());
+      documentsFieldAnalyzers.put("mpiwgDocId", new KeywordAnalyzer());
+      documentsFieldAnalyzers.put("type", new KeywordAnalyzer()); // e.g. mime type "text/xml"
+      documentsFieldAnalyzers.put("pageCount", new KeywordAnalyzer());
+      documentsFieldAnalyzers.put("schemaName", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("lastModified", new KeywordAnalyzer());
+      documentsFieldAnalyzers.put("tokenOrig", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("tokenReg", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("tokenNorm", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("tokenMorph", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("xmlContent", new StandardAnalyzer(Version.LUCENE_35));
+      documentsFieldAnalyzers.put("content", new StandardAnalyzer(Version.LUCENE_35));
+      documentsPerFieldAnalyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_35), documentsFieldAnalyzers);
+      IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_35, documentsPerFieldAnalyzer);
+      conf.setOpenMode(OpenMode.CREATE_OR_APPEND);
+      conf.setRAMBufferSizeMB(300);  // 300 MB because some documents are big; 16 MB is default 
+      FSDirectory fsDirectory = FSDirectory.open(luceneDocsDirectory);
+      writer = new IndexWriter(fsDirectory, conf);
+      writer.commit(); // when directory is empty this creates init files
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+    return writer;
+  }
+
+  private IndexWriter getNodesWriter() throws ApplicationException {
+    IndexWriter writer = null;
+    String luceneNodesDirectoryStr = Constants.getInstance().getLuceneNodesDir();
+    File luceneNodesDirectory = new File(luceneNodesDirectoryStr);
+    try {
+      Map<String, Analyzer> nodesFieldAnalyzers = new HashMap<String, Analyzer>();
+      nodesFieldAnalyzers.put("docId", new KeywordAnalyzer());
+      nodesFieldAnalyzers.put("language", new StandardAnalyzer(Version.LUCENE_35)); // language (through xml:id): e.g. "lat"
+      nodesFieldAnalyzers.put("pageNumber", new KeywordAnalyzer()); // page number (through element pb): e.g. "13"
+      nodesFieldAnalyzers.put("lineNumber", new KeywordAnalyzer()); // line number on the page (through element lb): e.g. "17"
+      nodesFieldAnalyzers.put("elementName", new KeywordAnalyzer()); // element name: e.g. "tei:s"
+      nodesFieldAnalyzers.put("elementDocPosition", new KeywordAnalyzer()); // absolute position in document: e.g. "4711"
+      nodesFieldAnalyzers.put("elementPosition", new KeywordAnalyzer()); // position in parent node (in relation to other nodes of the same name): e.g. "5"
+      nodesFieldAnalyzers.put("elementAbsolutePosition", new KeywordAnalyzer()); // absolute position in document (in relation to other nodes of the same name): e.g. "213"
+      nodesFieldAnalyzers.put("elementPagePosition", new KeywordAnalyzer()); // position in relation to other nodes of the same name: e.g. "213"
+      nodesFieldAnalyzers.put("xmlId", new KeywordAnalyzer()); // xml id: e.g. "4711bla"
+      nodesFieldAnalyzers.put("xpath", new KeywordAnalyzer()); // xpath: e.g. "/echo[1]/text[1]/p[1]/s[5]"
+      nodesFieldAnalyzers.put("tokenOrig", new StandardAnalyzer(Version.LUCENE_35));
+      nodesFieldAnalyzers.put("tokenReg", new StandardAnalyzer(Version.LUCENE_35));
+      nodesFieldAnalyzers.put("tokenNorm", new StandardAnalyzer(Version.LUCENE_35));
+      nodesFieldAnalyzers.put("tokenMorph", new StandardAnalyzer(Version.LUCENE_35));
+      nodesFieldAnalyzers.put("xmlContent", new StandardAnalyzer(Version.LUCENE_35));
+      nodesPerFieldAnalyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_35), nodesFieldAnalyzers);
+      IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_35, nodesPerFieldAnalyzer);
+      conf.setOpenMode(OpenMode.CREATE_OR_APPEND);
+      conf.setRAMBufferSizeMB(300);  // 300 MB because some documents are big; 16 MB is default 
+      FSDirectory fsDirectory = FSDirectory.open(luceneNodesDirectory);
+      writer = new IndexWriter(fsDirectory, conf);
+      writer.commit();
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+    return writer;
+  }
+
+  private Sort buildSort(String[] sortFieldNames, String type) {
+    Sort sort = new Sort();
+    ArrayList<SortField> sortFields = new ArrayList<SortField>();
+    for (int i=0; i<sortFieldNames.length; i++) {
+      String sortFieldName = sortFieldNames[i];
+      int sortFieldType = getDocSortFieldType(sortFieldName);
+      if (type.equals("node"))
+        sortFieldType = getNodeSortFieldType(sortFieldName);
+      String realSortFieldName = getDocSortFieldName(sortFieldName);
+      SortField sortField = new SortField(realSortFieldName, sortFieldType);
+      sortFields.add(sortField);
+    }
+    if (sortFieldNames.length == 1) {
+      SortField sortField1 = sortFields.get(0);
+      sort.setSort(sortField1);
+    } else if (sortFieldNames.length == 2) {
+      SortField sortField1 = sortFields.get(0);
+      SortField sortField2 = sortFields.get(1);
+      sort.setSort(sortField1, sortField2);
+    } else if (sortFieldNames.length == 2) {
+      SortField sortField1 = sortFields.get(0);
+      SortField sortField2 = sortFields.get(1);
+      SortField sortField3 = sortFields.get(2);
+      sort.setSort(sortField1, sortField2, sortField3);
+    }
+    return sort;
+  }
+
+  private String getDocSortFieldName(String fieldName) {
+    String sortFieldName = fieldName + "Sorted";
+    return sortFieldName;
+  }
+
+  private int getDocSortFieldType(String fieldName) {
+    int type = SortField.STRING;
+    if (fieldName.equals("lastModified"))
+      type = SortField.LONG;
+    return type;
+  }
+  
+  private int getNodeSortFieldType(String fieldName) {
+    int type = SortField.STRING;
+    if (fieldName.equals("pageNumber") || fieldName.equals("lineNumber") || fieldName.equals("elementDocPosition")) 
+      type = SortField.INT;
+    return type;
+  }
+
+  private FieldSelector getDocFieldSelector() {
+    HashSet<String> fields = new HashSet<String>();
+    fields.add("docId");
+    fields.add("identifier");
+    fields.add("uri");
+    fields.add("collectionNames");
+    fields.add("author");
+    fields.add("title");
+    fields.add("language");
+    fields.add("publisher");
+    fields.add("date");
+    fields.add("subject");
+    fields.add("rights");
+    fields.add("license");
+    fields.add("echoId");
+    fields.add("echoPageImageDir");
+    fields.add("echoFiguresDir");
+    fields.add("mpiwgDocId");
+    fields.add("type");
+    fields.add("pageCount"); 
+    fields.add("schemaName");
+    fields.add("lastModified");
+    fields.add("content");
+    FieldSelector fieldSelector = new SetBasedFieldSelector(fields, fields);
+    return fieldSelector;
+  }
+  
+  private FieldSelector getNodeFieldSelector() {
+    HashSet<String> fields = new HashSet<String>();
+    fields.add("docId");
+    fields.add("language");
+    fields.add("pageNumber");
+    fields.add("lineNumber");
+    fields.add("elementName");
+    fields.add("elementDocPosition");
+    fields.add("elementPosition");
+    fields.add("elementAbsolutePosition");
+    fields.add("elementPagePosition");
+    fields.add("xmlId");
+    fields.add("xpath");
+    fields.add("xmlContent");
+    fields.add("xmlContentTokenized");
+    FieldSelector fieldSelector = new SetBasedFieldSelector(fields, fields);
+    return fieldSelector;
+  }
+  
+  private SearcherManager getNewSearcherManager(IndexWriter indexWriter) throws ApplicationException {
+    SearcherManager searcherManager = null;
+    try {
+      searcherManager = new SearcherManager(indexWriter, true, null, null);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+    return searcherManager;
+  }
+
+  private IndexReader getDocumentsReader() throws ApplicationException {
+    IndexReader reader = null;
+    String luceneDocsDirectoryStr = Constants.getInstance().getLuceneDocumentsDir();
+    File luceneDocsDirectory = new File(luceneDocsDirectoryStr);
+    try {
+      FSDirectory fsDirectory = FSDirectory.open(luceneDocsDirectory);
+      reader = IndexReader.open(fsDirectory, true);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+    return reader;
+  }
+
+  private void makeIndexReaderUpToDate() throws ApplicationException {
+    try {
+      boolean isCurrent = documentsIndexReader.isCurrent();
+      if (!isCurrent) {
+        documentsIndexReader = IndexReader.openIfChanged(documentsIndexReader);
+      }
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+
+  private void makeDocumentsSearcherManagerUpToDate() throws ApplicationException {
+    try {
+      boolean isCurrent = documentsSearcherManager.isSearcherCurrent();
+      if (!isCurrent) {
+        documentsSearcherManager.maybeReopen();
+      }
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+
+  private void makeNodesSearcherManagerUpToDate() throws ApplicationException {
+    try {
+      boolean isCurrent = nodesSearcherManager.isSearcherCurrent();
+      if (!isCurrent) {
+        nodesSearcherManager.maybeReopen();
+      }
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+
+  private String toTokenizedXmlString(String xmlStr, String language) throws ApplicationException {
+    String xmlPre = "<tokenized xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" xmlns:de=\"http://www.mpiwg-berlin.mpg.de/ns/de/1.0/\" xmlns:mml=\"http://www.w3.org/1998/Math/MathML\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">";
+    String xmlPost = "</tokenized>";
+    String xmlStrTmp = xmlPre + xmlStr + xmlPost;
+    StringReader xmlInputStringReader = new StringReader(xmlStrTmp);
+    XmlTokenizer xmlTokenizer = new XmlTokenizer(xmlInputStringReader);
+    xmlTokenizer.setLanguage(language);
+    String[] outputOptions = { "withLemmas" };
+    xmlTokenizer.setOutputOptions(outputOptions);
+    xmlTokenizer.tokenize();
+    String result = xmlTokenizer.getXmlResult();
+    return result;
+  }
+
+  private String enrichWordsOrigRegNorm(String xmlStr) throws ApplicationException {
+    try {
+      WordContentHandler wordContentHandler = new WordContentHandler();
+      XMLReader xmlParser = new SAXParser();
+      xmlParser.setContentHandler(wordContentHandler);
+      StringReader strReader = new StringReader(xmlStr);
+      InputSource inputSource = new InputSource(strReader);
+      xmlParser.parse(inputSource);
+      String result = wordContentHandler.getResult();
+      return result;
+    } catch (SAXException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  private String escapeLuceneChars(String inputStr) {
+    String luceneCharsStr = "+-&|!(){}[]^~*?:\\"; // Lucene escape symbols
+    StringBuilder retStrBuilder = new StringBuilder();
+    for (int i = 0; i < inputStr.length(); i++) {
+      char c = inputStr.charAt(i);
+      if (luceneCharsStr.contains(String.valueOf(c)))
+        retStrBuilder.append("\\");
+      retStrBuilder.append(c);
+    }
+    return retStrBuilder.toString();
+  }
+
+  /**
+   * sorgt für sinnvolle satzanfänge
+   * 
+   * @param fragment
+   */
+  private String checkHitFragment(String fragment) {
+    if (fragment.startsWith(".") 
+        || fragment.startsWith(":") 
+        || fragment.startsWith(",") 
+        || fragment.startsWith("-") 
+        || fragment.startsWith(";") 
+        || fragment.startsWith("?")
+        || fragment.startsWith(")") 
+        || fragment.startsWith("!")) {
+      fragment = fragment.substring(1, fragment.length());
+      // finds first occurence of a given string out.println("first index of point : "+StringUtils.indexOfAny(fragment, "."));
+    }
+    return fragment;
+  }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainScheduler.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,243 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.scheduler;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.PriorityQueue;
+import java.util.Queue;
+
+import java.util.logging.Logger;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobListener;
+import org.quartz.SchedulerException;
+import org.quartz.SimpleTrigger;
+import org.quartz.Trigger;
+import org.quartz.impl.StdSchedulerFactory;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+public class CmsChainScheduler {
+  private static CmsChainScheduler instance;
+  private static String CRUD_JOB = "MPDL_CRUD_JOB";
+  private static String CRUD_TRIGGER = "MPDL_CRUD_TRIGGER";
+  private static String CRUD_GROUP = "MPDL_CRUD_GROUP";
+  private static Logger LOGGER = Logger.getLogger(CmsDocJob.class.getName());
+  private org.quartz.Scheduler scheduler;
+  private JobListener jobListener;
+  private Queue<CmsDocOperation> docOperationQueue = new PriorityQueue<CmsDocOperation>();
+  private HashMap<Integer, CmsDocOperation> finishedDocOperations = new HashMap<Integer, CmsDocOperation>();
+  private boolean operationInProgress = false;
+  private int jobOrderId = 0;
+  
+  public static CmsChainScheduler getInstance() throws ApplicationException {
+    if (instance == null) {
+      instance = new CmsChainScheduler();
+      instance.init();
+    }
+    return instance;
+  }
+
+  public CmsDocOperation doOperation(CmsDocOperation docOperation) throws ApplicationException {
+    jobOrderId++;
+    docOperation.setOrderId(jobOrderId);
+    queueOperation(docOperation);
+    scheduleNextOperation();
+    return docOperation;
+  }
+  
+  public void finishOperation(CmsDocOperation docOperation) throws ApplicationException {
+    operationInProgress = false;
+    Date now = new Date();
+    docOperation.setEnd(now);
+    docOperation.setStatus("finished");
+    int jobId = new Integer(docOperation.getOrderId());
+    finishedDocOperations.put(jobId, docOperation);
+    log(docOperation);
+    // schedule next job if there is one
+    scheduleNextOperation();
+  }
+  
+  private void log(CmsDocOperation docOperation) {
+    Date startTime = docOperation.getStart();
+    Date endTime = docOperation.getEnd();
+    long executionTime = -1;
+    if (startTime != null && endTime != null)
+      executionTime = (endTime.getTime() - startTime.getTime());
+    String jobInfo = "Document operation " + docOperation.toString() + ": started at: " + startTime + 
+      " and ended at: " + endTime + " (needed time: " + executionTime + " ms)";
+    LOGGER.info(jobInfo);
+  }
+  
+  public synchronized void scheduleNextOperation() throws ApplicationException {
+    if (isOperationInProgress()) {
+      // nothing, operation has to wait
+    } else {
+      CmsDocOperation docOperation = docOperationQueue.poll();
+      if (docOperation == null) {
+        // if queue is empty then do nothing (there are no more operations to execute)
+      } else {
+        Date now = new Date();
+        operationInProgress = true;
+        docOperation.setStart(now);
+        scheduleJob(docOperation, now);
+      }
+    }
+  }
+  
+  public ArrayList<CmsDocOperation> getDocOperations() throws ApplicationException {
+    ArrayList<CmsDocOperation> docOperations = new ArrayList<CmsDocOperation>();
+    try {
+      // first: all finished jobs
+      Collection<CmsDocOperation> finiDocOperations = finishedDocOperations.values();
+      docOperations.addAll(finiDocOperations);
+      // second: all currently executed jobs
+      if (operationInProgress) {
+        List<JobExecutionContext> currentJobs = (List<JobExecutionContext>) scheduler.getCurrentlyExecutingJobs();
+        Iterator<JobExecutionContext> iter = currentJobs.iterator();
+        while (iter.hasNext()) {
+          JobExecutionContext jobExecutionContext = iter.next();
+          CmsDocOperation docOperation = getDocOperation(jobExecutionContext);
+          if (docOperation != null) {
+            docOperations.add(docOperation);
+          }
+        }
+      }
+      // third: all queued jobs
+      Iterator<CmsDocOperation> iter = docOperationQueue.iterator();
+      while (iter.hasNext()) {
+        CmsDocOperation docOperation = iter.next();
+        docOperations.add(docOperation);
+      }
+    } catch (SchedulerException e) {
+      LOGGER.severe(e.getMessage());
+      throw new ApplicationException(e);
+    }
+    return docOperations;
+  }
+    
+  public CmsDocOperation getDocOperation(int jobId) throws ApplicationException {
+    CmsDocOperation docOperation = null;
+    try {
+      // first try: looks into currently executing jobs
+      if (operationInProgress) {
+        List<JobExecutionContext> currentJobs = (List<JobExecutionContext>) scheduler.getCurrentlyExecutingJobs();
+        Iterator<JobExecutionContext> iter = currentJobs.iterator();
+        while (iter.hasNext()) {
+          JobExecutionContext jobExecutionContext = iter.next();
+          docOperation = getDocOperation(jobExecutionContext);
+          if (docOperation != null) {
+            int dopOpJobId = docOperation.getOrderId();
+            if (jobId == dopOpJobId)
+              return docOperation;
+          }
+        }
+      }
+      // second try: look into finished jobs
+      docOperation = finishedDocOperations.get(new Integer(jobId));
+      if (docOperation != null) {
+        return docOperation;
+      }
+      // third try: look into queued jobs
+      Iterator<CmsDocOperation> iter = docOperationQueue.iterator();
+      while (iter.hasNext()) {
+        docOperation = iter.next();
+        if (docOperation.getOrderId() == jobId)
+          return docOperation;
+      }
+    } catch (SchedulerException e) {
+      LOGGER.severe(e.getMessage());
+      throw new ApplicationException(e);
+    }
+    // if not found return null
+    return null;
+  }
+  
+  public CmsDocOperation getDocOperation(JobExecutionContext jobExecutionContext) {
+    CmsDocOperation docOperation = null;
+    if (jobExecutionContext != null) {
+      JobDetail job = jobExecutionContext.getJobDetail();
+      JobDataMap parameters = job.getJobDataMap();
+      docOperation = (CmsDocOperation) parameters.get("operation");
+    }
+    return docOperation;
+  }
+  
+  private void queueOperation(CmsDocOperation docOperation) {
+    int operationsBefore = docOperationQueue.size();
+    if (operationsBefore == 0)
+     docOperation.setStatus("waiting in operation queue");
+    else 
+      docOperation.setStatus("waiting in operation queue: " + operationsBefore + " operations heve to be executed before this operation");
+    docOperationQueue.offer(docOperation);
+  }
+  
+  private synchronized boolean isOperationInProgress() {
+    return operationInProgress;  
+  }
+  
+  private void scheduleJob(CmsDocOperation docOperation, Date fireTime) throws ApplicationException {
+    try {
+      int jobId = docOperation.getOrderId();
+      String jobName = CRUD_JOB + "-id-" + jobId + "-timeId-" + fireTime;
+      JobDetail job = new JobDetail(jobName, CRUD_GROUP, CmsDocJob.class);
+      JobDataMap parameters = new JobDataMap();
+      parameters.put("operation", docOperation);
+      job.setJobDataMap(parameters);
+      job.addJobListener(jobListener.getName());        
+      String triggerName = CRUD_TRIGGER + "-id-" + jobId + "-timeId-" + fireTime;
+      Trigger trigger = new SimpleTrigger(triggerName, CRUD_GROUP, fireTime);
+      scheduler.scheduleJob(job, trigger);
+      String jobInfo = "Schedule document operation: " + docOperation.toString() + ": done at: " + fireTime.toString();
+      LOGGER.info(jobInfo);
+    } catch (SchedulerException e) {
+      LOGGER.severe(e.getMessage());
+      throw new ApplicationException(e);
+    }
+  }
+  
+  private void init() throws ApplicationException {
+    try {
+      if (scheduler == null) {
+        String quartzPath = getQuartzPath();
+        StdSchedulerFactory schedulerFactory = new StdSchedulerFactory(quartzPath);
+        scheduler = schedulerFactory.getScheduler();
+        jobListener = new CmsChainSchedulerListener();
+        scheduler.addJobListener(jobListener);
+        scheduler.start();
+        LOGGER.info("Started Quartz scheduler factory: " + quartzPath);
+      } 
+    } catch (SchedulerException e) {
+      LOGGER.severe(e.getMessage());
+      throw new ApplicationException(e);
+    }
+  }
+  
+  public void end() throws ApplicationException {
+    try {
+      if (scheduler != null) {
+        scheduler.shutdown();
+      }
+      String quartzPath = getQuartzPath();
+      LOGGER.info("Ended Quartz scheduler factory: " + quartzPath);
+    } catch (SchedulerException e) {
+      LOGGER.severe(e.getMessage());
+      throw new ApplicationException(e);
+    }
+  }
+
+  private String getQuartzPath() {
+    URL quartzUrl = CmsChainScheduler.class.getResource("quartz.properties");
+    String quartzPath = quartzUrl.getPath();
+    if (quartzPath.indexOf(".jar!") != -1) {
+      int beginIndex = quartzPath.indexOf(".jar!") + 6;
+      quartzPath = quartzPath.substring(beginIndex);
+    }
+    return quartzPath;    
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsChainSchedulerListener.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,53 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.scheduler;
+
+import java.util.logging.Logger;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.quartz.JobListener;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+public class CmsChainSchedulerListener implements JobListener {
+  private static Logger LOGGER = Logger.getLogger(CmsDocJob.class.getName());
+  
+  public String getName() {
+    return "MpdlJobChainingListener";
+  }
+
+  public void jobToBeExecuted(JobExecutionContext inContext) {
+  }
+
+  public void jobExecutionVetoed(JobExecutionContext inContext) {
+    String message = "Quartz: JobChainingListener: Job execution was vetoed.";
+    LOGGER.fine(message);
+  }
+
+  public void jobWasExecuted(JobExecutionContext inContext, JobExecutionException inException) {
+    // after finishing his job it tries to schedule the next operation (if there is one in the queue)
+    CmsDocOperation docOperation = null;
+    try {
+      CmsChainScheduler mpdlChainScheduler = CmsChainScheduler.getInstance();
+      docOperation = getDocOperation(inContext);
+      mpdlChainScheduler.finishOperation(docOperation);
+    } catch (ApplicationException e) {
+      if (docOperation != null) {
+        docOperation.setErrorMessage(e.getMessage());
+      }
+      LOGGER.severe(e.getMessage());
+    }
+  }
+
+  private CmsDocOperation getDocOperation(JobExecutionContext context) {
+    CmsDocOperation docOperation = null;
+    if (context != null) {
+      JobDetail job = context.getJobDetail();
+      JobDataMap parameters = job.getJobDataMap();
+      docOperation = (CmsDocOperation) parameters.get("operation");
+    }
+    return docOperation;
+  }
+  
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocJob.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,75 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.scheduler;
+
+import java.util.Date;
+
+import java.util.logging.Logger;
+import org.quartz.Job;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.DocumentHandler;
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+public class CmsDocJob implements Job {
+  public static String STATUS_BEGIN = "started";
+  private static Logger LOGGER = Logger.getLogger(CmsDocJob.class.getName());
+  private JobExecutionContext currentExecutedContext;
+  
+  public void execute(JobExecutionContext context) throws JobExecutionException {
+    this.currentExecutedContext = context;
+    CmsDocOperation docOperation = getDocOperation();
+    try {
+      docOperation.setStatus(STATUS_BEGIN);
+      String operationName = docOperation.getName();   
+      if (operationName.equals("create")) {
+        DocumentHandler docHandler = new DocumentHandler();
+        docHandler.doOperation(docOperation);
+      } else if (operationName.equals("delete")) {
+        DocumentHandler docHandler = new DocumentHandler();
+        docHandler.doOperation(docOperation);
+      } else if (operationName.equals("importDirectory")) {
+        DocumentHandler docHandler = new DocumentHandler();
+        docHandler.doOperation(docOperation);
+      }
+      Date startingTime = docOperation.getStart();
+      String jobInfo = "Document operation " + docOperation.toString() + ": started at: " + startingTime;
+      LOGGER.info(jobInfo);
+      this.currentExecutedContext = null;
+    } catch (Exception e) {
+      try {
+        // Quartz will automatically unschedule all triggers associated with this job so that it does not run again
+        CmsChainScheduler mpdlChainScheduler = CmsChainScheduler.getInstance();
+        mpdlChainScheduler.finishOperation(docOperation);
+        String errorMessage = e.getMessage();
+        if (errorMessage == null) {
+          Throwable t = e.getCause();
+          if (t == null) {
+            errorMessage = e.toString();
+          } else {
+            errorMessage = t.getMessage();
+          }
+        }
+        docOperation.setErrorMessage(errorMessage);
+        LOGGER.severe(errorMessage);
+        JobExecutionException jobExecutionException = new JobExecutionException(e);
+        jobExecutionException.setUnscheduleAllTriggers(true);
+        throw jobExecutionException;
+      } catch (ApplicationException ex) {
+        // nothing
+      }
+    }
+  } 
+
+  private CmsDocOperation getDocOperation() {
+    CmsDocOperation docOperation = null;
+    if (currentExecutedContext != null) {
+      JobDetail job = currentExecutedContext.getJobDetail();
+      JobDataMap parameters = job.getJobDataMap();
+      docOperation = (CmsDocOperation) parameters.get("operation");
+    }
+    return docOperation;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/CmsDocOperation.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,160 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.scheduler;
+
+import java.util.Date;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.MetadataRecord;
+
+public class CmsDocOperation implements Comparable<CmsDocOperation> {
+  private int id;
+  private Date start;
+  private Date end;
+  private String name;
+  private String status;
+  private String errorMessage;
+  private String uploadFileName;
+  private String srcUrl;   
+  private String docIdentifier;
+  private String mainLanguage;
+  private String[] elementNames; // element names which should be indexed (e.g. "s head, caption")
+  private String collectionNames; // collections to which this document belongs separated by blanks (e.g. "collection1 collection7")
+  private MetadataRecord mdRecord;
+  
+  public CmsDocOperation(String name, String srcUrl, String uploadFileName, String docIdentifier) {
+    this.name = name;
+    this.srcUrl = srcUrl;
+    this.uploadFileName = uploadFileName;
+    this.docIdentifier = docIdentifier;
+  }
+
+  public int compareTo(CmsDocOperation op) {
+    Integer opOrderId = new Integer(op.id);
+    Integer thisOrderId = new Integer(id);
+    return thisOrderId.compareTo(opOrderId);
+  }
+  
+  public boolean isFinished() {
+    if (status != null && status.equals("finished"))
+      return true;
+    else 
+      return false;
+  }
+  
+  public boolean isError() {
+    if (errorMessage != null && errorMessage.length() > 0)
+      return true;
+    else 
+      return false;
+  }
+  
+  public int getOrderId() {
+    return id;
+  }
+
+  public void setOrderId(int orderId) {
+    this.id = orderId;
+  }
+
+  public String getStatus() {
+    return status;
+  }
+
+  public void setStatus(String status) {
+    this.status = status;
+  }
+
+  public Date getStart() {
+    return start;
+  }
+
+  public void setStart(Date start) {
+    this.start = start;
+  }
+
+  public Date getEnd() {
+    return end;
+  }
+
+  public void setEnd(Date end) {
+    this.end = end;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getErrorMessage() {
+    return errorMessage;
+  }
+
+  public void setErrorMessage(String errorMessage) {
+    this.errorMessage = errorMessage;
+  }
+
+  public String getDocIdentifier() {
+    return docIdentifier;
+  }
+  
+  public void setDocIdentifier(String docIdentifier) {
+    this.docIdentifier = docIdentifier;
+  }
+  
+  public String getMainLanguage() {
+    return mainLanguage;
+  }
+  
+  public void setMainLanguage(String mainLanguage) {
+    this.mainLanguage = mainLanguage;
+  }
+  
+  public String[] getElementNames() {
+    return elementNames;
+  }
+  
+  public void setElementNames(String[] elementNames) {
+    this.elementNames = elementNames;
+  }
+  
+  public String getCollectionNames() {
+    return collectionNames;
+  }
+
+  public void setCollectionNames(String collectionNames) {
+    this.collectionNames = collectionNames;
+  }
+
+  public String getSrcUrl() {
+    return srcUrl;
+  }
+
+  public void setSrcUrl(String srcUrl) {
+    this.srcUrl = srcUrl;
+  }
+
+  public String getUploadFileName() {
+    return uploadFileName;
+  }
+
+  public void setUploadFileName(String uploadFileName) {
+    this.uploadFileName = uploadFileName;
+  }
+
+  public MetadataRecord getMdRecord() {
+    return mdRecord;
+  }
+
+  public void setMdRecord(MetadataRecord mdRecord) {
+    this.mdRecord = mdRecord;
+  }
+
+  public String toString() {
+    if (name.equals("delete"))
+      return name + "(" + id + ", " + docIdentifier + ")";
+    else 
+      return name + "(" + id + ", " + uploadFileName + ", " + docIdentifier + ")";
+  }
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/scheduler/quartz.properties	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,9 @@
+org.quartz.scheduler.instanceName = MpdlScheduler
+org.quartz.scheduler.instanceId = auto
+org.quartz.scheduler.rmi.export = false
+org.quartz.scheduler.rmi.proxy = false
+
+org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
+org.quartz.threadPool.threadCount = 3
+
+org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/test/TestLocal.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,451 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.test;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Hashtable;
+
+import javax.xml.transform.stream.StreamSource;
+
+import net.sf.saxon.s9api.Processor;
+import net.sf.saxon.s9api.QName;
+import net.sf.saxon.s9api.Serializer;
+import net.sf.saxon.s9api.XdmNode;
+import net.sf.saxon.s9api.XsltCompiler;
+import net.sf.saxon.s9api.XsltExecutable;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Fieldable;
+import org.apache.lucene.index.Term;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import com.sun.org.apache.xerces.internal.parsers.SAXParser;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.scheduler.CmsChainScheduler;
+import de.mpg.mpiwg.berlin.mpdl.cms.scheduler.CmsDocOperation;
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.lt.dict.db.LexHandler;
+import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.MorphologyCache;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.WordContentHandler;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.XmlTokenizer;
+import de.mpg.mpiwg.berlin.mpdl.lt.text.tokenize.XmlTokenizerContentHandler;
+import de.mpg.mpiwg.berlin.mpdl.util.Util;
+import de.mpg.mpiwg.berlin.mpdl.xml.xquery.XQueryEvaluator;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.GetFragmentsContentHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.HighlightContentHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.PageTransformer;
+import de.mpg.mpiwg.berlin.mpdl.cms.transform.XslResourceTransformer;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.DocumentHandler;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Hits;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.MetadataRecord;
+import de.mpg.mpiwg.berlin.mpdl.cms.document.Token;
+
+public class TestLocal {
+  private IndexHandler indexer;
+
+  public static void main(String[] args) throws ApplicationException {
+    try {
+      TestLocal test = new TestLocal();
+      test.init();
+      // test.importAllDocuments();
+      // test.createAllPdfInDirectory();
+      // test.testTransform();
+      // test.testXml();
+      // test.generateToc();
+      test.testCalls();
+      // test.generatePdf();
+      // test.xquery();
+      // test.createToc();
+      // test.testScheduler();
+      // test.getDocInfo();
+      // test.testChars();
+      test.end();
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  private void init() throws ApplicationException {
+    indexer = IndexHandler.getInstance();
+  }
+  
+  private void end() throws ApplicationException {
+    indexer.end();
+  }
+
+  private void testXml() throws ApplicationException {
+    try {
+      DocumentHandler docHandler = new DocumentHandler();
+      String docDirName = docHandler.getDocDir("/echo/la/Benedetti_1585_163127KK.xml");
+      String pageXmlFileName = docDirName + "/pages" + "/page-" + "444" + ".xml";
+      File pageXmlFile = new File(pageXmlFileName);
+      String pageXmlStr = null;
+      if (pageXmlFile.exists())
+        pageXmlStr = FileUtils.readFileToString(pageXmlFile, "utf-8");
+      System.out.println(pageXmlStr);
+      String tokStr = tokenizeWithLemmas(pageXmlStr, "lat");
+      System.out.println(tokStr);
+      tokStr = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + tokStr;
+      byte[] blablabla = tokStr.getBytes("utf-8");
+      String blablu = new String(blablabla, "utf-8");
+      String bla = enrichWordsOrigRegNorm(blablu);
+      System.out.println(bla);
+      
+      XQueryEvaluator xQueryEvaluator = new XQueryEvaluator();
+      URL url = new URL("file:/var/yp/Test_1789.xml");
+      XdmNode docNode = xQueryEvaluator.parse(url); // if it is not parseable an exception with a detail message is thrown 
+      
+      File srcFile = new File("/Users/jwillenborg/mpdl/data/xml/documents/tei/de/dt-ptolemaeus-tei-merge2.xml");
+      FileReader docFileReader = new FileReader(srcFile);
+      XmlTokenizer docXmlTokenizer = new XmlTokenizer(docFileReader);
+      docXmlTokenizer.setDocIdentifier("/tei/de/dt-ptolemaeus-tei-merge2.xml");
+      docXmlTokenizer.tokenize();  
+      ArrayList<XmlTokenizerContentHandler.Element> elements = docXmlTokenizer.getElements("s");
+      String blabla = "";
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+  
+  private void importAllDocuments() throws ApplicationException {
+    DocumentHandler docHandler = new DocumentHandler();
+    CmsDocOperation docOperation = new CmsDocOperation("importDirectory", "file:/Users/jwillenborg/test/documents", null, null);
+    docOperation.setCollectionNames("echo");
+    docHandler.doOperation(docOperation);
+  }
+  
+  private void createAllPdfInDirectory() throws ApplicationException {
+    DocumentHandler docHandler = new DocumentHandler();
+    CmsDocOperation docOperation = new CmsDocOperation("createAllPdfInDirectory", "file:/Users/jwillenborg/test/documents", null, null);
+    docOperation.setCollectionNames("echo");
+    docHandler.doOperation(docOperation);
+  }
+  
+  private void generatePdf() throws ApplicationException {
+    long begin = new Date().getTime();
+    DocumentHandler docHandler = new DocumentHandler();
+    // String docId = "/echo/la/Benedetti_1585_163127KK.xml";
+    String docId = "/diverse/de/Einst_Ueber_de_1907_02.xml";
+    // String docId = "/archimedes/it/caver_metod_020_it_1891.xml";
+    CmsDocOperation docOperation = new CmsDocOperation("createPdf", null, null, docId);
+    docHandler.doOperation(docOperation);
+    long end = new Date().getTime();
+    System.out.println("Needed time: " + (end - begin));
+  }
+
+  private void testChars() throws ApplicationException {
+    String docId = "/test/benedetti/page-444.xml";
+    String docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docId;
+    DocumentHandler docHandler = new DocumentHandler();
+    CmsDocOperation docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docId);
+    docHandler.doOperation(docOperation);
+  }
+  
+  private void testCalls() throws ApplicationException {
+    Date before = new Date();
+    System.out.println("Indexing start: " + before.getTime());
+    String docIdGoerz = "/tei/de/dt-ptolemaeus-tei-merge2.xml";
+    String docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdGoerz;
+    DocumentHandler docHandler = new DocumentHandler();
+    CmsDocOperation docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdGoerz);
+    // docHandler.doOperation(docOperation);
+    String docIdSchulz = "/tei/de/Schulz_2009.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdSchulz;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdSchulz);
+    // docHandler.doOperation(docOperation);
+    String docIdBenedetti = "/echo/la/Benedetti_1585_163127KK.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdBenedetti;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdBenedetti);
+    // docHandler.doOperation(docOperation);
+    String docIdSongYingxing = "/echo/zh/SongYingxing_1637.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdSongYingxing;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdSongYingxing);
+    // docHandler.doOperation(docOperation);
+    String docIdMonte = "/archimedes/la/monte_mecha_036_la_1577.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdMonte;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdMonte);
+    // docHandler.doOperation(docOperation);
+    String docIdEinstein = "/diverse/de/Einst_Antwo_de_1912.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdEinstein;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdEinstein);
+    // docHandler.doOperation(docOperation);
+    String docIdEinsteinUeber = "/diverse/de/Einst_Ueber_de_1907_02.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdEinsteinUeber;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdEinsteinUeber);
+    // docHandler.doOperation(docOperation);
+    String docIdTest = "/echo/zh/Yulei_tushuo_2_FN1CTY5C.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdTest;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdTest);
+    // docHandler.doOperation(docOperation);
+    String docIdMega = "/test/mega/MEGA_A2_B013-00_ETX.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdMega;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdMega);
+    // docHandler.doOperation(docOperation);
+    String docIdDiverse = "/diverse/en/078_A_1916.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdDiverse;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdDiverse);
+    // docHandler.doOperation(docOperation);
+    String docIdEinstGrossmann = "/diverse/de/EinsteinGrossmann.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdEinstGrossmann;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdEinstGrossmann);
+    // docHandler.doOperation(docOperation);
+    String docIdEinstGrund = "/diverse/en/078_A_1916.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdEinstGrund;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdEinstGrund);
+    // docHandler.doOperation(docOperation);
+    String docIdVolta = "/archimedes/it/volta_nuoMemLetTerz_922_it_1795.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdVolta;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdVolta);
+    // docHandler.doOperation(docOperation);
+    String docIdVitruv = "/echo/it/Vitruvius_1747_Y1G1TRCW.xml";
+    docSrcUrlStr = "file:/Users/jwillenborg/texts/mpdl/documents" + docIdVitruv;
+    docHandler = new DocumentHandler();
+    docOperation = new CmsDocOperation("create", docSrcUrlStr, null, docIdVitruv);
+    docHandler.doOperation(docOperation);
+    // indexer.deleteDocument(docIdGoerz);
+    // indexer.deleteDocument(docIdBenedetti);
+    MorphologyCache.getInstance().end();
+    LexHandler.getInstance().end();
+  }
+
+  private Hashtable<Integer, StringBuilder> getFragments(String fileName) throws ApplicationException {
+    try {
+      GetFragmentsContentHandler getFragmentsContentHandler = new GetFragmentsContentHandler();
+      XMLReader xmlParser = new SAXParser();
+      xmlParser.setContentHandler(getFragmentsContentHandler);
+      InputSource inputSource = new InputSource(fileName);
+      xmlParser.parse(inputSource);
+      Hashtable<Integer, StringBuilder> resultFragments = getFragmentsContentHandler.getResultPages();
+      return resultFragments;
+    } catch (SAXException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+
+  private void testTransform() throws ApplicationException {
+    Date begin = new Date();
+    XslResourceTransformer xslResourceTransformer = new XslResourceTransformer("pageXml.xsl");
+    xslResourceTransformer = new XslResourceTransformer("pageTei.xsl");
+    xslResourceTransformer = new XslResourceTransformer("pageArchimedes.xsl");
+    xslResourceTransformer = new XslResourceTransformer("pageXhtml.xsl");
+    xslResourceTransformer = new XslResourceTransformer("pageEcho.xsl");
+    Date end = new Date();
+    System.out.println("Needed time: " + (end.getTime() - begin.getTime()) + " ms");
+    begin = new Date();
+    String docFilePath = "/Users/jwillenborg/mpdl/data/xml/documents/echo/la/Benedetti_1585/pages/page-13-morph.xml";
+    xslResourceTransformer = new XslResourceTransformer("pageEcho.xsl");
+    String result = xslResourceTransformer.transform(docFilePath);
+    xslResourceTransformer = new XslResourceTransformer("pageEcho.xsl");
+    result = xslResourceTransformer.transform(docFilePath);
+    xslResourceTransformer = new XslResourceTransformer("pageEcho.xsl");
+    result = xslResourceTransformer.transform(docFilePath);
+    xslResourceTransformer = new XslResourceTransformer("pageEcho.xsl");
+    result = xslResourceTransformer.transform(docFilePath);
+    xslResourceTransformer = new XslResourceTransformer("pageEcho.xsl");
+    result = xslResourceTransformer.transform(docFilePath);
+    end = new Date();
+    System.out.println("Needed time: " + (end.getTime() - begin.getTime()) + " ms");
+    xslResourceTransformer = new XslResourceTransformer("pageEcho.xsl");
+    begin = new Date();
+    result = xslResourceTransformer.transform(docFilePath);
+    result = xslResourceTransformer.transform(docFilePath);
+    result = xslResourceTransformer.transform(docFilePath);
+    result = xslResourceTransformer.transform(docFilePath);
+    result = xslResourceTransformer.transform(docFilePath);
+    end = new Date();
+    System.out.println("Needed time: " + (end.getTime() - begin.getTime()) + " ms");
+    try {
+      Processor processor = new Processor(false); 
+      XsltCompiler xsltCompiler = processor.newXsltCompiler();
+      URL xslUrl = XslResourceTransformer.class.getResource("pageEcho.xsl");
+      StreamSource xslStreamSource = new StreamSource(xslUrl.openStream());
+      XsltExecutable xsltExecutable = xsltCompiler.compile(xslStreamSource);
+      net.sf.saxon.s9api.XsltTransformer xsltTransformer = xsltExecutable.load();
+      Serializer serializer = new Serializer();
+      serializer.setOutputWriter(new StringWriter());
+      begin = new Date();
+      for (int i=0; i<=5; i++) {
+        StreamSource xmlDoc = new StreamSource(docFilePath); 
+        xsltTransformer.setSource(xmlDoc);  // needs some time for bigger documents
+        xsltTransformer.setDestination(serializer);
+        xsltTransformer.transform();  // needs some time for bigger documents
+        result = serializer.getOutputDestination().toString();
+      }
+      end = new Date();
+      System.out.println("Needed time: " + (end.getTime() - begin.getTime()) + " ms");
+    } catch (Exception e) {
+      
+    }
+  }
+  
+  private String tokenizeXmlFragment() throws ApplicationException {
+    String result = null;
+    try {
+      String xmlFragment = new String(FileUtils.readFileToByteArray(new File("/Users/jwillenborg/tmp/testFragment2.xml")), "utf-8");
+      String srcUrlStr = "http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=/echo/la/Benedetti_1585.xml&mode=pureXml&pn=13";
+      URL srcUrl = new URL(srcUrlStr);
+      InputStream inputStream = srcUrl.openStream();
+      BufferedInputStream in = new BufferedInputStream(inputStream);
+      xmlFragment = IOUtils.toString(in, "utf-8");
+      in.close();
+
+      XmlTokenizer xmlTokenizer = new XmlTokenizer(new StringReader(xmlFragment));
+      xmlTokenizer.setLanguage("lat");
+      String[] stopElements = {"var"};
+      // xmlTokenizer.setOutputFormat("string");
+      String[] outputOptions = {"withLemmas"};
+      xmlTokenizer.setOutputOptions(outputOptions);
+      xmlTokenizer.setStopElements(stopElements);
+      xmlTokenizer.tokenize();
+      result = xmlTokenizer.getXmlResult();
+      System.out.println(result);
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return result;
+  }
+  
+  private String normalizeWords(String xmlStr) throws ApplicationException {
+    try {
+      WordContentHandler wordContentHandler = new WordContentHandler();
+      XMLReader xmlParser = new SAXParser();
+      xmlParser.setContentHandler(wordContentHandler);
+      StringReader strReader = new StringReader(xmlStr);
+      InputSource inputSource = new InputSource(strReader);
+      xmlParser.parse(inputSource);
+      String result = wordContentHandler.getResult();
+      return result;
+    } catch (SAXException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  private String tokenizeWithLemmas(String xmlStr, String language) throws ApplicationException {
+    StringReader strReader = new StringReader(xmlStr);
+    XmlTokenizer xmlTokenizer = new XmlTokenizer(strReader);
+    xmlTokenizer.setLanguage(language);
+    String[] outputOptionsWithLemmas = {"withLemmas"}; // so all tokens are fetched with lemmas (costs performance)
+    xmlTokenizer.setOutputOptions(outputOptionsWithLemmas); 
+    xmlTokenizer.tokenize();  
+    String retStr = xmlTokenizer.getXmlResult();
+    return retStr;
+  }
+  
+  private String enrichWordsOrigRegNorm(String xmlStr) throws ApplicationException {
+    try {
+      WordContentHandler wordContentHandler = new WordContentHandler();
+      XMLReader xmlParser = new SAXParser();
+      xmlParser.setContentHandler(wordContentHandler);
+      StringReader strReader = new StringReader(xmlStr);
+      InputSource inputSource = new InputSource(strReader);
+      xmlParser.parse(inputSource);
+      String result = wordContentHandler.getResult();
+      return result;
+    } catch (SAXException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+
+  private String highlight(String xmlStr, String highlightElem, int highlightElemPos, String highlightQueryType, String highlightQuery, String language) throws ApplicationException {
+    String result = null;
+    try {
+      xmlStr = normalizeWords(xmlStr);
+      HighlightContentHandler highlightContentHandler = new HighlightContentHandler(highlightElem, highlightElemPos, highlightQueryType, highlightQuery, language);
+      highlightContentHandler.setFirstPageBreakReachedMode(true);
+      XMLReader xmlParser = new SAXParser();
+      xmlParser.setContentHandler(highlightContentHandler);
+      StringReader stringReader = new StringReader(xmlStr);
+      InputSource inputSource = new InputSource(stringReader);
+      xmlParser.parse(inputSource);
+      result = highlightContentHandler.getResult().toString();
+    } catch (SAXException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+    return result;
+  }
+  
+  private void testScheduler() throws ApplicationException {
+    CmsDocOperation docOperation = new CmsDocOperation("update", "http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/getDoc?doc=/echo/zh/SongYingxing_1637.xml", null, "/echo/zh/SongYingxing_1637.xml"); 
+    String[] elemNames = {"s", "head"};
+    docOperation.setElementNames(elemNames);
+    CmsChainScheduler scheduler = CmsChainScheduler.getInstance();
+    docOperation = scheduler.doOperation(docOperation);
+    String bla = "";
+  }
+  
+  private void xquery() throws ApplicationException {
+    try {
+      XQueryEvaluator xQueryEvaluator = new XQueryEvaluator();
+      URL srcUrl = new URL("file:/Users/jwillenborg/tmp/blablabla/Benedetti_1585.xml");
+      String getTocEntries = "let $tocEntries := //echo:div[@type = 'section' or @type = 'chapter']";
+      String getFigures = 
+          "let $allFigures := //*:figure " +
+          "let $figures := " +
+          "  for $figure at $pos in $allFigures "+
+          "    let $caption := string-join($figure/*:caption/text(), ' ') " +
+          "    let $description := string-join($figure/*:description/text(), ' ') " +
+          "    let $variables := string-join($figure/*:variables/text(), ' ') " +
+          "    let $retFigure := " + 
+          "      element {'figure'}" +
+          "      { attribute {'number'} {$pos}, " +
+          "       element {'caption'} {$caption}, " +
+          "       element {'description'} {$description}, " +
+          "       element {'variables'} {$variables} }" + 
+          "    return " + 
+          "      $retFigure " +
+          "return $figures";
+      String result = xQueryEvaluator.evaluateAsString(srcUrl, getFigures);
+      String bla = result;
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  private void createToc() throws ApplicationException {
+    String docDirName = "/Users/jwillenborg/mpdl/data/xml/documents/echo/zh/SongYingxing_1637";
+    XslResourceTransformer tocTransformer = new XslResourceTransformer("toc.xsl");
+    File tocFile = new File(docDirName + "/toc.xml");
+    String docDestFileName = docDirName + "/SongYingxing_1637.xml";
+    String tocResult = tocTransformer.transform(docDestFileName);
+    String bla = "";
+  }
+  
+  private void getDocInfo() throws ApplicationException {
+    IndexHandler indexHandler = IndexHandler.getInstance();
+    MetadataRecord mdRecord = indexHandler.getDocMetadata("/echo/la/Benedetti_1585_163127KK.xml");
+  }
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/GetFragmentsContentHandler.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,203 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.transform;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import org.xml.sax.*;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.util.StringUtils;
+
+public class GetFragmentsContentHandler implements ContentHandler {
+  private String xmlnsString = "";
+  private int currentMilestonePosition = 0;
+  private Element currentElement;
+  private Element currentMilestoneElement;
+  private ArrayList<Element> elementQueue; // queue of opened elements (before they were closed): to connect them to a parent hierarchy 
+  private Hashtable<Integer, StringBuilder> resultFragments = new Hashtable<Integer, StringBuilder>();
+  private String milestoneElemenName = "pb";  // default is pb
+  
+  public GetFragmentsContentHandler() throws ApplicationException {
+  }
+
+  public GetFragmentsContentHandler(String milestoneElemenName) throws ApplicationException {
+    this.milestoneElemenName = milestoneElemenName;
+  }
+
+  public Hashtable<Integer, StringBuilder> getResultPages() {
+    return resultFragments;  
+  }
+
+  public int getMilestoneCount() {
+    return currentMilestonePosition;  
+  }
+
+  public void startDocument() throws SAXException {
+  }
+
+  public void endDocument() throws SAXException {
+    // write the closePath after the last minus 1 milestone element (the closing path after the last milestone element is automatically written by the normal closing tags)
+    if (currentMilestoneElement != null) {
+      String msClosePath = currentMilestoneElement.getClosePath();
+      write(msClosePath, currentMilestoneElement.milestonePosition - 1);
+    }
+    resultFragments.remove(new Integer(0));  // this fragment is filled but should not
+  }
+  
+  public void characters(char[] c, int start, int length) throws SAXException {
+    char[] cCopy = new char[length];
+    System.arraycopy(c, start, cCopy, 0, length);
+    String charactersStr = String.valueOf(cCopy);
+    if (charactersStr != null && ! charactersStr.equals("")) {
+      if (currentMilestonePosition > 0) {
+        charactersStr = StringUtils.deresolveXmlEntities(charactersStr);
+        write(charactersStr);
+      }
+    }
+  }
+
+  public void ignorableWhitespace(char[] c, int start, int length) throws SAXException {
+  }
+
+  public void processingInstruction(String target, String data) throws SAXException {
+  }
+
+  public void setDocumentLocator(Locator locator) {
+  }
+
+  public void startPrefixMapping(String prefix, String uri) throws SAXException {
+    if (prefix != null && prefix.equals(""))  
+      xmlnsString += "xmlns" + "=\"" + uri + "\" ";
+    else
+      xmlnsString += "xmlns:" + prefix + "=\"" + uri + "\" ";
+  }
+  
+  public void endPrefixMapping(String prefix) throws SAXException {
+  }
+
+  public void skippedEntity(String name) throws SAXException {
+  }
+
+  public void startElement(String uri, String localName, String name, Attributes attrs) throws SAXException {
+    if (elementQueue == null)
+      elementQueue = new ArrayList<Element>();
+    Element newElement = new Element(name);
+    if (currentElement != null) {
+      newElement.parent = currentElement;
+    }
+    currentElement = newElement;
+    if (localName != null && localName.equals(milestoneElemenName)) {
+      currentMilestonePosition++;
+      if (currentMilestoneElement != null) {
+        String msClosePath = currentMilestoneElement.getClosePath();
+        write(msClosePath, currentMilestoneElement.milestonePosition - 1);
+      }
+      currentMilestoneElement = currentElement;
+      currentMilestoneElement.milestonePosition = currentMilestonePosition;
+      String msOpenPath = currentMilestoneElement.getOpenPath();
+      write(msOpenPath);
+    }
+    int attrSize = attrs.getLength();
+    String attrString = "";
+    for (int i=0; i<attrSize; i++) {
+      String attrQName = attrs.getQName(i);
+      String attrValue = attrs.getValue(i);
+      attrValue = StringUtils.forXML(attrValue);
+      attrString = attrString + " " + attrQName + "=\"" + attrValue + "\"";
+    }
+    if (attrString != null && ! attrString.isEmpty()) {
+      attrString = attrString.trim();
+      currentElement.attrString = attrString;
+    }
+    if (xmlnsString != null && ! xmlnsString.isEmpty()) {
+      xmlnsString = xmlnsString.trim();
+      currentElement.xmlnsString = xmlnsString;
+    }
+    if (currentMilestonePosition > 0) {
+      write("<" + name);
+      if (xmlnsString != null && ! xmlnsString.isEmpty())
+        write(" " + xmlnsString);
+      if (attrString != null && ! attrString.isEmpty())
+        write(" " + attrString);
+      write(">");
+    }
+    xmlnsString = "";
+    elementQueue.add(currentElement);
+  }
+
+  public void endElement(String uri, String localName, String name) throws SAXException {
+    if (currentMilestonePosition > 0) {
+      write("</" + name + ">");
+    }
+    if (elementQueue != null && elementQueue.size() > 0) {
+      int lastIndex = elementQueue.size() - 1;
+      elementQueue.remove(lastIndex);
+    }
+    if (elementQueue != null && elementQueue.size() > 0) {
+      int lastIndex = elementQueue.size() - 1;
+      currentElement = elementQueue.get(lastIndex);
+    } else {
+      currentElement = null;
+    }
+  }
+
+  private void write(String outStr) throws SAXException {
+    StringBuilder resultFragment = resultFragments.get(new Integer(currentMilestonePosition));
+    if (resultFragment == null) {
+      resultFragment = new StringBuilder();
+      resultFragments.put(new Integer(currentMilestonePosition), resultFragment);
+    }
+    resultFragment.append(outStr);
+  }
+  
+  private void write(String outStr, int milestoneNumber) throws SAXException {
+    StringBuilder resultFragment = resultFragments.get(new Integer(milestoneNumber));
+    if (resultFragment == null) {
+      resultFragment = new StringBuilder();
+      resultFragments.put(new Integer(milestoneNumber), resultFragment);
+    }
+    resultFragment.append(outStr);
+  }
+  
+  public class Element {
+    public String name;
+    private String xmlnsString;
+    private String attrString;
+    private int milestonePosition;
+    private Element parent;
+    
+    private Element(String name) {
+      this.name = name;
+    }
+
+    private String getOpenPath() {
+      StringBuilder ancestorsStrBuilder = new StringBuilder();
+      if (parent != null) {
+        ancestorsStrBuilder.append(parent.getOpenPath()); 
+        ancestorsStrBuilder.append("<");
+        ancestorsStrBuilder.append(parent.name);
+        if (parent.xmlnsString != null && ! parent.xmlnsString.isEmpty()) {
+          ancestorsStrBuilder.append(" ");
+          ancestorsStrBuilder.append(parent.xmlnsString);
+        }
+        if (parent.attrString != null && ! parent.attrString.isEmpty()) {
+          ancestorsStrBuilder.append(" " + parent.attrString);
+        }
+        ancestorsStrBuilder.append(">");
+      }
+      return ancestorsStrBuilder.toString();
+    }
+ 
+    private String getClosePath() {
+      StringBuilder ancestorsStrBuilder = new StringBuilder();
+      if (parent != null) {
+        ancestorsStrBuilder.append("</");
+        ancestorsStrBuilder.append(parent.name);
+        ancestorsStrBuilder.append(">");
+        ancestorsStrBuilder.append(parent.getClosePath()); 
+      }
+      return ancestorsStrBuilder.toString();
+    }
+
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/HighlightContentHandler.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,215 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.transform;
+
+import java.util.ArrayList;
+
+import org.xml.sax.*;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.lucene.IndexHandler;
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+import de.mpg.mpiwg.berlin.mpdl.util.StringUtils;
+
+public class HighlightContentHandler implements ContentHandler {
+  private String xmlnsString = "";
+  private String highlightElemName;  
+  private int highlightElemPos = 1; 
+  private int currentHighlightElemPos = 0;
+  private boolean highlightElemMode = false;
+  private int highlightElemModeOpenTags = 0;
+  private String highlightQueryType = "orig";  // orig, reg, norm or morph
+  private String highlightQuery;  // complex Lucene query
+  private String highlightQueryForms;  // highlight terms separated by a blank
+  private boolean highlightHitMode = false;
+  private int highlightHitModeOpenTags = 0;
+  private boolean firstPageBreakReachedMode = false;  // in a page fragment: if a page break element is surrounded by an element (e.g. "s") then this element should not increment the currentHighlightElemPos 
+  private boolean firstPageBreakReached = true;  
+  private StringBuilder result = new StringBuilder();
+  
+  public HighlightContentHandler() throws ApplicationException {
+  }
+
+  public HighlightContentHandler(String highlightElemName, int highlightElemPos) throws ApplicationException {
+    this.highlightElemName = highlightElemName;
+    this.highlightElemPos = highlightElemPos;
+  }
+
+  public HighlightContentHandler(String highlightElemName, int highlightElemPos, String highlightQueryType, String highlightQuery, String language) throws ApplicationException {
+    this.highlightElemName = highlightElemName;
+    this.highlightElemPos = highlightElemPos;
+    this.highlightQueryType = highlightQueryType;
+    this.highlightQuery = highlightQuery;
+    if (highlightQuery != null) {
+      IndexHandler indexHandler = IndexHandler.getInstance();
+      ArrayList<String> queryTerms = indexHandler.fetchTerms(highlightQuery, language); // all query terms in query (also morphological terms)
+      highlightQueryForms = toString(queryTerms);
+    }
+  }
+
+  public void setFirstPageBreakReachedMode(boolean firstPageBreakReachedMode) {
+    this.firstPageBreakReachedMode = firstPageBreakReachedMode; 
+    if (firstPageBreakReachedMode)
+      this.firstPageBreakReached = false;  // is first set to false and later if a page break is found (by startElement) it is set to true
+  }
+  
+  public StringBuilder getResult() {
+    return result;  
+  }
+
+  public void startDocument() throws SAXException {
+  }
+
+  public void endDocument() throws SAXException {
+  }
+  
+  public void characters(char[] c, int start, int length) throws SAXException {
+    char[] cCopy = new char[length];
+    System.arraycopy(c, start, cCopy, 0, length);
+    String charactersStr = String.valueOf(cCopy);
+    if (charactersStr != null && ! charactersStr.equals("")) {
+      charactersStr = StringUtils.deresolveXmlEntities(charactersStr);
+      write(charactersStr);
+    }
+  }
+
+  public void ignorableWhitespace(char[] c, int start, int length) throws SAXException {
+  }
+
+  public void processingInstruction(String target, String data) throws SAXException {
+  }
+
+  public void setDocumentLocator(Locator locator) {
+  }
+
+  public void startPrefixMapping(String prefix, String uri) throws SAXException {
+    xmlnsString += "xmlns:" + prefix + "=\"" + uri + "\" ";
+    if (prefix != null && prefix.equals(""))  
+      xmlnsString = "xmlns" + "=\"" + uri + "\" ";
+  }
+  
+  public void endPrefixMapping(String prefix) throws SAXException {
+  }
+
+  public void skippedEntity(String name) throws SAXException {
+  }
+
+  public void startElement(String uri, String localName, String name, Attributes attrs) throws SAXException {
+    int attrSize = attrs.getLength();
+    String attrString = "";
+    for (int i=0; i<attrSize; i++) {
+      String attrQName = attrs.getQName(i);
+      String attrValue = attrs.getValue(i);
+      attrValue = StringUtils.forXML(attrValue);
+      attrString = attrString + " " + attrQName + "=\"" + attrValue + "\"";
+    }
+    if (attrString != null && ! attrString.isEmpty()) {
+      attrString = attrString.trim();
+    }
+    if (xmlnsString != null && ! xmlnsString.isEmpty()) {
+      xmlnsString = xmlnsString.trim();
+    }
+    if (localName.equals("pb"))
+      firstPageBreakReached = true;
+    // start highlight element at position
+    if (highlightElemName != null && highlightElemName.equals(localName) && firstPageBreakReached) {
+      currentHighlightElemPos++;
+      if (currentHighlightElemPos == highlightElemPos && highlightElemModeOpenTags == 0) {
+        highlightElemMode = true;
+        write("<hi type=\"elem\">");
+      }
+    }
+    if (highlightElemMode) {
+      highlightElemModeOpenTags++;
+    }
+    // start highlight query 
+    if (highlightQuery != null && localName.equals("w")) {
+      boolean matched = false;
+      String attrQName = "form";
+      if (highlightQueryType.equals("orig"))
+        attrQName = "form";
+      else if (highlightQueryType.equals("reg"))
+        attrQName = "formRegularized";
+      else if (highlightQueryType.equals("norm"))
+        attrQName = "formNormalized";
+      else if (highlightQueryType.equals("morph"))
+        attrQName = "lemmas";
+      String attrValue = getAttrValue(attrs, attrQName);
+      if (highlightQueryType.equals("reg") && attrValue == null)
+        attrValue = getAttrValue(attrs, "form"); // if no regularized form exist it takes the form 
+      if (attrValue != null) {
+        String[] forms = highlightQueryForms.split(" "); 
+        for (int i=0; i<forms.length; i++) {
+          if (! matched) {
+            String form = forms[i];
+            if (form.endsWith("*")) {  // TODO support middle wildcard queries: bla*bla bla?bla 
+              form = form.replace("*", "");
+              matched = attrValue.startsWith(form);
+            } else {
+              matched = attrValue.equals(form);  
+            }
+          }
+        }
+      }
+      if ((highlightElemName == null && matched && highlightHitModeOpenTags == 0) || (highlightElemName != null && highlightElemMode && matched && highlightHitModeOpenTags == 0)) {
+        highlightHitMode = true;
+        write("<hi type=\"hit\">");
+      }
+    }
+    if (highlightHitMode) {
+      highlightHitModeOpenTags++;
+    }
+    write("<" + name);
+    if (xmlnsString != null && ! xmlnsString.isEmpty())
+      write(" " + xmlnsString);
+    if (attrString != null && ! attrString.isEmpty())
+      write(" " + attrString);
+    write(">");
+    xmlnsString = "";
+  }
+
+  public void endElement(String uri, String localName, String name) throws SAXException {
+    write("</" + name + ">");
+    // end highlight element at position
+    if (highlightElemMode) {
+      if (highlightElemModeOpenTags == 1) {
+        highlightElemMode = false;
+        write("</hi>");
+      }
+      highlightElemModeOpenTags--;
+    }
+    // end highlight query 
+    if (highlightHitMode) {
+      if (highlightHitModeOpenTags == 1) {
+        highlightHitMode = false;
+        write("</hi>");
+      }
+      highlightHitModeOpenTags--;
+    }
+  }
+
+  private String toString(ArrayList<String> queryForms) {
+    String queryFormsStr = "";
+    for (int i=0; i<queryForms.size(); i++) {
+      String form = queryForms.get(i);
+      queryFormsStr = queryFormsStr + form + " ";
+    }
+    if (queryForms == null || queryForms.size() == 0)
+      return null;
+    else
+      return queryFormsStr.substring(0, queryFormsStr.length() -1); 
+  }
+  
+  private void write(String outStr) throws SAXException {
+    result.append(outStr);
+  }
+  
+  private String getAttrValue(Attributes attrs, String attrQName) {
+    String retValue = null;
+    int attrSize = attrs.getLength();
+    for (int i=0; i<attrSize; i++) {
+      String attrQNameTmp = attrs.getQName(i);
+      String attrValue = attrs.getValue(i);
+      if (attrQNameTmp.equals(attrQName))
+        return attrValue;
+    }
+    return retValue;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/PageTransformer.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,129 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.transform;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+
+import javax.xml.transform.stream.StreamSource;
+
+import de.mpg.mpiwg.berlin.mpdl.cms.document.MetadataRecord;
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+import net.sf.saxon.s9api.Processor;
+import net.sf.saxon.s9api.QName;
+import net.sf.saxon.s9api.SaxonApiException;
+import net.sf.saxon.s9api.Serializer;
+import net.sf.saxon.s9api.XdmAtomicValue;
+import net.sf.saxon.s9api.XdmValue;
+import net.sf.saxon.s9api.XsltCompiler;
+import net.sf.saxon.s9api.XsltExecutable;
+import net.sf.saxon.s9api.XsltTransformer;
+
+public class PageTransformer {
+  private int counter = 0;
+  private Processor processor;
+  private XsltCompiler xsltCompiler;
+  private XsltTransformer pageTeiTransformer;
+  private XsltTransformer pageEchoTransformer;
+  private XsltTransformer pageArchimedesTransformer;
+  private XsltTransformer pageXhtmlTransformer;
+  private XsltTransformer pageXmlTransformer;
+  private String displayWordOptions;
+  
+  public PageTransformer() throws ApplicationException {
+    init();
+  }
+  
+  public void setDisplayWordOptions(String displayWordOptions) {
+    this.displayWordOptions = displayWordOptions;  
+  }
+  
+  private void init() throws ApplicationException {
+    try {
+      processor = new Processor(false); 
+      xsltCompiler = processor.newXsltCompiler();
+      URL getFragmentXslUrl = PageTransformer.class.getResource("pageTei.xsl");
+      StreamSource xslStreamSource = new StreamSource(getFragmentXslUrl.openStream());
+      XsltExecutable xsltExecutable = xsltCompiler.compile(xslStreamSource);
+      pageTeiTransformer = xsltExecutable.load();
+      getFragmentXslUrl = PageTransformer.class.getResource("pageEcho.xsl");
+      xslStreamSource = new StreamSource(getFragmentXslUrl.openStream());
+      xsltExecutable = xsltCompiler.compile(xslStreamSource);
+      pageEchoTransformer = xsltExecutable.load();
+      getFragmentXslUrl = PageTransformer.class.getResource("pageArchimedes.xsl");
+      xslStreamSource = new StreamSource(getFragmentXslUrl.openStream());
+      xsltExecutable = xsltCompiler.compile(xslStreamSource);
+      pageArchimedesTransformer = xsltExecutable.load();
+      getFragmentXslUrl = PageTransformer.class.getResource("pageXhtml.xsl");
+      xslStreamSource = new StreamSource(getFragmentXslUrl.openStream());
+      xsltExecutable = xsltCompiler.compile(xslStreamSource);
+      pageXhtmlTransformer = xsltExecutable.load();
+      getFragmentXslUrl = PageTransformer.class.getResource("pageXml.xsl");
+      xslStreamSource = new StreamSource(getFragmentXslUrl.openStream());
+      xsltExecutable = xsltCompiler.compile(xslStreamSource);
+      pageXmlTransformer = xsltExecutable.load();
+    } catch (SaxonApiException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  public String transform(String inputStr, MetadataRecord mdRecord, int page, String outputFormat) throws ApplicationException {
+    String pageFragment = null;
+    String schemaName = mdRecord.getSchemaName();
+    if (schemaName != null)
+      schemaName = schemaName.toLowerCase();
+    try {
+      XsltTransformer transformer = null;
+      if (schemaName != null && schemaName.equals("tei") && outputFormat.equals("html"))
+        transformer = pageTeiTransformer;
+      else if (schemaName != null && schemaName.equals("echo") && outputFormat.equals("html"))
+        transformer = pageEchoTransformer;
+      else if (schemaName != null && schemaName.equals("archimedes") && outputFormat.equals("html"))
+        transformer = pageArchimedesTransformer;
+      else if (schemaName != null && (schemaName.equals("html") || schemaName.equals("xhtml")) && outputFormat.equals("html"))
+        transformer = pageXhtmlTransformer;
+      else if (outputFormat.equals("xmlDisplay"))
+        transformer = pageXmlTransformer;
+      else
+        transformer = pageTeiTransformer;
+      StringReader inputStrReader = new StringReader(inputStr);
+      StreamSource xmlDoc = new StreamSource(inputStrReader);
+      Serializer serializer = new Serializer();
+      serializer.setOutputWriter(new StringWriter());
+      serializer.setOutputProperty(Serializer.Property.SAXON_STYLESHEET_VERSION, "2.0");
+      serializer.setOutputProperty(Serializer.Property.METHOD, "xml");
+      serializer.setOutputProperty(Serializer.Property.MEDIA_TYPE, "text/html");
+      serializer.setOutputProperty(Serializer.Property.INDENT, "no");
+      serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
+      serializer.setOutputProperty(Serializer.Property.ENCODING, "utf-8");
+      transformer.setSource(xmlDoc);  
+      transformer.setDestination(serializer);
+      String displayWordOptionsStr = ""; // default: empty: display all word parts (dictionaryPart, orig reg, norm)
+      if (displayWordOptions != null)
+        displayWordOptionsStr = displayWordOptions;
+      QName displayWordOptionsQName = new QName("displayWordOptions");
+      XdmValue displayWordOptionsXdmValue = new XdmAtomicValue(displayWordOptionsStr);   
+      transformer.setParameter(displayWordOptionsQName, displayWordOptionsXdmValue);
+      String echoFiguresDir = mdRecord.getEchoFiguresDir();
+      QName echoFiguresDirQName = new QName("echoFiguresDir");
+      XdmValue echoFiguresDirXdmValue = new XdmAtomicValue(echoFiguresDir);
+      transformer.setParameter(echoFiguresDirQName, echoFiguresDirXdmValue);
+      String echoPageImgDir = mdRecord.getEchoPageImageDir();
+      QName echoPageImgDirQName = new QName("echoPageImgDir");
+      XdmValue echoPageImgDirXdmValue = new XdmAtomicValue(echoPageImgDir);
+      transformer.setParameter(echoPageImgDirQName, echoPageImgDirXdmValue);
+      transformer.transform(); 
+      pageFragment = serializer.getOutputDestination().toString();
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    counter++;
+    if (counter == 100)
+      init();
+    return pageFragment;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/QueryTransformer.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,70 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.transform;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URL;
+
+import javax.xml.transform.stream.StreamSource;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+import net.sf.saxon.s9api.Processor;
+import net.sf.saxon.s9api.QName;
+import net.sf.saxon.s9api.SaxonApiException;
+import net.sf.saxon.s9api.Serializer;
+import net.sf.saxon.s9api.XdmAtomicValue;
+import net.sf.saxon.s9api.XdmValue;
+import net.sf.saxon.s9api.XsltCompiler;
+import net.sf.saxon.s9api.XsltExecutable;
+import net.sf.saxon.s9api.XsltTransformer;
+
+public class QueryTransformer {
+  private Processor processor;
+  private XsltCompiler xsltCompiler;
+  private XsltTransformer xsltQueryDocument;
+  
+  public QueryTransformer() throws ApplicationException {
+    init();
+  }
+  
+  private void init() throws ApplicationException {
+    try {
+      processor = new Processor(false); 
+      xsltCompiler = processor.newXsltCompiler();
+      URL queryDocumentXslUrl = QueryTransformer.class.getResource("queryDocument.xsl");
+      StreamSource xslStreamSource = new StreamSource(queryDocumentXslUrl.openStream());
+      XsltExecutable xsltExecutable = xsltCompiler.compile(xslStreamSource);
+      xsltQueryDocument = xsltExecutable.load();
+    } catch (SaxonApiException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  public String queryDocument(String xmlFileName, String query, String flags, String outputFormat) throws ApplicationException {
+    String pageFragment = null;
+    try {
+      StreamSource xmlDoc = new StreamSource(xmlFileName); 
+      Serializer serializer = new Serializer();
+      serializer.setOutputWriter(new StringWriter());
+      serializer.setOutputProperty(Serializer.Property.INDENT, "yes");
+      xsltQueryDocument.setSource(xmlDoc);  // needs some time for bigger documents
+      xsltQueryDocument.setDestination(serializer);
+      QName queryQName = new QName("query");
+      XdmValue queryXdmValue = new XdmAtomicValue(query);
+      QName flagsQName = new QName("flags");
+      XdmValue flagsXdmValue = new XdmAtomicValue(flags);
+      QName outputFormatQName = new QName("outputFormat");
+      XdmValue outputFormatXdmValue = new XdmAtomicValue(outputFormat);
+      xsltQueryDocument.setParameter(queryQName, queryXdmValue);
+      xsltQueryDocument.setParameter(flagsQName, flagsXdmValue);
+      xsltQueryDocument.setParameter(outputFormatQName, outputFormatXdmValue);
+      xsltQueryDocument.transform();  // needs some time for bigger documents
+      pageFragment = serializer.getOutputDestination().toString();
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return pageFragment;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/TocTransformer.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,74 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.transform;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+
+import javax.xml.transform.stream.StreamSource;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+import net.sf.saxon.s9api.Processor;
+import net.sf.saxon.s9api.QName;
+import net.sf.saxon.s9api.SaxonApiException;
+import net.sf.saxon.s9api.Serializer;
+import net.sf.saxon.s9api.XdmAtomicValue;
+import net.sf.saxon.s9api.XdmValue;
+import net.sf.saxon.s9api.XsltCompiler;
+import net.sf.saxon.s9api.XsltExecutable;
+import net.sf.saxon.s9api.XsltTransformer;
+
+public class TocTransformer {
+  private Processor processor;
+  private XsltCompiler xsltCompiler;
+  private XsltTransformer tocTransformer;
+  
+  public TocTransformer() throws ApplicationException {
+    init();
+  }
+  
+  private void init() throws ApplicationException {
+    try {
+      processor = new Processor(false); 
+      xsltCompiler = processor.newXsltCompiler();
+      URL tocXslUrl = TocTransformer.class.getResource("tocOut.xsl");
+      StreamSource xslStreamSource = new StreamSource(tocXslUrl.openStream());
+      XsltExecutable xsltExecutable = xsltCompiler.compile(xslStreamSource);
+      tocTransformer = xsltExecutable.load();
+    } catch (SaxonApiException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  public String transform(String inputStr, String type, String outputFormat) throws ApplicationException {
+    String result = null;
+    try {
+      StringReader inputStrReader = new StringReader(inputStr);
+      StreamSource xmlDoc = new StreamSource(inputStrReader);
+      Serializer serializer = new Serializer();
+      serializer.setOutputWriter(new StringWriter());
+      serializer.setOutputProperty(Serializer.Property.SAXON_STYLESHEET_VERSION, "2.0");
+      serializer.setOutputProperty(Serializer.Property.METHOD, "xhtml");
+      serializer.setOutputProperty(Serializer.Property.INDENT, "no");
+      serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
+      serializer.setOutputProperty(Serializer.Property.ENCODING, "utf-8");
+      tocTransformer.setSource(xmlDoc);  
+      tocTransformer.setDestination(serializer);
+      QName typeQName = new QName("type");
+      XdmValue typeXdmValue = new XdmAtomicValue(type);
+      QName outputFormatQName = new QName("outputFormat");
+      XdmValue outputFormatXdmValue = new XdmAtomicValue(outputFormat);
+      tocTransformer.setParameter(typeQName, typeXdmValue);
+      tocTransformer.setParameter(outputFormatQName, outputFormatXdmValue);
+      tocTransformer.transform(); 
+      result = serializer.getOutputDestination().toString();
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return result;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/XslResourceTransformer.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,94 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.transform;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+
+import javax.xml.transform.stream.StreamSource;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+import net.sf.saxon.s9api.Processor;
+import net.sf.saxon.s9api.QName;
+import net.sf.saxon.s9api.SaxonApiException;
+import net.sf.saxon.s9api.Serializer;
+import net.sf.saxon.s9api.XdmValue;
+import net.sf.saxon.s9api.XsltCompiler;
+import net.sf.saxon.s9api.XsltExecutable;
+import net.sf.saxon.s9api.XsltTransformer;
+
+public class XslResourceTransformer {
+  private Processor processor;
+  private XsltCompiler xsltCompiler;
+  private Serializer serializer;
+  private XsltTransformer xsltTransformer;
+  
+  public XslResourceTransformer(String resourceName) throws ApplicationException {
+    init(resourceName);
+  }
+  
+  private void init(String resourceName) throws ApplicationException {
+    try {
+      processor = new Processor(false); 
+      xsltCompiler = processor.newXsltCompiler();
+      URL xslUrl = XslResourceTransformer.class.getResource(resourceName);
+      StreamSource xslStreamSource = new StreamSource(xslUrl.openStream());
+      XsltExecutable xsltExecutable = xsltCompiler.compile(xslStreamSource);
+      xsltTransformer = xsltExecutable.load();
+    } catch (SaxonApiException e) {
+      throw new ApplicationException(e);
+    } catch (IOException e) {
+      throw new ApplicationException(e);
+    }
+  }
+  
+  public String transform(String xmlFileName) throws ApplicationException {
+    String result = null;
+    try {
+      StreamSource xmlDoc = new StreamSource(xmlFileName); 
+      serializer = new Serializer();
+      serializer.setOutputWriter(new StringWriter());
+      xsltTransformer.setSource(xmlDoc);  // needs some time for bigger documents
+      xsltTransformer.setDestination(serializer);
+      xsltTransformer.transform();  // needs some time for bigger documents
+      result = serializer.getOutputDestination().toString();
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return result;
+  }
+
+  public String transformStr(String xmlStr) throws ApplicationException {
+    String retStr = null;
+    try {
+      StringReader inputStrReader = new StringReader(xmlStr);
+      StreamSource xmlDoc = new StreamSource(inputStrReader);
+      serializer = new Serializer();
+      serializer.setOutputWriter(new StringWriter());
+      xsltTransformer.setSource(xmlDoc);  // needs some time for bigger documents
+      xsltTransformer.setDestination(serializer);
+      xsltTransformer.transform();  // needs some time for bigger documents
+      retStr = serializer.getOutputDestination().toString();
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return retStr;
+  }
+
+  public void setParameter(QName name, XdmValue value) throws ApplicationException {
+    try {
+      xsltTransformer.setParameter(name, value); 
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+  }
+
+  public void setOutputProperty(Serializer.Property property, String value) throws ApplicationException {
+    try {
+      serializer.setOutputProperty(property, value);
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/chars.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes"/>
+
+<xsl:template match="text()">
+  <xsl:sequence select="normalize-space(.)"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageArchimedes.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,332 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:archimedes">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'archimedes'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:expan|*:emph|*:q|*:quote|*:blockquote|*:set-off|*:reg|*:var|*:num">
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="text">
+  <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
+  <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
+  <xsl:variable name="bottomNotes" select="//*:note"/>
+  <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
+    <xsl:apply-templates/>
+    <xsl:if test="$contentStr = '' and empty($figures)">  <!-- test if div only contains empty nodes but no figures -->
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
+        <xsl:value-of select="'[Empty page]'"/>
+      </div>
+    </xsl:if>
+    <!--   Foot notes                      -->
+    <xsl:if test="$countBottomNotes > 0">
+      <div class="notes foot">
+        <xsl:for-each select="$bottomNotes">
+          <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+          <span>
+            <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+            <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+            <span>
+              <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+              <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+              <xsl:apply-templates/>
+            </span>
+          </span>
+        </xsl:for-each>
+      </div>
+    </xsl:if>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <xsl:variable name="type" select="string(@type)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="$type = 'head'">
+        <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>      
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>      
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number">
+    <xsl:choose>
+      <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="file">
+    <xsl:choose>
+      <xsl:when test="not(empty(@xlink:href))"><xsl:value-of select="replace(@xlink:href, '/', '.')"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <span class="figure">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:variable name="fileHref" select="replace(@xlink:href, '/', '.')"/>
+    <xsl:variable name="fileName" select="concat($echoFiguresDir, '/', $fileHref)"/>
+    <xsl:variable name="digilibUrl" select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?fn=', $fileName)"/>
+    <xsl:variable name="scalerUrl" select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/>
+    <xsl:variable name="ancestorWords" select="./ancestor::*:w"/>  <!-- if figure is in a word then no link within a link should be produced -->
+    <xsl:choose>
+      <xsl:when test="empty($ancestorWords)">
+        <a href="{$digilibUrl}">
+          <img>
+            <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+          </img>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <img>
+          <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+        </img>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:if test="not(empty(@number))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
+          <xsl:value-of select="string(@number)"/>
+        </span>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
+          <xsl:value-of select="concat('[', 'Figure', ' ', string(@number), ']')"/>
+        </span>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="note">
+  <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
+  <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+    <span class="noteSign"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></span>
+  </span>
+</xsl:template>
+
+<xsl:template match="foreign">
+  <xsl:variable name="lang" select="@lang"/>
+  <xsl:variable name="xmllang" select="@xml:lang"/>
+  <xsl:variable name="language">
+    <xsl:choose>
+      <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
+      <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="gap">
+  <span class="gap">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
+    <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words                            -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEcho.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,559 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  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:de="http://www.mpiwg-berlin.mpg.de/ns/de/1.0/"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:mml="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms echo de math mml svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:echo">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'echo'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:text">
+  <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
+  <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
+  <xsl:variable name="bottomNotes" select="//*:note[contains(@position, 'foot') or empty(@position)]"/>
+  <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
+    <xsl:apply-templates/>
+    <xsl:if test="$contentStr = '' and empty($figures)">  <!-- test if div only contains empty nodes but no figures -->
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
+        <xsl:value-of select="'[Empty page]'"/>
+      </div>
+    </xsl:if>
+    <!--   Foot notes                      -->
+    <xsl:if test="$countBottomNotes > 0">
+      <div class="notes foot">
+        <xsl:for-each select="$bottomNotes">
+          <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+          <span>
+            <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+            <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+            <span>
+              <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+              <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+              <xsl:apply-templates/>
+            </span>
+          </span>
+        </xsl:for-each>
+      </div>
+    </xsl:if>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <xsl:variable name="style" select="@style"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
+    <xsl:choose>
+      <xsl:when test="not(empty($style))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="empty(@position)"><xsl:value-of select="name()"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat(name(), ' ', string(@position))"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="image" select="*:image"/>
+  <xsl:variable name="caption" select="*:caption"/>
+  <xsl:variable name="description" select="*:description"/>
+  <xsl:variable name="variables" select="*:variables"/>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:if test="not(empty($image))">
+      <xsl:variable name="file" select="$image/@file"/>
+      <xsl:variable name="pn" select="$image/@pn"/>
+      <xsl:variable name="wx" select="$image/@wx"/>
+      <xsl:variable name="wy" select="$image/@wy"/>
+      <xsl:variable name="ww" select="$image/@ww"/>
+      <xsl:variable name="wh" select="$image/@wh"/>
+      <xsl:variable name="digilibServiceName" select="'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html'"/>
+      <xsl:variable name="scalerServiceName" select="'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler'"/>
+      <xsl:variable name="fileName">
+        <xsl:choose>
+          <xsl:when test="empty($wx) and empty($file)"><xsl:value-of select="$echoFiguresDir"/></xsl:when>
+          <xsl:when test="empty($wx) and not(empty($file))"><xsl:value-of select="concat($echoFiguresDir, '/', $file)"/></xsl:when>
+          <xsl:when test="not(empty($wx)) and empty($file)"><xsl:value-of select="$echoPageImgDir"/></xsl:when>
+          <xsl:when test="not(empty($wx)) and not(empty($file))"><xsl:value-of select="concat($echoPageImgDir, '/', $file)"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="$echoFiguresDir"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="digilibUrl">
+        <xsl:choose>
+          <xsl:when test="empty($pn) and empty($wx)"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName)"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and empty($wx)"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;pn=', $pn)"/></xsl:when>
+          <xsl:when test="empty($pn) and not(empty($wx))"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh)"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and not(empty($wx))"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh)"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName)"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="scalerUrl">
+        <xsl:choose>
+          <xsl:when test="empty($pn) and empty($wx)"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and empty($wx)"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:when test="empty($pn) and not(empty($wx))"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and not(empty($wx))"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;dh=200&amp;dw=200')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <a href="{$digilibUrl}">
+        <img>
+          <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+        </img>
+      </a>
+    </xsl:if>
+    <xsl:if test="not(empty(@number))">
+      <xsl:variable name="type"><xsl:value-of select="'Figure'"/></xsl:variable>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
+          <xsl:value-of select="string(@number)"/>
+        </span>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
+          <xsl:value-of select="concat('[', $type, ' ', string(@number), ']')"/>
+        </span>
+      </span>
+    </xsl:if>
+    <xsl:if test="not(empty($caption))">
+      <xsl:for-each select="$caption">
+        <span class="caption"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:if test="not(empty($description))">
+      <xsl:for-each select="$description">
+        <span class="description"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:if test="not(empty($variables))">
+      <xsl:for-each select="$variables">
+        <span class="variables"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="mml:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- XHTML: remove the xhtml namespace   -->
+<xsl:template match="xhtml:*">
+  <xsl:variable name="hasLabel" select="not(empty(@xhtml:label))"/>
+  <xsl:variable name="isTable" select="local-name() = 'table'"/>
+  <xsl:choose>
+    <xsl:when test="(not($hasLabel)) or ($isTable and $hasLabel)">
+      <xsl:element name="{name()}" namespace="">
+        <xsl:copy-of select="@*"/>
+        <xsl:apply-templates/>
+      </xsl:element>
+    </xsl:when>
+    <xsl:otherwise></xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:place|*:person">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <xsl:variable name="style" select="@style"/>
+  <xsl:variable name="class" select="'p'"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="not(empty($style))">
+        <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number">
+    <xsl:choose>
+      <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="file">
+    <xsl:choose>
+      <xsl:when test="not(empty(@file))"><xsl:value-of select="@file"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+      <xsl:if test="not(empty(@o))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'o'"/></xsl:attribute>
+          <xsl:value-of select="@o"/>
+        </span>
+      </xsl:if>
+      <xsl:if test="not(empty(@rhead))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'rhead'"/></xsl:attribute>
+          <xsl:value-of select="@rhead"/>
+        </span>
+      </xsl:if>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:expan">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'expan'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:note|*:handwritten">
+  <xsl:variable name="position">
+    <xsl:choose>
+      <xsl:when test="empty(@position) and name() = 'note'"><xsl:value-of select="'foot'"/></xsl:when>
+      <xsl:when test="empty(@position) and name() = 'handwritten'"><xsl:value-of select="'margin'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="string(@position)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="type">
+    <xsl:choose>
+      <xsl:when test="name() = 'note'"><xsl:value-of select="'printed'"/></xsl:when>
+      <xsl:when test="name() = 'handwritten'"><xsl:value-of select="'handwritten'"/></xsl:when>
+      <xsl:otherwise></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
+  <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="concat('note ', $type, ' ', $position)"/></xsl:attribute>
+    <span class="noteSign">
+      <xsl:choose>
+        <xsl:when test="$position = 'foot'"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></xsl:when>
+        <xsl:otherwise><xsl:value-of select="$noteSign"/></xsl:otherwise>
+      </xsl:choose>
+    </span>
+    <xsl:if test="$position != 'foot'">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+        <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+        <xsl:apply-templates/>
+        <xsl:if test="$type = 'handwritten'">
+          <span>
+            <xsl:attribute name="class"><xsl:value-of select="'noteNumText'"/></xsl:attribute>
+            <xsl:value-of select="concat('[Handwritten note ', string(@number), ']')"/>
+          </span>
+        </xsl:if>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:emph">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'emph'"/></xsl:attribute>
+    <xsl:choose>
+      <xsl:when test="not(empty(@style))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="string(@style)"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:foreign">
+  <xsl:variable name="lang" select="@lang"/>
+  <xsl:variable name="xmllang" select="@xml:lang"/>
+  <xsl:variable name="language">
+    <xsl:choose>
+      <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
+      <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="$language = ''"><xsl:value-of select="'foreign'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat('foreign ', $language)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:q">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'q'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:quote">
+  <span class="quote">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:blockquote">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'blockquote'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:set-off">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'set-off'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:reg">
+  <span class="reg">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'reg'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:var">
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="empty(@type)"><xsl:value-of select="'var'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat('var ', string(@type))"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:num">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'num'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:gap">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
+    <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words  -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageTei.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,690 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:TEI">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'TEI'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:expan|*:emph|*:q|*:quote|*:reg|*:num">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:teiHeader">
+  <!-- do nothing -->
+</xsl:template>
+
+<xsl:template match="*:text">
+  <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
+  <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
+  <xsl:variable name="textAncestors" select="./ancestor::*:text"/>
+  <xsl:variable name="bottomNotes" select="//*:note[contains(@place, 'foot') or empty(@place)]"/>
+  <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
+    <xsl:apply-templates/>
+    <xsl:if test="$contentStr = '' and empty($figures) and empty($textAncestors)">  <!-- test if div only contains empty nodes but no figures -->
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
+        <xsl:value-of select="'[Empty page]'"/>
+      </div>
+    </xsl:if>
+    <!--   Foot notes                      -->
+    <xsl:if test="$countBottomNotes > 0">
+      <div class="notes foot">
+        <xsl:for-each select="$bottomNotes">
+          <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+          <span>
+            <xsl:attribute name="id"><xsl:value-of select="$noteSign"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'note printed foot'"/></xsl:attribute>
+            <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+            <span>
+              <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+              <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+              <xsl:apply-templates/>
+            </span>
+          </span>
+        </xsl:for-each>
+      </div>
+    </xsl:if>
+  </div>
+  <!--   Dictionary                      -->
+  <xsl:if test="not(empty(//*:entry))">
+    <xsl:for-each select="//*:entry">
+      <xsl:sort select="*:form/*:orth"/>
+      <xsl:variable name="position" select="position()"/>
+      <span class="entry">
+        <xsl:apply-templates select="*:form"/>
+        <xsl:apply-templates select="*:sense"/>
+        <xsl:if test="not(empty(*:figure))">
+          <span class="entryDiv">
+            <span class="bf"><xsl:value-of select="'Figures: '"/></span>
+            <span class="entryDiv">
+              <xsl:for-each select="*:figure">
+                <xsl:variable name="href" select="*:graphic/@url"/>
+                <xsl:variable name="figDesc" select="string(*:figDesc)"/>
+                <xsl:if test="$href != ''">
+                  <div class="figure" style="margin-left:10px;">
+                    <a href="{$href}"><img alt="Figure: {$figDesc}" src="{$href}" width="200" height="200"/></a>
+                    <br/>
+                    <xsl:value-of select="'[Figure]: '"/><xsl:apply-templates select="*:head"/>
+                  </div>
+                </xsl:if>
+              </xsl:for-each>
+            </span>
+          </span>
+        </xsl:if>
+        <xsl:if test="not(empty(*:xr))">
+          <span class="entryDiv">
+            <span class="bf"><xsl:value-of select="'References: '"/></span>
+            <span class="entryDiv">
+              <xsl:for-each select="*:xr/*:ref">
+                <li><xsl:apply-templates select="."/></li>
+              </xsl:for-each>
+            </span>
+          </span>
+        </xsl:if>
+      </span>
+    </xsl:for-each>  
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number">
+    <xsl:choose>
+      <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="file">
+    <xsl:choose>
+      <xsl:when test="not(empty(@facs))"><xsl:value-of select="@facs"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <span class="figure">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:variable name="url">
+      <xsl:choose>
+        <xsl:when test="not(empty(@facs))"><xsl:value-of select="string(@facs)"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="string(graphic/@url)"/></xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="fileName" select="concat($echoFiguresDir, '/', $url)"/>
+    <xsl:variable name="digilibUrl">
+      <xsl:choose>
+        <xsl:when test="starts-with($url, 'http')"><xsl:value-of select="$url"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?fn=', $fileName)"/></xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="scalerUrl">
+      <xsl:choose>
+        <xsl:when test="starts-with($url, 'http')"><xsl:value-of select="$url"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="concat('http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=', $fileName, '&amp;dh=200&amp;dw=200')"/></xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <a href="{$digilibUrl}">
+      <img>
+        <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+      </img>
+    </a>
+    <xsl:if test="not(empty(@number))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
+          <xsl:value-of select="string(@number)"/>
+        </span>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
+          <xsl:value-of select="concat('[', 'Figure', ' ', string(@number), ']')"/>
+        </span>
+      </span>
+    </xsl:if>
+    <xsl:if test="not(empty(*:head))">
+      <span class="caption">
+        <xsl:for-each select="*:head">
+          <xsl:apply-templates/>
+        </xsl:for-each>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- segmentation   -->
+<xsl:template match="*:seg">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@rend = 'highlight'">
+        <xsl:attribute name="class"><xsl:value-of select="'seg highlight'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@rend = 'highlightPoint'">
+        <xsl:attribute name="class"><xsl:value-of select="'seg highlightPoint'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="class"><xsl:value-of select="'seg'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </span>
+</xsl:template>
+
+<!-- choice   -->
+<xsl:template match="*:choice">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'choice'"/></xsl:attribute>
+    <xsl:if test="not(empty(*:orig))">
+      <xsl:apply-templates select="*:orig"/>
+    </xsl:if>
+    <xsl:if test="not(empty(*:abbr))">
+      <xsl:apply-templates select="*:abbr"/>
+    </xsl:if>
+    <xsl:if test="not(empty(*:am))">
+      <xsl:apply-templates select="*:am"/>
+    </xsl:if>
+    <xsl:if test="not(empty(*:sic))">
+      <xsl:apply-templates select="*:sic"/>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- hi (highlighted)  -->
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="not(empty(@type)) and @type = 'elem'">
+      <div>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:when test="not(empty(@type)) and @type != 'elem'">
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:when>
+    <xsl:when test="@rend = 'initial'">
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="'initial'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:when>
+    <xsl:when test="@rend = 'bold'">
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="'bf'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- name (of type: place, person, ...)   -->
+<xsl:template match="*:name">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@type = 'place'">
+        <xsl:attribute name="class"><xsl:value-of select="'place'"/></xsl:attribute>
+        <xsl:attribute name="title"><xsl:value-of select="'Place'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@type = 'person'">
+        <xsl:attribute name="class"><xsl:value-of select="'person'"/></xsl:attribute>
+        <xsl:attribute name="title"><xsl:value-of select="'Person'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@type = 'org'">
+        <xsl:attribute name="class"><xsl:value-of select="'organization'"/></xsl:attribute>
+        <xsl:attribute name="title"><xsl:value-of select="'Organization'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:attribute name="class"><xsl:value-of select="@type"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </span>
+</xsl:template>
+
+<!-- place, person, ...)   -->
+<xsl:template match="*:placeName">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'place'"/></xsl:attribute>
+    <xsl:attribute name="title"><xsl:value-of select="concat('Place: ', @type)"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+<xsl:template match="*:persName">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'person'"/></xsl:attribute>
+    <xsl:attribute name="title"><xsl:value-of select="'Person'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- term    -->
+<xsl:template match="*:term">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'term'"/></xsl:attribute>
+    <xsl:attribute name="title"><xsl:value-of select="'Terminology entry'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- line    -->
+<xsl:template match="*:lg">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lg'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:l">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'l'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+  <br/>
+</xsl:template>
+
+<!-- reference: sourounds it by parantheses so that it could be 
+iop from word links within it  -->
+<xsl:template match="*:ref">
+  <xsl:variable name="refPos"><xsl:value-of select="count(./preceding::*:ref) + 1"/></xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'ref'"/></xsl:attribute>
+    <xsl:if test="not(empty(@target))">
+      <a class="ref">
+        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
+        <span class="super"><xsl:value-of select="concat('[', $refPos)"/></span>
+      </a>
+      <xsl:value-of select="' '"/>
+      <xsl:apply-templates/>
+      <xsl:value-of select="' '"/>
+      <a class="ref">
+        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
+        <span class="super"><xsl:value-of select="concat($refPos, ']')"/></span>
+      </a>
+    </xsl:if>
+    <xsl:if test="empty(@target)">
+      <xsl:apply-templates/>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- table    -->
+<xsl:template match="*:table">
+  <table>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(head))">
+      <caption align="top"><xsl:apply-templates select="*:head"/></caption>
+    </xsl:if>
+    <xsl:apply-templates select="*:row"/>
+  </table>
+</xsl:template>
+
+<xsl:template match="*:row">
+  <tr>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@role = 'label'">
+01002    b
+  ghj565hghj23,b02,0    <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
+  0      <xsl:apply-templates/>
+   bvcxvb4    </xsl:when>
+      <xsl:when test="@role = 'data' or empty(@role)">
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </tr>
+</xsl:template>
+
+<xsl:template match="*:cell">
+  <td>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="@role = 'label' and empty(@cols)">
+        <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="@role = 'label' and not(empty(@cols))">
+        <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
+        <xsl:attribute name="style"><xsl:value-of select="'font-weight:bold;'"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="(@role = 'data' or empty(@role)) and empty(@cols)">
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:when test="(@role = 'data' or empty(@role)) and not(empty(@cols))">
+        <xsl:attribute name="colspan"><xsl:value-of select="@cols"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </td>
+</xsl:template>
+
+<!-- dictionary    -->
+<xsl:template match="*:entry">
+  <!-- emp
+  
+  + handled in text tag    -->
+</xsl:template>
+
+<xsl:template match="*:form">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'form'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:orth">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'orth'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:sense">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'sense'"/></xsl:attribute>
+    <span class="entryDiv"><xsl:apply-templates select="*:def"/></span>
+    <span class="entryDiv"><xsl:apply-templates select="*:etym"/></span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:def">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'def'"/></xsl:attribute>
+    <span class="bf"><xsl:value-of select="'Definition: '"/></span>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:mentioned">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'mentioned'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:etym">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'etym'"/></xsl:attribute>
+    <span class="bf"><xsl:value-of select="'Etymology: '"/></span>
+    <span class="entryDiv">
+      <xsl:for-each select="*:cit">
+        <li><xsl:apply-templates select="*:quote"/><xsl:value-of select="' ('"/><xsl:apply-templates select="*:def"/><xsl:value-of select="')'"/></li>
+      </xsl:for-each>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:cit">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cit'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:note">
+  <xsl:variable name="position">
+    <xsl:choose>
+      <xsl:when test="empty(@place) and name() = 'note'"><xsl:value-of select="'foot'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="string(@place)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="type" select="'printed'"/>
+  <xsl:variable name="noteSign" select="count(./preceding::*:note) + 1"/>
+  <xsl:variable name="href" select="concat(urlBase, '#', $noteSign)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="concat('note ', $type, ' ', $position)"/></xsl:attribute>
+    <span class="noteSign">
+      <xsl:choose>
+        <xsl:when test="$position = 'foot'"><a href="{$href}"><xsl:value-of select="$noteSign"/></a></xsl:when>
+        <xsl:otherwise><xsl:value-of select="$noteSign"/></xsl:otherwise>
+      </xsl:choose>
+    </span>
+    <xsl:if test="$position != 'foot'">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+        <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:foreign">
+  <xsl:variable name="xmllang" select="@xml:lang"/>
+  <xsl:variable name="language">
+    <xsl:choose>
+      <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:gap">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
+    <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words                            -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXhtml.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,240 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:saxon="http://saxon.sf.net/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xs saxon dc dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="displayWordOptions"></xsl:param>
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<!-- the identity template -->
+<xsl:template match="@*|node()">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="*:html">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="*:body">
+  <!-- to set the xhtml namespace onto this dummy node -->
+  <page>
+    <xsl:apply-templates/>
+  </page>
+</xsl:template>
+
+<xsl:template match="*:expan|*:emph|*:q|*:quote|*:blockquote|*:set-off|*:reg|*:var|*:num|*:figure">
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:a">
+  <!-- empty element with only name attribute makes trouble -->
+  <xsl:variable name="name" select="@name"/>
+  <xsl:variable name="href" select="@href"/>
+  <xsl:choose>
+    <xsl:when test="not(empty($name)) and empty($href)">
+      <span>
+        <xsl:attribute name="id"><xsl:value-of select="$name"/></xsl:attribute>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <a class="ref">
+        <xsl:copy-of select="@*"/>
+        <xsl:apply-templates/>
+      </a>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <div>
+    <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number" select="count(./preceding::*:pb) + 1"/>
+  <xsl:variable name="file" select="$number"/>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+    </span>
+  </span>
+</xsl:template>
+
+<!--  MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:br">
+  <br>
+    <xsl:attribute name="class"><xsl:value-of select="'br'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:note">
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words                            -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <a class="dictionary">
+          <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$displayWordOptions = ''">
+        <span class="w">
+          <xsl:sequence select="$dictionaryPart"/>
+          <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="w">
+          <xsl:if test="contains($displayWordOptions, 'dictionaryPart')"><xsl:sequence select="$dictionaryPart"/></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'orig')"><span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'reg')"><span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span></xsl:if>
+          <xsl:if test="contains($displayWordOptions, 'norm')"><span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span></xsl:if>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:sequence select="$displayWord"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageXml.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink dcterms math svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<!-- transform to browser like xml display -->
+<xsl:template match="element()">
+  <xsl:variable name="elementName" select="name()"/>
+  <xsl:variable name="elementPresentation">
+    <xsl:choose>
+    <xsl:when test="element() = node() or text() != ''">
+      <xsl:value-of select="'&lt;'"/>
+      <span class="xml elementName"><xsl:value-of select="$elementName"/></span>
+      <xsl:apply-templates select="attribute()"/>
+      <xsl:value-of select="'&gt;'"/>
+      <xsl:apply-templates select="element()|text()|comment()|processing-instruction()"/>
+      <xsl:value-of select="'&lt;/'"/>
+      <span class="xml elementName"><xsl:value-of select="$elementName"/></span>
+      <xsl:value-of select="'&gt;'"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="'&lt;'"/>
+      <span class="xml elementName"><xsl:value-of select="$elementName"/></span>
+      <xsl:apply-templates select="attribute()"/>
+      <xsl:value-of select="'/&gt;'"/>
+    </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <ul class="xml element">
+    <xsl:sequence select="$elementPresentation"/>
+  </ul>
+</xsl:template>
+
+<xsl:template match="attribute()">
+  <xsl:variable name="attributeName" select="name()"/>
+  <span class="xml attributeName">
+    <xsl:value-of select="' '"/>
+    <xsl:value-of select="$attributeName"/>
+  </span>
+  <xsl:value-of select="'=&quot;'"/>
+  <span class="xml attributeValue"><xsl:value-of select="."/></span><xsl:value-of select="'&quot;'"/>
+</xsl:template>
+
+<xsl:template match="comment()">
+  <span class="xml comment">
+    <xsl:value-of select="'&lt;!-- '"/><xsl:value-of select="."/><xsl:value-of select="' --&gt;'"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="processing-instruction()">
+</xsl:template>
+
+<xsl:template match="*:w">
+  <xsl:apply-templates select="*:orig/node()"/>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/queryDocument.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+ 
+<xsl:param name="query"></xsl:param>
+<xsl:param name="flags"></xsl:param>
+<xsl:param name="outputFormat"></xsl:param>
+
+<xsl:variable name="apos">'</xsl:variable>
+<xsl:variable name="xpathQuery">
+  <xsl:choose>
+    <xsl:when test="$flags = ''"><xsl:value-of select="concat('//*:s[matches(.,', $apos, $query, $apos, ')]', '|', '//*:head[matches(.,', $apos, $query, $apos, ')]')"/></xsl:when>
+    <xsl:otherwise><xsl:value-of select="concat('//*:s[matches(.,', $apos, $query, $apos, ',', $apos, $flags, $apos, ')]', '|', '//*:head[matches(.,', $apos, $query, $apos, ',', $apos, $flags, $apos, ')]')"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+<xsl:variable name="queryResult" select="saxon:evaluate($xpathQuery)" xmlns:saxon="http://saxon.sf.net/"/>
+<xsl:variable name="queryResultSize"><xsl:value-of select="count($queryResult)"/></xsl:variable>
+<xsl:variable name="queryResultPageSize" select="20"/>
+<xsl:variable name="queryResultPages">
+  <xsl:choose>
+    <xsl:when test="$queryResultSize = 0"><xsl:value-of select="count($queryResult)"/></xsl:when>
+    <xsl:otherwise><xsl:value-of select="$queryResultSize idiv $queryResultPageSize + 1"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+<xsl:variable name="pageBreaks" select="saxon:evaluate('//*:pb')" xmlns:saxon="http://saxon.sf.net/"/>
+<xsl:variable name="queryResultHtml">
+<xsl:choose>
+  <xsl:when test="$outputFormat = 'html'">
+    <table>
+      <thead>
+        <tr>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">No.</button>
+          </th>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Path</button>
+          </th>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Hit</button>
+          </th>
+          <th align="left" valign="top">
+            <button name="order-by" value="author" style="padding:0px;font-weight:bold;font-size:14px;background:none;border:none;">Page</button>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <xsl:for-each select="$queryResult">
+          <xsl:variable name="hit" select="."/>
+          <tr>
+            <td align="left" valign="top"><xsl:value-of select="position()"/></td>
+            <td align="left" valign="top"><xsl:value-of select="saxon:path(.)" xmlns:saxon="http://saxon.sf.net/"/></td>
+            <td align="left" valign="top"><xsl:value-of select="."/></td>
+            <td align="left" valign="top"><xsl:value-of select="count(./preceding::*:pb)"/></td>     <!-- better performance: count($pageBreaks[. << $hit])  -->
+          </tr>
+        </xsl:for-each>    
+      </tbody>
+    </table>
+  </xsl:when>
+  <xsl:otherwise>
+    <result>
+      <query><xsl:value-of select="$query"/></query>
+      <flags><xsl:value-of select="$flags"/></flags>
+      <size><xsl:value-of select="$queryResultSize"/></size>
+      <page-size><xsl:value-of select="$queryResultPageSize"/></page-size>
+      <pages><xsl:value-of select="$queryResultPages"/></pages>
+      <pn>1</pn>
+      <hits>
+        <xsl:for-each select="$queryResult">
+          <xsl:variable name="hit" select="."/>
+          <hit>
+            <hitType><xsl:value-of select="'s'"/></hitType>
+            <pos><xsl:value-of select="position()"/></pos>
+            <pn><xsl:value-of select="count(./preceding::*:pb)"/></pn>
+            <hitId>xmlId</hitId>
+            <hitPos>4711</hitPos>
+            <hitString><xsl:value-of select="."/></hitString>
+            <hitSurroundsPB>false</hitSurroundsPB>
+          </hit>
+        </xsl:for-each>    
+      </hits>
+      <query-forms></query-forms>
+      <query-regularizations></query-regularizations>
+    </result>
+  </xsl:otherwise>
+</xsl:choose>
+</xsl:variable>
+<xsl:template match="/">
+  <xsl:sequence select="$queryResultHtml"/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/replaceAnchor.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet 
+  version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xhtml"
+>
+
+<xsl:output method="xml" encoding="utf-8"/>
+
+<xsl:template match="@*|node()">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+<!-- insert figure number  -->
+<xsl:template match="*:figure">
+  <xsl:variable name="number" select="count(./preceding::*:figure) + 1"/>
+  <xsl:element name="{name()}" namespace="{namespace-uri()}"><!-- remove namespace in element and its subnodes  -->
+    <xsl:apply-templates select="@*"/>
+    <xsl:attribute name="number"><xsl:value-of select="$number"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- insert figure number  -->
+<xsl:template match="*:handwritten">
+  <xsl:variable name="number" select="count(./preceding::*:handwritten) + 1"/>
+  <xsl:element name="{name()}" namespace="{namespace-uri()}"><!-- remove namespace in element and its subnodes  -->
+    <xsl:apply-templates select="@*"/>
+    <xsl:attribute name="number"><xsl:value-of select="$number"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:anchor">
+  <xsl:variable name="type" select="@type"/>
+  <xsl:variable name="href" select="@xlink:href"/>
+  <xsl:choose>
+    <xsl:when test="$type = 'figure'">
+      <xsl:variable name="figure" select="//*:figure[@xlink:label = $href]"/>
+      <xsl:apply-templates select="$figure"/>
+    </xsl:when>
+    <xsl:when test="$type = 'handwritten'">
+      <xsl:variable name="handwritten" select="//*:handwritten[@xlink:label = $href]"/>
+      <xsl:apply-templates select="$handwritten"/>
+    </xsl:when>
+    <xsl:when test="$type = 'note'">
+      <xsl:variable name="note" select="//*:note[@xlink:label = $href]"/>
+      <xsl:sequence select="$note"/>
+    </xsl:when>
+    <xsl:when test="$type = 'table'">
+      <xsl:variable name="table" select="//xhtml:table[@xlink:label = $href]"/>
+      <xsl:sequence select="$table"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy>
+        <xsl:apply-templates select="@*|node()"/>
+      </xsl:copy>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- remove the anchored divs: div which contain a labeled figure, note, handwritten or table -->
+<xsl:template match="*:div">
+  <xsl:variable name="containingElems" select="*:figure|*:note|*:handwritten|xhtml:table"/>
+  <xsl:variable name="hasLabel" select="not(empty($containingElems[1]/@xlink:label))"/>
+  <xsl:choose>
+    <xsl:when test="$hasLabel"></xsl:when>
+    <xsl:otherwise>
+      <xsl:copy>
+        <xsl:apply-templates select="@*|node()"/>
+      </xsl:copy>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/toc.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,147 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet 
+  version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="xsl xlink xhtml"
+>
+
+<xsl:output method="xml" encoding="utf-8" indent="yes"/>
+
+<xsl:template match="/">
+  <xsl:variable name="toc" select="//*:div[@type = 'section' or @type = 'chapter' or @type = 'part']"/>
+  <xsl:variable name="figures" select="//*:figure"/>
+  <xsl:variable name="notes" select="//*:note|//*:handwritten"/>
+  <xsl:variable name="pages" select="//*:pb"/>
+  <xsl:variable name="places" select="//*:place"/>
+  <list>
+    <xsl:if test="not(empty($toc))">
+      <list type ="toc">
+        <xsl:attribute name="count"><xsl:value-of select="count($toc)"/></xsl:attribute>
+        <head>Table of contents</head>
+        <xsl:apply-templates select="$toc"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($figures))">
+      <list type="figures">
+        <xsl:attribute name="count"><xsl:value-of select="count($figures)"/></xsl:attribute>
+        <head>Figures</head>
+        <xsl:apply-templates select="$figures"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($notes))">
+      <list type="notes">
+        <xsl:attribute name="count"><xsl:value-of select="count($notes)"/></xsl:attribute>
+        <head>Notes</head>
+        <xsl:apply-templates select="$notes"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($pages))">
+      <list type="pages">
+        <xsl:attribute name="count"><xsl:value-of select="count($pages)"/></xsl:attribute>
+        <head>Pages</head>
+        <xsl:apply-templates select="$pages"/>
+      </list>
+    </xsl:if>
+    <xsl:if test="not(empty($places))">
+      <list type="places">
+        <xsl:attribute name="count"><xsl:value-of select="count($places)"/></xsl:attribute>
+        <head>Places</head>
+        <xsl:apply-templates select="$places"/>
+      </list>
+    </xsl:if>
+  </list>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <xsl:variable name="number" select="@number"/>
+  <item>
+    <xsl:if test="not(empty($number))"><xsl:attribute name="n"><xsl:value-of select="$number"/></xsl:attribute></xsl:if>
+    <xsl:apply-templates select="*:caption"/>
+    <xsl:apply-templates select="*:description"/>
+    <xsl:apply-templates select="*:variables"/>
+    <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:caption"><xsl:value-of select="' '"/>
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="*:description">
+  <xsl:apply-templates/><xsl:value-of select="' '"/>
+</xsl:template>
+
+<xsl:template match="*:variables">
+  <xsl:apply-templates/><xsl:value-of select="' '"/>
+</xsl:template>
+
+<xsl:template match="*:note|*:handwritten">
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <xsl:variable name="number" select="@number"/>
+  <xsl:variable name="position" select="@position"/>
+  <xsl:variable name="type">
+    <xsl:choose>
+      <xsl:when test="name() = 'note'"><xsl:value-of select="'printed'"/></xsl:when>
+      <xsl:when test="name() = 'handwritten'"><xsl:value-of select="'handwritten'"/></xsl:when>
+      <xsl:otherwise></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <item>
+    <xsl:if test="not(empty($type))"><xsl:attribute name="type"><xsl:value-of select="$type"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($position))"><xsl:attribute name="position"><xsl:value-of select="$position"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($number))"><xsl:attribute name="n"><xsl:value-of select="$number"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:place">
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <xsl:variable name="id" select="@id"/>
+  <item>
+    <xsl:if test="not(empty($id))"><xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute></xsl:if>
+    <content><xsl:apply-templates/></content>
+    <xsl:if test="not(empty($page))"><ref><xsl:value-of select="$page"/></ref></xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:variable name="level"><xsl:number level="multiple" count="*:div[@type = 'section' or @type = 'chapter' or @type = 'part']" format="1."/></xsl:variable>
+  <xsl:variable name="depth" select="string-length(replace($level, '[^\\.]', ''))"/>
+  <xsl:variable name="pb" select="./preceding::*:pb[1]"/>
+  <xsl:variable name="o" select="$pb/@o"/>
+  <xsl:variable name="oNorm" select="$pb/@o-norm"/>
+  <xsl:variable name="page" select="count(./preceding::*:pb)"/>
+  <item>
+    <xsl:if test="not(empty($level))"><xsl:attribute name="n"><xsl:value-of select="$level"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty($level))"><xsl:attribute name="lv"><xsl:value-of select="$depth"/></xsl:attribute></xsl:if>
+    <xsl:apply-templates select="*:head"/>
+    <xsl:if test="not(empty($page))">
+      <ref>
+        <xsl:if test="not(empty($o))"><xsl:attribute name="o"><xsl:value-of select="$o"/></xsl:attribute></xsl:if>
+        <xsl:if test="not(empty($oNorm))"><xsl:attribute name="o-norm"><xsl:value-of select="$oNorm"/></xsl:attribute></xsl:if>
+        <xsl:value-of select="$page"/>
+      </ref>
+    </xsl:if>
+  </item>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <xsl:apply-templates/><xsl:value-of select="' '"/>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="page" select="count(./preceding::*:pb) + 1"/>
+  <item>
+    <xsl:attribute name="n"><xsl:value-of select="$page"/></xsl:attribute>
+    <xsl:if test="not(empty(@o))"><xsl:attribute name="o"><xsl:value-of select="@o"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(@o-norm))"><xsl:attribute name="o-norm"><xsl:value-of select="@o-norm"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(@file))"><xsl:attribute name="file"><xsl:value-of select="@file"/></xsl:attribute></xsl:if>
+    <xsl:if test="not(empty(@facs))"><xsl:attribute name="file"><xsl:value-of select="@facs"/></xsl:attribute></xsl:if>
+  </item>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/tocOut.xsl	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet 
+  version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+<xsl:output method="xhtml"/>
+
+<xsl:param name="type"></xsl:param>
+<xsl:param name="outputFormat"></xsl:param>
+
+<xsl:template match="/">
+  <xsl:choose>
+    <xsl:when test="$outputFormat = 'html'">
+      <xsl:apply-templates select="//*:list[@type = $type]/item" mode="html"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:sequence select="//*:list[@type = $type]"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*:item" mode="html">
+  <xsl:variable name="n" select="@n"/>
+  <xsl:variable name="level" select="@lv"/>
+  <div>
+    <xsl:attribute name="class"><xsl:value-of select="'tocItem'"/></xsl:attribute>
+    <xsl:value-of select="concat($n, ' ')"/>
+    <xsl:apply-templates mode="html"/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:ref" mode="html">
+  <xsl:variable name="pageOrig" select="@o"/>
+  <xsl:variable name="page" select="text()"/>
+  <xsl:variable name="pageHref" select="concat('#page', $page)"/>
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="'tocPageRef'"/></xsl:attribute>
+    <xsl:value-of select="'Page: '"/>
+    <a href="{$pageHref}"><xsl:apply-templates mode="html"/></a>
+  </span>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/translator/MicrosoftTranslator.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,120 @@
+package de.mpg.mpiwg.berlin.mpdl.cms.translator;
+
+import java.util.ArrayList;
+
+import com.memetix.mst.language.Language;
+import com.memetix.mst.translate.Translate;
+import com.memetix.mst.detect.Detect;
+
+import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
+
+public class MicrosoftTranslator {
+  private static final String KEY = "474A4E72DB217E37031EC190ACB4159378A6917C";  // free key to use with Microsoft server
+  private static String[] DEST_LANGUAGES = {"eng", "ger", "fra"};
+
+  private MicrosoftTranslator() {
+    // nothing: prevent instantiation
+  }
+  
+  public static String[] getDestLanguages() {
+    return DEST_LANGUAGES;
+  }
+
+  public static String translate(String query, String toLanguageStr) throws ApplicationException {
+    if (toLanguageStr == null)
+      throw new ApplicationException("MicrosoftTranslator: toLanguageStr is null");
+    String translation = null;
+    try {
+      Translate.setKey(KEY);  // Set the API key once per JVM. It is set statically and applies to all services
+      String langId = de.mpg.mpiwg.berlin.mpdl.lt.general.Language.getInstance().getLanguageId(toLanguageStr);  // e.g. "de" is delivered from "deu"
+      Language toLanguage = Language.fromString(langId);
+      translation = Translate.execute(query, toLanguage);
+      translation = translation.toLowerCase();
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return translation;
+  }
+
+  public static String translate(String query, String fromLanguageStr, String toLanguageStr) throws ApplicationException {
+    if (fromLanguageStr == null)
+      throw new ApplicationException("MicrosoftTranslator: toLanguageStr is null");
+    if (toLanguageStr == null)
+      throw new ApplicationException("MicrosoftTranslator: fromLanguageStr is null");
+    String translation = null;
+    try {
+      Translate.setKey(KEY);
+      String fromLangId = de.mpg.mpiwg.berlin.mpdl.lt.general.Language.getInstance().getLanguageId(fromLanguageStr);  // e.g. "de" is delivered from "deu"
+      String toLangId = de.mpg.mpiwg.berlin.mpdl.lt.general.Language.getInstance().getLanguageId(toLanguageStr);  // e.g. "de" is delivered from "deu"
+      Language fromLanguage = Language.fromString(fromLangId);
+      Language toLanguage = Language.fromString(toLangId);
+      translation = Translate.execute(query, fromLanguage, toLanguage);
+      translation = translation.toLowerCase();
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return translation;
+  }
+
+  public static ArrayList<String> translate(String[] query, String fromLanguageStr, String[] toLanguagesStr) throws ApplicationException {
+    ArrayList<String> translations = new ArrayList<String>();
+    for (int i=0; i<toLanguagesStr.length; i++) {
+      String toLanguageStr = toLanguagesStr[i];
+      String[] translationsArray = translate(query, fromLanguageStr, toLanguageStr);
+      for (int j=0; j<translationsArray.length; j++) {
+        String translation = translationsArray[j];
+        translations.add(translation);
+      }
+    }
+    return translations;
+  }
+  
+  public static String[] translate(String[] query, String fromLanguageStr, String toLanguageStr) throws ApplicationException {
+    if (fromLanguageStr == null)
+      throw new ApplicationException("MicrosoftTranslator: toLanguageStr is null");
+    if (toLanguageStr == null)
+      throw new ApplicationException("MicrosoftTranslator: fromLanguageStr is null");
+    String[] translation = null;
+    try {
+      Translate.setKey(KEY);  
+      String fromLangId = de.mpg.mpiwg.berlin.mpdl.lt.general.Language.getInstance().getLanguageId(fromLanguageStr);  // e.g. "de" is delivered from "deu"
+      String toLangId = de.mpg.mpiwg.berlin.mpdl.lt.general.Language.getInstance().getLanguageId(toLanguageStr);  // e.g. "de" is delivered from "deu"
+      Language fromLanguage = Language.fromString(fromLangId);
+      Language toLanguage = Language.fromString(toLangId);
+      translation = Translate.execute(query, fromLanguage, toLanguage);
+      for (int i=0; i<translation.length; i++) {
+        translation[i] = translation[i].toLowerCase();
+      }
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return translation;
+  }
+
+  public static String detectLanguageCode(String query) throws ApplicationException {
+    String langCode = null;
+    try {
+      Detect.setKey(KEY);
+      Language detectedLanguage = Detect.execute(query);
+      if (detectedLanguage != null)
+        langCode = detectedLanguage.toString();
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return langCode;
+  }
+   
+  public static String detectLanguageName(String query) throws ApplicationException {
+    String langName = null;
+    try {
+      Detect.setKey(KEY);
+      Language detectedLanguage = Detect.execute(query);
+      if (detectedLanguage != null)
+        langName = detectedLanguage.getName(Language.GERMAN);
+    } catch (Exception e) {
+      throw new ApplicationException(e);
+    }
+    return langName;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services-new/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/exception/ApplicationException.java	Tue May 21 10:19:32 2013 +0200
@@ -0,0 +1,14 @@
+package de.mpg.mpiwg.berlin.mpdl.exception;
+
+public class ApplicationException extends Exception {
+
+  public ApplicationException(Exception e) {
+    super(e);
+  }
+
+  public ApplicationException(String str) {
+    super(str);
+  }
+
+}
+