--- MPIWGWeb/xmlhelper.py 2004/06/28 18:47:14 1.2 +++ MPIWGWeb/xmlhelper.py 2004/09/01 09:35:12 1.4 @@ -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: @@ -189,7 +198,7 @@ def getText(nodelist): elif node.tagName =="inline": rc+=par2html([node]) elif node.attributes: - print "xlink?" + if 'xlink:type' in node.attributes.keys(): #is a xlink? rc +=xlink2html(node) #print "RWT",rc