Changeset 455:0a53fea83df7 in documentViewer for documentViewer_old.py
- Timestamp:
- Jul 15, 2011, 7:34:41 PM (13 years ago)
- Branch:
- elementtree
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentViewer_old.py
r453 r455 10 10 from Ft.Xml import EMPTY_NAMESPACE, Parse 11 11 import Ft.Xml.Domlette 12 13 import xml.etree.ElementTree as ET14 15 12 import os.path 16 13 import sys … … 36 33 return int(default) 37 34 38 def getTextFromNode(node ):35 def getTextFromNode(nodename): 39 36 """get the cdata content of a node""" 40 if node is None:37 if nodename is None: 41 38 return "" 42 # ET: 43 text = node.text or "" 44 for e in node: 45 text += gettext(e) 46 if e.tail: 47 text += e.tail 48 49 # 4Suite: 50 #nodelist=node.childNodes 51 #text = "" 52 #for n in nodelist: 53 # if n.nodeType == node.TEXT_NODE: 54 # text = text + n.data 55 56 return text 39 nodelist=nodename.childNodes 40 rc = "" 41 for node in nodelist: 42 if node.nodeType == node.TEXT_NODE: 43 rc = rc + node.data 44 return rc 57 45 58 46 def serializeNode(node, encoding="utf-8"): 59 47 """returns a string containing node as XML""" 60 s = ET.tostring(node) 61 62 # 4Suite: 63 # stream = cStringIO.StringIO() 64 # Ft.Xml.Domlette.Print(node, stream=stream, encoding=encoding) 65 # s = stream.getvalue() 66 # stream.close() 48 stream = cStringIO.StringIO() 49 #logging.debug("BUF: %s"%(stream)) 50 Ft.Xml.Domlette.Print(node, stream=stream, encoding=encoding) 51 s = stream.getvalue() 52 #logging.debug("BUF: %s"%(s)) 53 stream.close() 67 54 return s 68 55 … … 510 497 raise IOError("Unable to get dir-info from %s"%(infoUrl)) 511 498 512 dom = ET.fromstring(txt).getroot() 513 #dom = Parse(txt) 514 sizes=dom.find("//dir/size") 515 #sizes=dom.xpath("//dir/size") 499 dom = Parse(txt) 500 sizes=dom.xpath("//dir/size") 516 501 logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes) 517 502 … … 562 547 raise IOError("Unable to read index meta from %s"%(url)) 563 548 564 dom = ET.fromstring(txt).getroot() 565 #dom = Parse(txt) 549 dom = Parse(txt) 566 550 return dom 567 551 … … 582 566 raise IOError("Unable to read infoXMLfrom %s"%(url)) 583 567 584 dom = ET.fromstring(txt).getroot() 585 #dom = Parse(txt) 568 dom = Parse(txt) 586 569 return dom 587 570 … … 601 584 dom = self.getDomFromIndexMeta(path) 602 585 603 acctype = dom.find("//access-conditions/access/@type") 604 #acctype = dom.xpath("//access-conditions/access/@type") 586 acctype = dom.xpath("//access-conditions/access/@type") 605 587 if acctype and (len(acctype)>0): 606 588 access=acctype[0].value … … 628 610 logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path)) 629 611 # put in all raw bib fields as dict "bib" 630 bib = dom.find("//bib/*") 631 #bib = dom.xpath("//bib/*") 612 bib = dom.xpath("//bib/*") 632 613 if bib and len(bib)>0: 633 614 bibinfo = {} … … 638 619 # extract some fields (author, title, year) according to their mapping 639 620 metaData=self.metadata.main.meta.bib 640 bibtype=dom.find("//bib/@type") 641 #bibtype=dom.xpath("//bib/@type") 621 bibtype=dom.xpath("//bib/@type") 642 622 if bibtype and (len(bibtype)>0): 643 623 bibtype=bibtype[0].value
Note: See TracChangeset
for help on using the changeset viewer.