#!/usr/local/Python-2.4/bin/python
#!/usr/bin/env python
"""
CGI interface to xsltproc
Share and Enjoy.
"""
import cgi, sys, os, urllib
from urlparse import urlparse, urlunparse
XSLTPROC='/usr/bin/xsltproc'
Page = """
xsltproc service
Process your XSLT
"""
Page2 = """
"""
def serveRequest():
fields = cgi.FieldStorage()
if not fields.has_key('docAddr'):
print "Content-Type: text/html"
print
print Page
print Page2 % ("", "")
else:
docAddr = urlunparse(urlparse(fields['docAddr'].value))
xslAddr = urlunparse(urlparse(fields['xslAddr'].value))
print "Content-Type: text/xml"
print ""
print ""
sys.stdout.flush()
os.system(" ".join((XSLTPROC, xslAddr, docAddr)))
if __name__ == '__main__':
if os.environ.has_key('SCRIPT_NAME'):
serveRequest()