Index: /trunk/__init__.py
===================================================================
--- /trunk/__init__.py	(revision 3)
+++ /trunk/__init__.py	(revision 3)
@@ -0,0 +1,13 @@
+import displayXML
+
+def initialize(context):
+    """initialize OSAS"""
+
+    
+    context.registerClass(
+        displayXML.displayXML,
+        constructors = (
+          displayXML.manage_addDisplayXMLForm,
+          displayXML.manage_addDisplayXML
+          )
+        )
Index: /trunk/analyseAndTag/test.xml
===================================================================
--- /trunk/analyseAndTag/test.xml	(revision 3)
+++ /trunk/analyseAndTag/test.xml	(revision 3)
@@ -0,0 +1,5 @@
+<test>
+<a>fgsg<p>jjkljjk</p>ggddg</a>jljklj
+</test>
+
+
Index: /trunk/displayXML.py
===================================================================
--- /trunk/displayXML.py	(revision 3)
+++ /trunk/displayXML.py	(revision 3)
@@ -0,0 +1,650 @@
+### XSLT Class ###
+### setzt 4 suite vorraus ###
+from Acquisition import Implicit
+from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
+from Globals import DTMLFile
+
+from threading import Thread,Timer
+import threading
+
+import sys
+import urllib
+import urlparse
+from Ft.Xml.Domlette import Print, PrettyPrint
+from StringIO import StringIO
+from types import *
+from Globals import package_home
+import transaction
+
+import os.path
+
+import urllib,cgi
+
+try:
+    from Ft.Xml.Xslt.Processor import Processor
+    from Ft.Xml import InputSource, EMPTY_NAMESPACE,Parse
+    from Ft.Xml.Domlette import NonvalidatingReader
+except:
+    print "4suite has to be installed"
+
+from analyseAndTag.analyseAndTag import DonatusFile
+
+def zptFile(self, path, orphaned=False):
+    """returns a page template file from the product"""
+    if orphaned:
+        # unusual case
+        pt=PageTemplateFile(os.path.join(package_home(globals()), path))
+    else:
+      
+            pt=PageTemplateFile(os.path.join(package_home(globals()), path)).__of__(self)
+    return pt
+
+
+class getXML(Implicit):
+    """get XML thread"""
+
+    def set(self,qs,xsl,result):
+        """set"""
+   
+        self._v_qs=qs
+        self.xsl=xsl
+        self.result=None        
+
+#    def acquireLock(self):
+#    
+#         lock=getattr(self, "_v_lock", None)
+#         if not lock:
+#             self._v_lock=threading.Lock()
+#             lock=self._v_lock
+#         lock.acquire()
+#
+#    def releaseLock(self):
+#         # acquire() should have been called
+#         # about one second before. This means the volatile lock
+#         # should still be there
+#    
+#         self._v_lock.release()
+#        
+  
+    def __call__(self):
+        """wait"""
+        return True
+    
+    def run(self):
+        """call it"""
+        xml=""
+
+        try:
+  
+            urlH=urllib.urlopen(self._v_qs)
+            xml=urlH.read()
+            urlH.close()
+            xsltproc=Processor()
+            document = InputSource.DefaultFactory.fromString(xml)
+            
+            stylesheet = InputSource.DefaultFactory.fromUri(self.xsl)
+            
+            xsltproc.appendStylesheet(stylesheet)
+            
+        
+            #print self.xsl
+            #< xsltproc.run(document)
+            tmp=xsltproc.run(document)
+            
+            self.result=tmp[0:]
+            
+        
+       	except:
+               
+               self.result="<html>error: %s %s<br>"%sys.exc_info()[0:2]
+               self.result+=xml
+               self.result+="</html>"
+        
+        
+    
+    def getResult(self):
+
+        return self.result
+
+from ZODB import DB
+from ZODB.FileStorage import FileStorage
+
+class XML_caching:
+    def __init__(self):
+        """init the storage"""
+        self.storage=FileStorage(os.path.join(INSTANCE_HOME,"var/XML_caching.fs"))		
+        self.db=DB(self.storage)    
+        self.connection=self.db.open()
+        self.root=self.connection.root()
+    
+    def deleteObject(self,name,pn=None):
+        """delete an object from cache"""
+        fileStore=self.root.get(name,None)
+        if fileStore:
+            if not pn:
+                del(self.root[name])
+            else:
+                if self.root[name].get(pn,None):
+                    del(self.root[name][pn])
+                    
+        
+    def storeObject(self,name,pn,object):
+        """store an object"""
+        
+        if not self.root.get(name,None):
+            self.root[name]={}
+            
+
+        #following is necessary to make clear that object has really changed for ZODB
+        tmp=self.root[name]
+        tmp[pn]=object
+        self.root[name]=tmp
+        transaction.get().commit()
+        return True
+   
+    def retrieveObject(self,name,pn):
+        """retrieve it"""
+        
+        fileStore=self.root.get(name,None)
+        if not fileStore:
+            return None
+        else:
+           
+            return self.root[name].get(pn,None)
+        
+
+class displayXML(ZopePageTemplate):
+    """xml viewer mit morphologischen Tools"""
+
+    meta_type="displayXML"
+    
+    cache=XML_caching() # cache for analysed pages
+    caching="yes"
+    
+    appendQueryString=True # add query string to the cgiUrl can be changed with addChanges
+    
+    passURL=False #use url from querystring parameter fn to retrieve the text and not the url in cgi-url can be changed with addChanges
+        
+    
+    results={}
+    manage_options=ZopePageTemplate.manage_options+(
+     {'label':'Change xml-ressource','action':'change_displayXMLForm'},)
+     
+    def tagLex(self,nr="1",id=None):
+            """gerateword tags"""
+            
+           
+            df=DonatusFile(txt=self.getPage(_pn=nr,_id=id),baseUri=self.baseUri)
+           
+            return df.convertedXML()
+            #return DonatusFile(txt=self.getPage(_pn=nr)).convertedXML()
+    def refreshTxt(self):
+        """txt fuer refresh"""
+        return """ 2;url=%s?repeat=%s """%(self.absolute_url(),self.threadName)
+
+    def xslt(self):
+        """xslt"""
+
+        return self.document_src()
+
+    def change_displayXMLForm(self):
+        """change form"""
+        pt=zptFile(self, 'zpt/changeDisplayXML.zpt')
+        return pt()
+
+    def addChanges(self,cgiUrl,appendQueryString=False,passURL=False,caching=False,RESPONSE=None):
+        """change the xslt, ueberschriebt addChanges in ECHO_PageTemplate"""
+    
+        if urlparse.urlparse(cgiUrl)[0]=="":#relative url in absolute
+            self.cgiUrl=urlparse.urljoin(self.absolute_url(), cgiUrl)
+        else:
+            self.cgiUrl=cgiUrl
+        
+        if appendQueryString: 
+            self.appendQueryString=True
+        else:
+            self.appendQueryString=False
+        
+        if passURL:
+            self.passURL=True
+        else:
+            self.passURL=False
+       
+        if caching:
+            self.caching="yes"
+        else:
+            self.caching="No"
+        
+
+        if RESPONSE:
+            RESPONSE.redirect("manage_main")
+        
+    def index_html(self,repeat=None):
+        """standard ausgabe"""
+
+        threadName=repeat
+        
+        if not threadName or threadName=="":
+            
+            #abwaertskompatibilitt mit altem nivht konfigurierbaren prototypen
+            
+            if getattr(self,'cgiUrl','')=='':
+                self.cgiUrl="http://medea.mpiwg-berlin.mpg.de/cgi-bin/search/q1"
+                
+            qs="%s%s"%(self.cgiUrl,self.REQUEST['QUERY_STRING'])
+            xsl=self.absolute_url()+"/xslt"
+            self._v_xmltrans=getXML().__of__(self)
+            #self._xmltrans.start()
+            thread=Thread(target=self._v_xmltrans)
+            thread.start()
+            self._v_xmltrans.set(qs,xsl,None)
+            self._v_xmltrans.run()
+            
+            
+            self.threadName=thread.getName()[0:]
+            wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])
+            if wait_template:
+                return wait_template[0][1]()
+            pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','xsltWait.zpt')).__of__(self)
+            return pt()
+            #_v_xmltrans.run()
+        
+        else:
+            
+            if (self._v_xmltrans.getResult()==None):
+
+                wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])
+                if wait_template:
+                        return wait_template[0][1]()
+                
+                pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','xsltWait.zpt')).__of__(self)
+                return pt()
+            else:
+                return self._v_xmltrans.getResult()
+
+    
+    def getText(self):
+        """print nur den text"""
+        qs,baseUri=self.getTextInput()
+        self.REQUEST.RESPONSE.redirect(qs)
+
+    def deleteCache(self):
+        """deletefrom cache"""
+        fn=self.REQUEST['fn']
+        self.cache.deleteObject(fn)
+        
+    
+    def createLinkNode(self,url,dom):
+        """createa a link node"""
+        txt=dom.createTextNode("<XMLLink>")
+        node=dom.createElementNS("http://test.de","a")
+        node.setAttributeNS("http://test.de","href",url)
+        node.appendChild(txt)
+        return node
+      
+    def forwardLink(self,linkid,url,type="target",RESPONSE=None):
+        """forward to link"""
+        if RESPONSE:
+            RESPONSE.redirect(self.getLink(linkid,url,type=type))
+            
+        else:
+            return self.getLink(linkid,url,type=type)
+    def getLink(self,linkid,url,type="target"):
+        """get target for linkid"""
+        dom=NonvalidatingReader.parseUri(url)
+        
+        masterurl=dom.xpath("//mpiwg:masterurl/@ref",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+        slaveurl=dom.xpath("//mpiwg:slaveurl/@ref",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+        
+        #check now if there are in the link file
+     
+        xp="//mpiwg:link[@id='%s']"%linkid
+        
+        if type=="target":
+            for link in dom.xpath(xp,explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'}):
+                fn=link.xpath("mpiwg:target/@filename",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                
+                if urlparse.urlparse(urllib.unquote(fn))[0]=="http": # fn ist eine url
+                    return urllib.unquote(fn)  # dann gibt diese zurueck 
+                
+                ref=link.xpath("mpiwg:target/@refid",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                
+                ref2=link.xpath("mpiwg:target/mpiwg:pagelink/@refid",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                selectionNodeIndex=link.xpath("mpiwg:target/mpiwg:pagelink/@selectionNodeIndex",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                  
+              
+                
+                lstr=slaveurl+'fn='+fn+'&_id='+ref+'&_pagelink=%s///%s/%s/%s'%(ref2,selectionNodeIndex,linkid,'target')
+                lstr+="&_links="+urllib.quote(url)
+                
+        else:
+            for link in dom.xpath(xp,explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'}):
+                fn=link.xpath("mpiwg:source/@filename",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                if urlparse.urlparse(urllib.unquote(fn))[0]=="http": # fn ist eine url
+                    return urllib.unquote(fn)  # dann gibt diese zurueck 
+                
+                ref=link.xpath("mpiwg:source/@refid",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                
+                ref2=link.xpath("mpiwg:source/mpiwg:pagelink/@refid",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                selectionNodeIndex=link.xpath("mpiwg:source/mpiwg:pagelink/@selectionNodeIndex",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                             
+                lstr=masterurl+'fn='+fn+'&_id='+ref+'&_pagelink=%s///%s/%s/%s'%(ref2,selectionNodeIndex,linkid,'source')
+                lstr+="&_links="+urllib.quote(url)
+        return lstr
+   
+    def addLinksUrl(self,txt,url):
+        """add reference to links to  url"""
+        ret=[]
+        dom=NonvalidatingReader.parseUri(url)
+        textDom=NonvalidatingReader.parseString(txt)
+
+        #find ids in txt
+        ids=textDom.xpath("//*[@id]")
+        
+        for textid in ids:
+            xp="//mpiwg:link[mpiwg:source/@refid='%s']"%textid.xpath("@id")[0].value
+            for link in dom.xpath(xp,explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'}):
+                ref2=link.xpath("mpiwg:source/mpiwg:pagelink/@refid",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                selectionNodeIndex=link.xpath("mpiwg:source/mpiwg:pagelink/@selectionNodeIndex",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                linkid=link.xpath("@id")[0].value         
+                ret.append('%s///%s/%s/%s'%(ref2,selectionNodeIndex,linkid,'source'))
+           
+            xp="//mpiwg:link[mpiwg:target/@refid='%s']"%textid.xpath("@id")[0].value
+            for link in dom.xpath(xp,explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'}):
+                ref2=link.xpath("mpiwg:target/mpiwg:pagelink/@refid",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                selectionNodeIndex=link.xpath("mpiwg:target/mpiwg:pagelink/@selectionNodeIndex",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                linkid=link.xpath("@id")[0].value         
+                ret.append('%s///%s/%s/%s'%(ref2,selectionNodeIndex,linkid,'target'))
+           
+           
+        return ret
+          
+    def addLinks(self,txt,url="http://127.0.0.1:8080/HFQP/linkCreator/getCollectionXML?collection=commentary2"):
+        """add links to a page from xml linkfile"""
+        
+        dom=NonvalidatingReader.parseUri(url)
+        textDom=NonvalidatingReader.parseString(txt)
+
+        #find ids in txt
+        ids=textDom.xpath("//*[@id]")
+        masterurl=dom.xpath("//mpiwg:masterurl/@ref",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+        slaveurl=dom.xpath("//mpiwg:slaveurl/@ref",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+        
+        #check now if there are in the link file
+        for textid in ids:
+            xp="//mpiwg:link[mpiwg:source/@refid='%s']"%textid.xpath("@id")[0].value
+            for link in dom.xpath(xp,explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'}):
+                fn=link.xpath("mpiwg:target/@filename",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                print fn
+                if urlparse.urlparse(urllib.unquote(fn))[0]=="http": # fn ist eine url
+                    lstr=urllib.unquote(fn)  # dann gibt diese zurueck 
+                else:
+                    try:
+                        ref=link.xpath("mpiwg:target/@refid",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                    
+                        ref2=link.xpath("mpiwg:target/mpiwg:pagelink/@refid",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                        selectionNodeIndex=link.xpath("mpiwg:target/mpiwg:pagelink/@selectionNodeIndex",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                        linkid=link.xpath("@id")[0].value         
+                        lstr=slaveurl+'fn='+fn+'&_id='+ref+'&_pagelink=%s///%s/%s/%s'%(ref2,selectionNodeIndex,linkid,'target')
+                        lstr+="&_links="+urllib.quote(url)
+                    except:
+                        lstr=""
+                node=self.createLinkNode(lstr,textDom)
+                textid.parentNode.insertBefore(node,textid)
+              
+          
+            xp="//mpiwg:link[mpiwg:target/@refid='%s']"%textid.xpath("@id")[0].value
+            for link in dom.xpath(xp,explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'}):
+                fn=link.xpath("mpiwg:source/@filename",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                if urlparse.urlparse(urllib.unquote(fn))[0]=="http": # fn ist eine url
+                    lstr=urllib.unquote(fn)  # dann gibt diese zurueck 
+                else:
+                
+                    ref=link.xpath("mpiwg:source/@refid",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                    
+                    ref2=link.xpath("mpiwg:source/mpiwg:pagelink/@refid",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                    selectionNodeIndex=link.xpath("mpiwg:source/mpiwg:pagelink/@selectionNodeIndex",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})[0].value
+                    linkid=link.xpath("@id")[0].value                    
+                    lstr=masterurl+'fn='+fn+'&_id='+ref+'&_pagelink=%s///%s/%s/%s'%(ref2,selectionNodeIndex,linkid,"source")
+                    lstr+="&_links="+urllib.quote(url)
+                    
+                node=self.createLinkNode(lstr,textDom)
+                textid.parentNode.insertBefore(node,textid)
+              
+            
+        
+        strio = StringIO()
+        PrettyPrint(textDom,strio) 
+        xmlstr = strio.getvalue()
+        
+        return xmlstr
+
+            
+        
+    def getPageLex(self,_pn="1",_id=None,_caching=None,_links=None,_showall="no",_displaylinks="yes"):
+        """getpage mit lexikalischer analyse und xslt transform
+        if _caching=yes dann wird die lwxikalisch analysierte seite in einem cache abgespeichert
+        """
+        def encode(hash):
+            ret=[]
+            for x in hash.keys():
+                value=hash[x]
+                
+                if type(value) is ListType:
+                    for z in value:
+                        ret.append("%s=%s"%(x,z))
+                else:
+                    ret.append("%s=%s"%(x,value))
+            return "&".join(ret)
+                    
+                        
+            
+        if not _caching:
+            _caching=self.caching
+            
+        fn=self.REQUEST['fn']
+
+        if not _id:
+           
+            fromCache=self.cache.retrieveObject(fn,_pn)
+     
+            if fromCache and _caching=="yes":
+              
+                txt = fromCache
+            else:
+                txt=self.tagLex(nr=_pn)   
+              
+                self.cache.storeObject(fn,_pn,txt[0:])
+            
+        else:
+           txt=self.tagLex(id=_id)
+      
+        if _showall=="yes":
+           params=cgi.parse_qs(self.REQUEST['QUERY_STRING'])
+           
+           params['_pagelink']=self.addLinksUrl(txt,url=_links)
+           params['_showall']='no'
+          
+           print self.absolute_url()+"?"+encode(params)
+           self.REQUEST.RESPONSE.redirect(self.absolute_url()+"/getPageLex?"+encode(params))
+           
+           
+        xsl=self.xslt()
+        
+        xsltproc=Processor()
+        if type(txt)==UnicodeType:
+            document = InputSource.DefaultFactory.fromString(txt.encode('utf-8'))
+        else:
+            document = InputSource.DefaultFactory.fromString(txt)
+        stylesheet = InputSource.DefaultFactory.fromString(xsl)
+        xsltproc.appendStylesheet(stylesheet)
+        tmp=xsltproc.run(document)
+        
+        if _links and (_displaylinks=='yes'):
+            _links=urllib.unquote(_links)
+            tmp=self.addLinks(tmp,url=_links)
+            
+        #bugfix for digilib images which doesn't accept &amp;
+        tmp=tmp.replace("&amp;","&")
+        
+
+        return tmp[0:]
+            
+    def getTextInput(self):
+        """get the text
+        wie der text geholt wird liegt an der konfiguration,
+        is appendQueryString gesetzt, dann wir jeweils der Querystring an vorgebenen url gesetzt, erwartet wird fn=
+        fr den Pfad, is passURL gesetzt, dann wird falls fn= eine vollstndige url enthlt, diese anstelle der in cgiurl definierten genommen.
+        """
+        
+        if getattr(self,'passURL',False) and self.REQUEST.has_key('fn') and (urlparse.urlparse(self.REQUEST['fn'])[0]=='http'):
+            qs=self.REQUEST['fn']
+            baseUri=qs
+        elif getattr(self,'pappendQueryString',True):
+            qs="%s%s"%(self.cgiUrl,self.REQUEST['QUERY_STRING'])
+            baseUri=self.cgiUrl
+        else:
+            qs="%s"%(self.cgiUrl)
+            baseUri=self.cgiUrl
+        
+        #fact= InputSource.DefaultFactory.fromUri(qs)
+        return qs,baseUri
+        #return InputSource.InputSource(fact)
+        #xmlt=urllib.urlopen(qs).read()
+        
+    def getPage(self,_pn="-1",_id=None,REQUEST=None,_caching=None):
+        """get a page from an xml"""
+        
+        if not _caching:
+            _caching=self.caching
+            
+        pn=int(_pn)-1
+        if pn<0 and (not _id):
+            if REQUEST:
+                return "Sorry, pagenumbers have to be greater than 0"
+            else:
+                return None
+       
+        xmlt,self.baseUri=self.getTextInput()
+        
+        #get the text from cache, if existing
+        try:
+            fromCache=self.cache.retrieveObject(self.baseUri,"-1")
+        except:
+            fromCache=None
+        if fromCache and _caching=="yes":
+          
+            txt = fromCache
+        else:
+
+            txt=urllib.urlopen(xmlt).read()
+            
+            self.cache.storeObject(self.baseUri,"-1",txt)
+        
+   
+        dom=NonvalidatingReader.parseString(txt,self.baseUri)
+        
+        #pb should have a namespache
+
+        pbs=dom.xpath("//mpiwg:pb",explicitNss={'mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})
+        
+        if len(pbs)==0: # versuche nochmal ohne
+            pbs=dom.xpath("//pb")
+
+        if _id:
+            #suche wieviele pb for der id
+            
+            
+            idpb=dom.xpath("//*[@id='%s']/preceding::node()/mpiwg:pb"%_id,explicitNss={'html':'http://www.w3.org/1999/xhtml','mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'})
+            if len(idpb)==0:
+                idpb=dom.xpath("//*[@id='%s']/preceding::node()/pb"%_id)
+         
+            if len(idpb)==0:
+                        k=0
+                        for node in dom.xpath("//*[@id='%s']//preceding::node()"%_id,explicitNss={'html':'http://www.w3.org/1999/xhtml','mpiwg':'http://www.mpiwg-berlin.mpg.de/namespace'}):
+                            if getattr(node,'tagName',"")=="mpiwg:pb":
+                                k+=1
+            else:
+                k=len(idpb)
+            #pn=k-1 #-1 wegen Seitenzahlzaehlung startet mit 0
+            pn=k-1 #-1 wegen Seitenzahlzaehlung startet mit 0
+        if pn > len(pbs):
+            if REQUEST:
+                return "Sorry, pagenumber %s does not exit"%(pn+1)
+            else:
+                return None
+            
+        beginNode=pbs[pn] #take the n'th pb
+
+        if not (pn==len(pbs)-1): # nicht die letzte Seite
+            endNode=pbs[pn+1]
+        else:
+            endNode=None
+        
+        deleteNodes=beginNode.xpath('preceding::node()')
+        if endNode:
+            deleteNodes+=endNode.xpath('following::node()')
+        for node in deleteNodes:
+            try:
+                parent=node.xpath("..")
+           
+                if parent:
+                    parent[0].removeChild(node)
+            except:
+                zLOG.LOG("ECHO_Resource (getAccessRightMD)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2])
+        strio = StringIO()
+        PrettyPrint(dom,strio) 
+        xmlstr = strio.getvalue()
+        
+        return xmlstr
+
+
+        
+def manage_addDisplayXMLForm(self):
+    """Form for adding"""
+    pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','AddDisplayXML.zpt')).__of__(self)
+    return pt()
+
+from urllib import quote
+
+
+def manage_addDisplayXML(self, id,title=None,contentType=0, text=None, cgiUrl=None,
+                           REQUEST=None, submit=None):
+    "Add a Page Template with optional file content."
+
+    
+    id = str(id)
+    if REQUEST is None:
+        self._setObject(id, displayXML(id, text))
+        ob = getattr(self, id)
+        setattr(ob,'contentType',contentType)
+        if title:
+           ob.pt_setTitle(title)
+       
+        setattr(ob,'cgiUrl',cgiUrl)
+        return ob
+    else:
+        file = REQUEST.form.get('file')
+        headers = getattr(file, 'headers', None)
+        if headers is None or not file.filename:
+            zpt = displayXML(id)
+        else:
+            zpt = displayXML(id, file, headers.get('contentType'))
+
+        self._setObject(id, zpt)
+        ob = getattr(self, id)
+      
+        setattr(ob,'cgiUrl',cgiUrl)
+        if title:
+            ob.pt_setTitle(title)
+        
+        try:
+            u = self.DestinationURL()
+        except AttributeError:
+            u = REQUEST['URL1']
+
+        if submit == " Add and Edit ":
+            u = "%s/%s" % (u, quote(id))
+        REQUEST.RESPONSE.redirect(u+'/manage_main')
+    return ''
Index: /trunk/zpt/AddDisplayXML.zpt
===================================================================
--- /trunk/zpt/AddDisplayXML.zpt	(revision 3)
+++ /trunk/zpt/AddDisplayXML.zpt	(revision 3)
@@ -0,0 +1,89 @@
+<h1 tal:replace="structure here/manage_page_header">Header</h1>
+<form action="manage_addECHO_xslt" method="post" enctype="multipart/form-data">
+<table cellspacing="0" cellpadding="2" border="0">
+  <tr>
+    <td align="left" valign="top">
+    <div class="form-label">
+    Id
+    </div>
+    </td>
+    <td align="left" valign="top">
+    <input type="text" name="id" size="40" />
+    </td>
+  </tr>
+  <tr>
+    <td align="left" valign="top">
+    <div class="form-label">
+    Title
+    </div>
+    </td>
+    <td align="left" valign="top">
+    <input type="text" name="title" size="40" />
+    </td>
+  </tr>
+  <tr>
+    <td align="left" valign="top">
+    <div class="form-label">
+    Label
+    </div>
+    </td>
+    <td align="left" valign="top">
+    <input type="text" name="label" size="40" />
+    </td>
+  </tr>
+   <tr>
+    <td align="left" valign="top">
+    <div class="form-label">
+    Url of the XML-source:
+    </div>
+    </td>
+    <td align="left" valign="top">
+    <input type="text" name="cgiUrl" size="40" />
+    </td>
+  </tr>
+  
+  <tr>
+    <td align="left" valign="top">
+    <div class="form-label">
+    Weight
+    </div>
+    </td>
+    <td align="left" valign="top">
+    <input type="text" name="weight" size="40" />
+    </td>
+  </tr>
+  <tr>
+    <td align="left" valign="top">
+    <div class="form-label">
+    Content Type
+    </div>
+    </td>
+    <td align="left" valign="top">
+    <input type="text" name="contentType" size="40" />
+    </td>
+  </tr>
+  <tr>
+    <td align="left" valign="top">
+    <div class="form-optional">
+    File
+    </div>
+    </td>
+    <td align="left" valign="top">
+    <input type="file" name="file" size="25" value="" />
+    </td>
+  </tr>
+  <tr>
+    <td align="left" valign="top">
+    </td>
+    <td align="left" valign="top">
+    <div class="form-element">
+    <input class="form-element" type="submit" name="submit" 
+     value=" Add " /> 
+    <input class="form-element" type="submit" name="submit" 
+     value=" Add and Edit " />
+    </div>
+    </td>
+  </tr>
+</table>
+</form>
+<h1 tal:replace="structure here/manage_page_footer">Footer</h1>
Index: /trunk/zpt/changeDisplayXML.zpt
===================================================================
--- /trunk/zpt/changeDisplayXML.zpt	(revision 3)
+++ /trunk/zpt/changeDisplayXML.zpt	(revision 3)
@@ -0,0 +1,28 @@
+<h1 tal:replace="structure here/manage_page_header">Header</h1>
+<h2>Change ECHO XSL</h2>
+<form action="addChanges" method="post">
+<table>
+<tr>
+<td class="form-label">uri of the xml file: </td>
+<td><input size="100" name="cgiUrl" tal:attributes="value python:getattr(here,'cgiUrl','')"></td>
+</tr>
+<tr>
+<td class="form-label">Append query string to the uri above </td>
+<td tal:condition="python:getattr(here,'appendQueryString',True)"><input type="checkbox" value="yes"  name="appendQueryString" checked></td>
+<td tal:condition="not:python:getattr(here,'appendQueryString',True)"><input type="checkbox" value="no" name="appendQueryString"></td>
+</tr>
+<tr>
+<td class="form-label">If parameter "fn" is passed and contains an url then this url is used instead of above </td>
+<td tal:condition="python:getattr(here,'passURL',False)"><input type="checkbox" name="passURL" value="yes" checked></td>
+<td tal:condition="not:python:getattr(here,'passURL',False)"><input type="checkbox" value="no" name="passURL"></td>
+</tr>
+<tr>
+<td class="form-label">Caching: </td>
+<td tal:condition="python:getattr(here,'caching','yes')=='yes'"><input type="checkbox" name="caching" value="yes" checked></td>
+<td tal:condition="not:python:getattr(here,'caching','yes')=='yes'"><input type="checkbox" value="no" name="caching"></td>
+</tr>
+<br>
+
+<input type="submit" value="change">
+</form>
+<h1 tal:replace="structure here/manage_page_footer">Footer</h1>
