--- MPIWGWeb/xmlhelper.py 2004/08/11 13:02:04 1.3 +++ MPIWGWeb/xmlhelper.py 2005/10/10 08:42:49 1.6.2.1 @@ -15,7 +15,7 @@ from Ft.Xml.XLink import XLinkElements #from Ft.Xml import EMPTY_NAMESPACE from Ft.Lib import Uri -xml2html={'WEB_normal':('

','

'),'Normal':('

','

'),'WEB_picture':('

','

'),'WEB_figuretitle':('',''),'WEB_bibliography':('

','

'),'Web_kursiv':('',''),'WEB_kursiv':('',''),'WEB_hyperlink':('',''),'Hyperlink':('','')} +xml2html={'WEB_normal':('

','

'),'Normal':('

','

'),'WEB_picture':('

','

'),'WEB_figuretitle':('

','

'),'WEB_bibliography':('

','

'),'Web_kursiv':('',''),'WEB_kursiv':('',''),'WEB_hyperlink':('',''),'Hyperlink':('','')} def addToDict(dict,name,value): if name=="": @@ -50,18 +50,20 @@ def proj2hash(xmlstring): sections=Evaluate('section',dom.getElementsByTagName('part')[0])# Parse all Sections #print sections,dom.getElementsByTagName('part')[0] for section in sections: - + sec=parseSection(section) if sec[0]=="WEB_project_header": # Sonderfall project + addToDict(list,'WEB_project_header',sec[1]) # store title addToDict(list,'WEB_project_description',sec[2]) #store description else: # no information in heading + addToDict(list,sec[0],sec[2]) #evaluate higher level sections sections=Evaluate('section/section',dom.getElementsByTagName('part')[0]) - + for section in sections: sec=parseSection(section) @@ -70,7 +72,7 @@ def proj2hash(xmlstring): addToDict(list,'WEB_project_description',sec[2]) #store description else: # no information in heading addToDict(list,sec[0],sec[2]) - + return list @@ -78,9 +80,11 @@ def proj2hash(xmlstring): def parseSection(section): type="" header="" - for heading in section.getElementsByTagName('heading'): - type=heading.getAttribute('class') - header=getText(heading.childNodes) + for heading in section.childNodes: + if getattr(heading,'tagName','')=="heading": + + type=heading.getAttribute('class') + header=getText(heading.childNodes) if type=="": # falls heading fehlt, pruefe ob erster par richtig par=section.getElementsByTagName('par')[0] @@ -173,7 +177,7 @@ def getText(nodelist): rc = u'' for node in nodelist: - if node.nodeType == node.TEXT_NODE: + if node.nodeType == node.TEXT_NODE: #print "node",node #print "NODE",node.data.encode('utf-8','ignore'),"V" #print "HALII"