From EXPath

Revision as of 23:17, 25 April 2012 by FGeorges (Talk | contribs)
Jump to: navigation, search

The webapp module provides a way to write web applications directly in XSLT, XQuery and/or XProc. The homepage of the module is: http://expath.org/modules/webapp/. This module is defined by first looking at the existing and playing with a toy implementation, before writing down a spec. This page gather several observations as well as drafts. There are also specific info for the implementation for Saxon and Calabash, using Java Servlets, aka Servlex.

Some notes can also be found in Florent Georges's wiki.


Servlet definition

A servlet is a component that takes a request and a context as input, and provides a response as output. The request is represented by an element web:request and a sequence of zero or more request bodies. The context is represented by an element web:application and an element web:servlet. The response is represented by an element web:response and a sequence of zero or more response bodies.

A servlet can be implemented using one of various technologies. Each kind of servlet has its own rules for receiving requests and providing responses. The available servlet kinds are:

  • an XPath function (provided by an XQuery library module, a stylesheet, or any other implementation-specific means);
  • an XSLT named template;
  • an XSLT stylesheet;
  • an XQuery main module;
  • an XProc pipeline;
  • an XProc step.



See the various points at the end of this wiki page, related to the session management, a function library and the setup a deployment.

Filters and error handlers

For filters, probably use something based on the following (for transformers, just define an out filter without in part), that is, define a filter as a pair of components:

<filter name="one"? group="general"?>
      [ xslt | xquery | xproc ]
      [ xslt | xquery | xproc ]
   <url pattern="/pages/*"/>?

For error handlers, map error codes (aka QNames) to components in the same way.

Challenges: how to order them? For instance, do we have to apply a filter to the output of an error handler (in some cases we want, like a website layout, in other cases we don't, in some case we want error handler to catch errors in filters...) → order them as they are declared in the file.

Groups: define groups of servlets / filters / error handlers. The semantics is that the filters and error handlers apply to the servlets of the group. Define a group like a substitution group in XSD or a mode in XSLT: by using a QName and an attribute (and maybe a group element for meta infos, like xsl:mode in XSLT 3.0).

Maybe use the name chain instead of group, as this implies more the idea of order between items. A chain can be defined by the filters and error handlers with a @chain with the same name, or by using the element chain:

<chain name="my-chain">
   <filter ...>
   <error .../>
   <chain name="other-chain"/>
   <filter .../>

A chain can be in a chain itself.

Personal tools