= xmlvw by TOYODA Eizi * Author: TOYODA Eizi * Date: 2013-05-07 == What is this xmlvw is a tiny CGI to apply XSLT stylesheet to any XML online. The name `xmlvw' comes from XML viewer, but it can be used with any XSLT that generates meaningful output to web browser. == How it works When the CGI is called without any parameter (no PATH_INFO nor QUERY_STRING), it generates an HTTP form that prompt the user to specify XSLT and XML. XSLT can be chosen from a pull-down list of *.xsl files installed at predefined directory (/usr/local/share/xmlvw). XML can be specified either by URL or by file upload. Then the next request to the CGI should be like http://toyoda-eizi.net/xmlvw?xsl=gmd_txt&url=http://... or its POST equivalent. Alternative way to use the CGI is calling it with PATH_INFO. In that case the first path segment becomes the basename of XSLT, and the rest (must begin with http://) becomes the URL. For example http://toyoda-eizi.net/gmd_txt/http://example.com/path can be used to apply gmd_txt.xsl to the XML located at http://example.com/path. Anyway at the final stage the CGI reads specified input (or uses uploaded file), parses by libxml2, inserts XML processing instruction and echoes it back as response. The `xml-stylesheet' processing instruction contains URL to the XSLT (http://toyoda-eizi.net/gmd_txt/ for above case) and is interpreted by the web browser. == Porting tips This kind of work, applying an XSLT, can also be done by JavaScript, but it is worth noting that most web browser has limitation on applying XSLT coming from different host for security reasons. When called from localhost, the script rewrites URL of itself. You have to edit URLFIX constant to preferred hostname of your server. The script is intended to be run behind some load-balancer or cache proxy. If that is not the case, you can simply rewrite the definition by "URLFIX = nil" to disable the function.