#!/usr/bin/python2.3

import libxml2

# we need: export PYTHONPATH="/usr/lib/python2.3:/home/wxwindows/lib/python/:/home/wxwindows/pythonlibs/lib/python2.3/site-packages/:/home/wxwindows/pythonlibs/usr/lib/python2.3/site-packages/"

class XPathElem:
  def __init__(self, node):
    self.node = node
  def value(self, path): return self.node.xpathEval('string(' + path + ')')
  def nodes(self, path): return [ XPathElem(x) for x in self.node.xpathEval(path) ]
  def test(self, path): return self.node.xpathEval('boolean(' + path + ')')

root = XPathElem(libxml2.parseFile("/home/wxwindows/public_html/xmldocs/classes.xml"))

print '<html><body>';
#print '<h1>Events list</h1>'
print "<table border=0>";
for myclass in root.nodes ('/classes/class'):
  events = myclass.nodes ('events/event')
  if len(events) > 0:
    #print "<h2>" + myclass.value('@name') + "</h2>";
    print "<tr><td>&nbsp";
    print "<tr><td colspan=2>" + myclass.value('@name') 
    #print "<table border=0 width=100% cellspacing=0>";
    #print "<tr><td><table border=0 width=100% cellspacing=0>";
    #print '<tr><td width=500 colspan=2 bgcolor=grey>' + myclass.value('@name')
    for event in events:
      print '<tr><td>' + event.value('@name')
      if not (event.value('@name') == ("EVT_" + event.value(''))):
        print '<td>' + event.value('')
    #print "</table>";

print "</table>";

print '</body></html>'

