XSLTForms/Generic HTTP Server

This page describes installing XSLTForms in a generic Web server, e.g. Apache. If you are using XSLTForms with MarkLogic or with eXistDB, see the product-specific documentation.

Installing XSLTForms proper edit

Prospective users of XSLTForms are sometimes frustrated because they cannot find anything that look like proper installation instructions. (This page is an attempt to correct that situation, for those who find it.) Part of the problem is that some users find it hard to believe that installation of an XForms implementation can be as simple as it is.

Downloading XSLTForms edit

First, you must download a copy of XSLTForms. The easiest thing to do is probably to go to the Sourceforge Project Home Page for XSLTForms and look for a download button; clicking on that button will cause your browser to download a ZIP file containing the most recent release package for the software.

When this page was last revised (February 2017), the most recent package was 1.0RC2 (1.0 release candidate 2).

Note: earlier releases are still available, including

Unless you have a special need for an older version rather than the current version, however, you should take the latest available package.

Snapshot versions may be found by clicking on the Code tab or the SVN tag in the SourceForge project area. (When this page was last revised in February 2017, the most recent snapshot was r639, dated 20 Jan 2017.) Because the snapshot versions may include important enhancements or bug fixes, many users of XSLTForms use the snapshot versions for production work, rather than the most recent 'stable' version.)

Next, you must unzip the ZIP file and get it onto your HTTP server. Remember the location where you put it. (If you do not know how to get files onto your Web server, you will need to consult other sources to learn how to do that, before continuing here.)

Making your forms use XSLTForms edit

Finally, you must add an XML stylesheet instruction to your XForms, which points to the xsltforms.xsl stylesheet in the package you just installed. So if your site is named forms.example.com and you installed XSLTForms in /lib/xsltforms-1.0RC/ and the xsltforms.xsl file is in that directory (do check, sometimes the release packages are wrapped in an extra layer and you'll find the stylesheet one directory level further down), you'll add a line like this (you may replace the newlines with a single blank; they are here to keep the lines short in the code block):

<?xml-stylesheet 
   href="http://forms.example.com/lib/xsltforms-1.0RC/xsltforms.xsl" 
   type="text/xsl"?>

to the XHTML+XForms documents you want to deliver with XSLTForms. In practice, you may prefer to use a relative URI rather than an absolute URI (so the stylesheet instruction will read ... href="../../../lib/xsltforms-1.0RC/xsltforms.xsl" ...); that makes it easier to test forms on a test machine before putting them on a production server.

Serving your forms with an appropriate MIME type edit

A common source of problems at initial setup time is serving forms with an inappropriate MIME type.

  • Forms served from an HTTP server should have a MIME type of application/xml, text/xml, or application/xhtml. Forms served as text/html won't work: browsers don't apply XSLT stylesheets to HTML documents.
  • Forms loaded from a local file system will or won't work, depending on what MIME type the browser associates with the file extension. If .html doesn't work, try .xhtml or .xml.

Accepting PUT and POST edit

Arranging for your server to accept PUT or POST requests from an XForm is an entirely separate matter. In principle, setting the server up to handle such requests is completely independent of your XForms implementation (though in practice some server-side XForms implementations include server-side support for PUT and POST in the package).

This is not the place to go into details, but in general the options available include:

  • installation of a WebDAV server (or more commonly configuration of some other server software to support WebDAV requests); possibilities include
    • WebDAV support in Apache
    • WebDAV / Delta V support in Subversion
    • Apache support for WebDAV using Subversion as the file store
    • the WebDAV interface in an XQuery database like eXist or BaseX
    • WebDAV servers in MarkLogic
  • configuration of a generic HTTP server to accept PUT or POST

Because they involve accepting and processing data from potentially unknown (and thus potentially untrustworthy and hostile) clients, PUT and POST unavoidably represent a security risk for your system. In consequence, most Webmasters and system administrators will have firm views on the right way to set things up to manage the risk properly. Users of XForms will need to work with the Webmaster to ensure that things are set up in a way that will let you get your work done and won't expose your site to unavoidable security problems.

XForms can be used as a convenient way to provide more sophisticated user interfaces for Web pages even without submitting data to a server, so for some purposes you may not need to set your server up for PUT and POST.

And for XForms applications you just want to run on your own machine, the support for file:// URIs in current versions of XSLTForms may make it unnecessary to configure a WebDAV server. (Need description of the Java applet elsewhere in the WikiBook, and need link to that description from here.)