INRIA
[Up]
Warning

Work in progress

This version may be updated without notice.

Web Specification

A Web module for Active Tags

Working Draft 19 december 2006

Abstract

This specification describes a new Web optional module for Active Tags. This Web module provides tags, attributes, functions and predefined properties related to Web applications.

Requirement levels

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Note that for reasons of style, these words are not capitalized in this document.

Active Tags specifications

The following specifications are part of the Active Tags technologies.

Table of contents

1 The Web module
2 Web concepts
3 Use cases
4 Web module reference

4.1 Elements
4.2 Foreign attributes
4.3 Predefined properties
4.4 Extended XPath functions
4.5 Data types

Appendix

A Glossary
B Related Active Tags specifications
C Lists

C.1 Examples list
C.2 Figures list
D Active Schema for the Web module


1 The Web module

This Active Tags module has been designed to provide basic Web support. It provides a high-level abstraction of a Web application. A Web application runs inside a Web engine that embeds an Active Tags engine. How the engines are cooperating is out of the scope of this specification.


2 Web concepts

Most Web concepts are represented in Active Tags thanks to properties stored in the data set.

Application

The Web application is the top level entry to a set of services related to the application. A Web application is mapped either at the server root, or just under the server root :

According to the underlying Web engine used, the Web application may endorse a set of informations accessible with Active Tags with the $web:application property ; additionally, parameters used to initialize the Web application are also accessible.

The $web:application property can be referred in any Active Tags service.

Service

A service defines mappings to handle HTTP requests with the <web:mapping> element. Each service of an application is represented by an active sheet. How each service (active sheet) is bound to the Web application is implementation dependant.

The Web engine may also provide a set of initialization parameters with the $web:service property, which is accessible in the entire active sheet.

A service can define an initialization phase thanks to the <web:init> element.

HTTP handling

When a service is invoked, the mapping (<web:mapping>) that matches the request's URL is called with the following properties :

The web URI scheme

A Web application is often deployed to a target location not necessary known by developers ; the resources that depend on the location of a web application must be accessed in a neutral way (without the knowledge of the real path where the application is located). To do so, an implementation of this module must rely on a file system manager that accept the web URI scheme.

The web URI scheme is like the file URI scheme, except that the root file depends on the location where the Web application is effectively deployed. For convenience, the web URI scheme may be translated to a more classical file scheme. If necessary, this translation may be performed by a catalog.

For example, the following URI "web:///WEB-INF/xslt/xmlToHtml.xslt" could be resolved to "file:///path/to/tomcat/myWebapp/WEB-INF/xslt/xmlToHtml.xslt".

Example

A Web application

The following active sheet defines a service of a Web application

<?xml version="1.0" encoding="iso-8859-1"?>
<web:service xmlns:web="http://www.inria.fr/xml/active-tags/web" xmlns:xcl="http://www.inria.fr/xml/active-tags/xcl"> <web:init> <!-- define shareable stylesheets --> <xcl:parse-stylesheet name="xmlToHtml" scope="shared" value="web:///stylesheets/xmlToHtml.xslt"/> </web:init> <web:mapping match="^/this\.xml$" mime-type="application/xml"> <!-- simply return this active-sheet --> <xcl:transform output="{ value( $web:response/@web:output ) }" source="{ $this }"/> </web:mapping> <web:mapping match="^/(.+).html$" mime-type="text/html"> <!-- simply transform an XML file to HTML --> <xcl:transform output="{ value( $web:response/@web:output ) }"
source="web:///{ $web:match }.xml" stylesheet="{ $xmlToHtml }"/> </web:mapping> </web:service>

In this service, a stylesheet is parsed when the server starts. This stylesheet will be shared by all HTTP requests.

Assuming that the Web application is accessible with http://www.acme.org/foo/, this service might serves :

  • http://www.acme.org/foo/this.xml : the XML source of this service.
  • http://www.acme.org/foo/document.html : an HTML view of foo/document.xml.

3 Use cases

Using matchers

The $web:match property contains a list of strings matched by the regular expression used in the mapping ; in XPath, if a list contains a single item, it can be processed as is :

    <web:mapping match="^/(.+).html$" mime-type="text/html">
        <!-- simply transform an XML file to HTML -->
        <xcl:transform output="{ value( $web:response/@web:output ) }"
source="web:///{ $web:match }.xml" stylesheet="{ $xmlToHtml }"/> </web:mapping>

On the opposite, if a list contains several items, it must be processed by retrieving the nodes that compose the list (notice that the XPath wildcard * is not relevant because strings are not like XML elements) :

    <web:mapping match="^/(.+[^/])/img/(.*)$">
        <xcl:attribute name="web:mime-type" referent="{ $web:response }"
value="{ web:mime-type( $web:match/node()[2] ) }"/> <!-- simply display the img --> <io:copy source="web:///img/{ $web:match/node()[1] }/{ $web:match/node()[2] }"
target="{ value( $web:response/@web:output ) }"/> </web:mapping>

4 Web module reference

Web namespace URI : http://www.inria.fr/xml/active-tags/web
Usual prefix : web
Elements Foreign attributes Predefined properties Extended functions Data types
<web:service>
<web:init>
<web:mapping>
<web:flush>
<web:clear>
<web:invoke>
<web:start>
<web:post>
<web:get>
@web:version
$web:application
$web:service
$web:request
$web:response
$web:match
web:x-application
web:x-service
web:x-request
web:x-response

Must be an adt:expression that computes an object of the type expected.
Must be a hard-coded value (litteral)
Can be either a hard-coded value or an adt:expression
This material may be missing
Denotes a value to use by default
Allows a read operation.
Allows a write operation.
Allows a rename operation.
Allows an update operation.
Allows a delete operation.

4.1 Elements

<web:service>

Root element for an active sheet that stands for a Web service.

server initialization phase

The active sheet is unmarshalled when the Web engine starts.

If present, the <web:init> procedure is invoked.

HTTP handling phase

The Web engine selects the <web:mapping> procedure to invoke.

[TODO: content definition]

<web:init>

Defines the initialization procedure.

unmarshal phase

Registers this action to the processor instance as the default procedure.

runtime phase

Run the subactions.

[TODO: content definition]

<web:mapping>

Handles an HTTP request.

runtime phase

Run the subactions.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
hard-coded matchoptional adt:regexp

A regular expression used to match the request's URL.

missing attributedefault value

If missing, this procedure matches all URL with the method specified ; such mapping should be the last mapping defined in a service.

runtimeuseoptional

The string to use to test the regular expression.

missingdefault value The test is made on the part of the request's URL from the application name up to the query string ; for example, with the request http://www.foo.com/myApp/path/to/doc.html?param=value, the regular expression is tested on /path/to/doc.html. Notice that the application name is excluded from the path, which make matchings insensible to the deployment location of the application.
xs:string

It is possible to build other strings ; for example use="{$web:request/@web:full-path}" will produce /myApp/path/to/doc.html?param=value.

hard-codedmethodoptional Indicates which HTTP method will be matched by this mapping. If specified, one or several of the values below may be specified.
missing attributedefault value All HTTP methods are concerned.
xs:stringGETThis mapping will be activated on HTTP GET requests.
POSTThis mapping will be activated on HTTP POST requests.
HEADThis mapping will be activated on HTTP HEAD requests.
PUTThis mapping will be activated on HTTP PUT requests.
DELETEThis mapping will be activated on HTTP DELETE requests.
OPTIONSThis mapping will be activated on HTTP OPTIONS requests.
TRACEThis mapping will be activated on HTTP TRACE requests.
xs:string Several values from the above list, separated with blanks.
hard-codedmime-typeoptional Specify how to set the MIME type to the HTTP response.
missing attributedefault value No MIME type is set by default.
xs:string''Try to set the MIME type automatically according to the extension of the URL.
For example, if the URL is http://www.acme.org/index.html, the MIME type should be text/html.
The underlying implementation should define means to bind extensions to MIME types.
xs:string Set the MIME type to the value specified.
[TODO: content definition]

<web:flush>

Forces any content in the buffer of the HTTP response to be written to the client.


<web:clear>

Clears the buffer of the HTTP response, and eventually the status code and headers.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
hard-codedclear-headersoptionalIndicates whether the status code and headers have to be cleared or not.
xs:booleantruedefault valueClear all.
falsePreserve the status code and headers.

<web:invoke>

Invoke a service on the server.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
bothpathxs:string

The path to the service in the context of the current Web application.

hard-codedmodeoptionalIndicates whether the service must be included or forwarded.
xs:stringforwarddefault valueForwards the request from a service to another resource (service, HTML file, etc) on the server.
includeIncludes the content of another resource (service, HTML file, etc) in the HTTP response.

<web:start>

Start the server emulation

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
bothserviceweb:x-application

The web application


<web:post>

Emulate the post service.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
bothnamexs:string

The post name.

bothurlxs:string

The url you want send a request to.

bothserviceweb:x-application

The web application


<web:get>

Emulate the get service.

Attributes runtime | hard-coded | both
NameTypeValue optional | default value
bothnamexs:string

The post name.

bothurlxs:string

The url you want send a request to.(with cgi params)

bothserviceweb:x-application

The web application

4.2 Foreign attributes

@web:version

The version of the Web module to use. This attribute should be encountered before any Web element, but it takes precedence on the element inside which it is hosted.

4.3 Predefined properties

$web:application

  • Property type: web:x-application
  • $web:application is a reference to the Web application.


    $web:service

  • Property type: web:x-service
  • $web:service is a reference to the HTTP service.


    $web:request

  • Property type: web:x-request
  • $web:request is a reference to the HTTP request.


    $web:response

  • Property type: web:x-response
  • $web:response is a reference to the HTTP response.


    $web:match

  • Property type: adt:list of xs:string
  • $web:match contains a list of strings that has been captured by the regular expression used in a <web:mapping>.

    4.5 Data types

    web:x-application type

    Represents a Web application.

    Operation read | write | rename | update | delete
    TypeValueComment
    type()
    xs:QNameweb:x-applicationThis type
    string()
    readxs:string The string value of the application is its name, if the underlying Web engine is naming applications.
    attribute::
    readadt:map of adt:NItem A set of attributes including those specified below (and that can't be removed). Other predefined attributes may have been set by the underlying Web engine. At runtime, additional attributes may be set, removed or updated, if they are not bound to a namespace URI.
    @web:server-info
    readxs:string Informations about the underlying Web engine.
    @web:server-version
    readxs:string The version of the underlying Web engine.
    @web:path
    readxs:string The path to the application, that either starts with "/", or is "".
    @web:init-param
    readadt:map of xml:attribute A fixed set of attributes that are not bound to a namespace URI. They represent the parameters used when the application is initialized.

    web:x-service type

    Represents an HTTP service.

    Operation read | write | rename | update | delete
    TypeValueComment
    type()
    xs:QNameweb:x-serviceThis type
    string()
    readxs:string The string value of the service is its name, if the underlying Web engine is naming services.
    attribute::
    readadt:map of xml:attribute A fixed set of attributes including those specified below. Other attributes are not bound to a namespace URI and represent the parameters used when the service is initialized.
    @web:info
    readxs:string Informations about the service, such as author, version...

    web:x-request type

    Represents an HTTP request.

    Operation read | write | rename | update | delete
    TypeValueComment
    type()
    xs:QNameweb:x-requestThis type
    child::
    readadt:list of adt:NItem Represent the parameters contained in the query string or posted form data. The parameters are contained in a fixed list of values that have names. Each name in the list is a string not bound to a namespace URI (the name of the parameter) ; the list may contain duplicate names.
    attribute::
    readadt:map of adt:NItem A set of attributes including those specified below (and that can't be removed). Other predefined attributes may have been set by the underlying Web engine. Additional attributes may be set, removed or updated, if they are not bound to a namespace URI.
    @web:content-length
    readxs:integer The length of the request body, the same as the CGI variable CONTENT_LENGTH.
    @web:input
    readio:input The body of the request.
    @web:scheme
    readxs:string The name of the scheme used to make this request, for example, http or https.
    @web:is-secure
    readxs:boolean Indicates whether this request was made using a secure channel, such as HTTPS.
    @web:application-path
    readxs:string The path to the application, that either starts with "/", or is "" (for the root application).
    @web:path
    readxs:string The path of the request's URL from the protocol name up to the query string.
    For example, with the request http://www.acme.org/path/to/doc.html?param=value, the path is /path/to/doc.html.
    @web:full-path
    readxs:string The path of the request's URL from the protocol and with the query string.
    For example, with the request http://www.acme.org/path/to/doc.html?param=value, the full path is /path/to/doc.html?param=value.
    @web:url
    readxs:string The full URL of the request, including the protocol, server name, port number, and path, but it does not include query string parameters.
    For example, with the request http://www.acme.org/path/to/doc.html?param=value, the URL is http://www.acme.org/path/to/doc.html.
    @web:full-url
    readxs:string The full URL of the request, including the protocol, server name, port number, path, and the query string.
    For example, with the request http://www.acme.org/path/to/doc.html?param=value, the full URL is the same.
    @web:headers
    readadt:list of adt:NItem Represent the headers contained in this request. The headers are contained in a fixed list of values that have names. Each name in the list is a string not bound to a namespace URI (the name of the header) ; the list may contain duplicate names.
    @web:method
    readxs:string The name of the HTTP method with which this request was made, for example, GET, POST, or PUT ; the same as the value of the CGI variable REQUEST_METHOD.
    @web:path-info
    readxs:string Any extra path information associated with the URL the client sent when it made this request ; the same as the value of the CGI variable PATH_INFO.
    @web:path-translated
    readxs:string Any extra path information translated to a real path ; the same as the value of the CGI variable PATH_TRANSLATED.
    Example : /var/www/htdocs/path/to/doc.html
    @web:query-string
    readxs:string The query string that is contained in the request URL after the path ; the same as the value of the CGI variable QUERY_STRING.

    Note

    Precaution while handling parameters

    As a request may handle several parameters that has the same name, it is recommended to use one of the following form when processing a single parameter :

    If more than 1 parameter was supplied whereas only 1 is expected, the parameters in excess would be ignored.


    web:x-response type

    Represents an HTTP response.

    Operation read | write | rename | update | delete
    TypeValueComment
    type()
    xs:QNameweb:x-responseThis type
    child::
    Represent the HTTP headers of the response. The HTTP headers are contained in a list (by default, it is empty) of values that have names. Each name in the list is a string not bound to a namespace URI (the name of the HTTP header) ; the list may contain duplicate names.
    readadt:list of adt:NItem A list of HTTP headers.
    updateadt:NItem A header name and its value.
    attribute::
    readadt:map of adt:NItem A set of attributes including those specified below (and that can't be removed). Other attributes that are not bound to a namespace URI represent the cookies set to the HTTP response.
    @web:character-encoding
    readxs:string The name of the chararacter encoding of the HTTP response.
    updatexs:string The name of the chararacter encoding of the HTTP response.
    @web:output
    readio:output The output stream of the HTTP response.
    @web:buffer-size
    readxs:int The buffer size for the body of the HTTP response.
    updatexs:int The buffer size for the body of the HTTP response.
    @web:status-code
    The HTTP status code (200, 404, etc).
    readxs:int The value is -1 until it is explicitely changed.
    updatexs:int The value to set to the HTTP status.
    @web:id
    readxs:string The unique identifier assigned to this session.
    @web:creation-time
    readxs:long The time when this session was created (number of milliseconds since midnight January 1, 1970 GMT).
    @web:last-accessed-time
    readxs:long The last time the client sent a request associated with this session (number of milliseconds since midnight January 1, 1970 GMT).
    @web:max-inactive-interval
    readxs:int The maximum time interval, in seconds, that this session will be keept open between client accesses.
    updatexs:int The maximum time interval, in seconds, that this session will be keept open between client accesses.

    web:x-cookie type

    [TODO]

    Appendix

    A Glossary

    B Related Active Tags specifications

    This list is not exhaustive; it is a list of common modules usable by an engine that implements the Active Tags specifications that implementors may use. Additional modules are welcome.

    C Lists

    C.1 Examples list

    C.2 Figures list