#!/usr/bin/env python # -*- mode: python -*- """ This is a simple-minded XSL processor CGI """ # $Header: /cvsroot/dbagg3/htdocs/xsltproc,v 1.1 2004/08/13 01:57:05 deusx Exp $ import os,sys import cgiconfig, cgi import cgitb; cgitb.enable() import libxml2, libxslt form = cgi.FieldStorage() xsl_url = form.getvalue('xsl','') xml_url = form.getvalue('xml','') if not xsl_url.startswith('http://') or not xml_url.startswith('http://'): print "Content-Type: text/html\n\n"; print """ xsltproc
xsl:
xml:
""" else: styledoc = libxml2.parseEntity(xsl_url) doc = libxml2.parseEntity(xml_url) style = libxslt.parseStylesheetDoc(styledoc) result = style.applyStylesheet(doc, None) out = style.saveResultToString(result) style.freeStylesheet() doc.freeDoc() result.freeDoc() print "Content-Type: text/html\n\n"; print out