Mercurial > hg > documentViewer
comparison MpdlXmlTextServer.py @ 395:e6f3fcb2058f
*** empty log message ***
author | abukhman |
---|---|
date | Mon, 08 Nov 2010 16:04:06 +0100 |
parents | bb317af1c197 |
children | 55f9eeebc338 |
comparison
equal
deleted
inserted
replaced
394:ce9fa69f81c3 | 395:e6f3fcb2058f |
---|---|
136 dom = Parse(text) | 136 dom = Parse(text) |
137 result= dom.xpath("//result/resultPage") | 137 result= dom.xpath("//result/resultPage") |
138 | 138 |
139 docinfo['numPages']=int(getTextFromNode(result[0])) | 139 docinfo['numPages']=int(getTextFromNode(result[0])) |
140 return docinfo | 140 return docinfo |
141 | 141 |
142 #def getQueryResultHits(self, docinfo=None, pageinfo=None): | |
143 | |
144 | |
145 def getGisPlaces(self, docinfo=None, pageinfo=None): | 142 def getGisPlaces(self, docinfo=None, pageinfo=None): |
146 """ Show all Gis Places of whole Page""" | 143 """ Show all Gis Places of whole Page""" |
147 xpath='//place' | 144 xpath='//place' |
148 docpath = docinfo['textURLPath'] | 145 docpath = docinfo['textURLPath'] |
149 url = docinfo['url'] | 146 url = docinfo['url'] |
172 hrefList=[] | 169 hrefList=[] |
173 myList="" | 170 myList="" |
174 text=self.getServerData("xpath.xql", "document=%s&xpath=%s"%(docinfo['textURLPath'],xpath)) | 171 text=self.getServerData("xpath.xql", "document=%s&xpath=%s"%(docinfo['textURLPath'],xpath)) |
175 dom =Parse(text) | 172 dom =Parse(text) |
176 result = dom.xpath("//result/resultPage/place") | 173 result = dom.xpath("//result/resultPage/place") |
174 | |
177 for l in result: | 175 for l in result: |
178 hrefNode = l.getAttributeNodeNS(None, u"id") | 176 hrefNode = l.getAttributeNodeNS(None, u"id") |
179 href= hrefNode.nodeValue | 177 href= hrefNode.nodeValue |
180 hrefList.append(href) | 178 hrefList.append(href) |
181 myList = ",".join(hrefList) | 179 myList = ",".join(hrefList) |
354 logging.debug("documentViewer (gettoc) tocSearch: %s"%(tocSearch)) | 352 logging.debug("documentViewer (gettoc) tocSearch: %s"%(tocSearch)) |
355 tc=int((tocSearch/10)+1) | 353 tc=int((tocSearch/10)+1) |
356 logging.debug("documentViewer (gettoc) tc: %s"%(tc)) | 354 logging.debug("documentViewer (gettoc) tc: %s"%(tc)) |
357 return tc | 355 return tc |
358 | 356 |
357 def getQueryResultHits(self, docinfo=None, pageinfo=None, query=None, queryType=None, pn=1, optionsClose=None): | |
358 | |
359 """number of hits in Search mode""" | |
360 docpath = docinfo['textURLPath'] | |
361 pagesize = pageinfo['queryPageSize'] | |
362 pn = pageinfo['searchPN'] | |
363 query =pageinfo['query'] | |
364 queryType =pageinfo['queryType'] | |
365 tocSearch = 0 | |
366 tocDiv = None | |
367 | |
368 pagexml = self.getServerData("doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s"%(docpath, 'text', queryType, urllib.quote(query), pagesize, pn)) | |
369 #pagexml=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s"%(docpath, 'text', queryType, query, pagesize, pn) ,outputUnicode=False) | |
370 pagedom = Parse(pagexml) | |
371 numdivs = pagedom.xpath("//div[@class='queryResultHits']") | |
372 tocSearch = int(getTextFromNode(numdivs[0])) | |
373 return tocSearch | |
374 | |
375 def getQueryResultHitsText(self, docinfo=None, pageinfo=None): | |
376 """number of hits in Text of Contents mode""" | |
377 | |
378 docpath = docinfo['textURLPath'] | |
379 pagesize = pageinfo['queryPageSize'] | |
380 pn = pageinfo['searchPN'] | |
381 query =pageinfo['query'] | |
382 queryType =pageinfo['queryType'] | |
383 tocSearch = 0 | |
384 tocDiv = None | |
385 tocMode = pageinfo['tocMode'] | |
386 tocPN = pageinfo['tocPN'] | |
387 pagexml=self.getServerData("doc-query.xql", "document=%s&queryType=%s"%(docpath,'toc')) | |
388 pagedom = Parse(pagexml) | |
389 logging.debug("documentViewer (pagedom) pagedom: %s"%(pagedom)) | |
390 numdivs = pagedom.xpath("//div[@class='queryResultHits']") | |
391 tocSearch = int(getTextFromNode(numdivs[0])) | |
392 return tocSearch | |
393 | |
394 def getQueryResultHitsFigures(self, docinfo=None, pageinfo=None): | |
395 """number of hits in Text of Figures mode""" | |
396 | |
397 docpath = docinfo['textURLPath'] | |
398 pagesize = pageinfo['queryPageSize'] | |
399 pn = pageinfo['searchPN'] | |
400 query =pageinfo['query'] | |
401 queryType =pageinfo['queryType'] | |
402 tocSearch = 0 | |
403 tocDiv = None | |
404 tocMode = pageinfo['tocMode'] | |
405 tocPN = pageinfo['tocPN'] | |
406 pagexml=self.getServerData("doc-query.xql", "document=%s&queryType=%s"%(docpath,'figures')) | |
407 pagedom = Parse(pagexml) | |
408 logging.debug("documentViewer (pagedom) pagedom: %s"%(pagedom)) | |
409 numdivs = pagedom.xpath("//div[@class='queryResultHits']") | |
410 tocSearch = int(getTextFromNode(numdivs[0])) | |
411 return tocSearch | |
412 | |
413 | |
359 def getToc(self, mode="text", docinfo=None): | 414 def getToc(self, mode="text", docinfo=None): |
360 """loads table of contents and stores in docinfo""" | 415 """loads table of contents and stores in docinfo""" |
361 logging.debug("documentViewer (gettoc) mode: %s"%(mode)) | 416 logging.debug("documentViewer (gettoc) mode: %s"%(mode)) |
362 if mode == "none": | 417 if mode == "none": |
363 return docinfo | 418 return docinfo |