#!/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/converting/classes.xml"))

print '<html><body><h1>Platforms supported by Classes</h1><table><tr><th>'

platforms = ['gtk','win32','motif','nanox','mgl','macos','os2']

for platform in platforms:
  print '<th>' + platform

for myclass in root.nodes ('/classes/class'):
  mydict = {}
  for platform in myclass.nodes ('supported/platform'):
    mydict[platform.value('@name')] = platform.value('@status')

  print '<tr><td>' + myclass.value('@name')
  for platform in platforms:
    print '<td>' 
    if mydict.has_key(platform):
      print mydict[platform]

print '</table></body></html>'
