--- MPIWGWeb/xmlhelper.py 2004/02/04 10:03:33 1.1.1.1 +++ MPIWGWeb/xmlhelper.py 2004/09/02 15:33:42 1.5 @@ -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':('','')} +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,15 +72,25 @@ 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 def parseSection(section): - heading=section.getElementsByTagName('heading')[0] - type=heading.getAttribute('class') - header=getText(heading.childNodes) + type="" + header="" + 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] + type=par.getAttribute('class') + header=getText(par.childNodes) + #print section.childNodes pars=Evaluate('par',section) content=par2html(pars) @@ -165,19 +177,16 @@ def getText(nodelist): rc = u'' for node in nodelist: - print "HHHH" if node.nodeType == node.TEXT_NODE: #print "node",node #print "NODE",node.data.encode('utf-8','ignore'),"V" #print "HALII" try: try: - print "try1" #rc += node.data.encode('utf-8','ignore') rc += node.data except: - print "try2" #rc= node.data.encode('utf-8','ignore') rc=node.data except: @@ -187,10 +196,9 @@ def getText(nodelist): node.data.encode('utf-8','ignore') #print "RC",rc elif node.tagName =="inline": - print "HI", node.getAttribute('class') rc+=par2html([node]) elif node.attributes: - print "xlink?" + if 'xlink:type' in node.attributes.keys(): #is a xlink? rc +=xlink2html(node) #print "RWT",rc