# XForms to XHTML Stylesheet

Tue Aug 20 03:15:27 EDT 2002
$Id: README.xml,v 1.2 2002/08/27 18:56:08 rick Exp $
rick frankel
cyberCode consulting inc

    		  rick@rickster.com

## Contents

- `xforms.xsl` xforms to html template

- `xforms.css` Example CSS styles for above output

- `test.xml` Test input

- `PostFilter.pm` Apply posted data to embedded instance data (see below)

- `README.xml` source to this document

## Sample Usage

    	  xsltproc --param list-size 3 xforms.xsl test.xml

## Optional Parameters

There are 2 default (xsl:params) in the template. One controls the formatting of lists. The other controls the encoding of the instance data into the hidden form field _instance (see below). Their defaults are:

- list-size 5

- encode-instance-data 0 (false()

## Requirements

The stylesheet has been tested with the xsltproc command-line processor.

The template requires an xslt processor which supports the following exst extensions:

- str:tokenize for handling multi-valued select instance data

- dyn:evaluate for instance data

- func:function for accessing model nodes and more.

Note that the dyn prefix is mapped to the http://icl.com/saxon namespace, which is available in the current release version of libXML. When the cvs version is released, the evaluate function will also be mapped into the http://exslt.org/dynamic namespace and the template can be changed. However, it seems that at least for the moment, the cvs version of libXML is also backwards compatible w/ the saxon namespace.

## Overview

The template attempts to handle as much of the Xforms RFC as possible w/o client side procesing or multi-pass transformations. Obviously, w/o client side processing things such as events, actions, control flow and interleaved model specific controls cannot be handled.

This version operates in xslt push mode. Any text or nodes (w/attributes) not in the xforms namespace are copied to the output as is. It handles multiple forms, but assumes that ALL the controls for each form are wrapped in an outermost xforms:group, in the same sense as binding elements are considered outermost in in section 7.3 of the xforms spec (that is, the xpath expression ancestor::xforms:group returns the null set).

It also assumes that the input contains all non xforms tags (e.g., html, head, body) required to generate a valid output document.

selectMany bindings are handled (I think) per the spec. That is, the instance data is assumed to be a space separated list of data.

Currently, nodeset attributes are assumed to be relative to xforms:instance (the root of the pseudo document as defined in the spec), as I cannot deduce from the spec whether they inherit outer context. If you want to bind a itemset to a relative reference, you can use a bind attribute. The bind element will be parsed as a relative path.

An xforms::group with the class attribute no-display can be used for context grouping and will not generate a 'div' element in the output. This is useful for generating instance context per section 7.3 of the spec without breaking e.g, a css table model. The template also ignores any caption, hint or common-attributes (class, accessKey) associated with the group.

Name attributes on the html form elements are generated according to the spec. That is, if the encoding is application/x-www-urlencoded, the name will be the local-name() of the data node. Any other encoding (default multipart-form-data) will be the xpath to the data.

## Instance Encoding

Since this implementation does not allow in-place editing of the instance data on the client, the OO perl library `PostFilter.pm` has been provided to perform this function on the backend. If value of the stylesheet parameter encode-instance-data is true (1), the instance data for the submitted form will be html-encoded into the hidden form parameter _instance. The PostFilter package provides one method (other than `new`), `parse`, which takes a single argument, a hash of the cgi parameters and returns a libXML document containing the updated instance data. A sample cgi script using `PostFilter` is provided in `t/filter_test.cgi`.

### PostFilter.pm

#### Functions

##### new([parser=>parser,debug=>int])

If an instance of `XML::libXML` is not passed in as the named param parser, it will be instantiated in the new function.

##### parse(%cgi_params)

The `parse` function takes a single argument, a reference to hash as returned by `CGI::Vars`. It returns an `XML::LibXML::Document`, with an xforms:instance root element.

## Support for the XForms Spec, section-by-section

### 2 Introduction to XForms

#### 2.6 Multiple Forms per Document

supported

### 3 Document Structure

#### 3.1 The XForms Namespace

template uses prefix xf:

#### 3.2 Horizontally Applicable Markup

elements and attributes in other namespaces copied verbatim

#### 3.3 Model

mutiple models allowed. controls for each form must be contained in an outer group element. The model used will be either the first model in the document, or the model specified by the first element found via the xpath expression ancestor:xf:*[@model]. extensionFunctions are not supported.

#### 3.4 instance

Supported for inline content, xlinks not supported

#### 3.5 schema

not supported

#### 3.6 submitInfo

supported

- action supported

- mediaTypeExtension supported

- method supported

- version not-supported

- indent not-supported

- encoding supported

- mediaType not-supported

- omitXMLDeclaration not-supported

- standalone not-supported

- CDATASectionElements not-supported

- replace not-supported

#### 3.7 privacy

not supported

#### 3.8 XForms and XLink

xlink not supported

### 4 Processing Model

#### 4.1 Events Overview

#### 4.2 Initialization Events

not supported

#### 4.3 Interaction Events

not supported

#### 4.4 XForms Submit

##### 4.4.1 xforms:submit

supported

##### 4.4.2 application/x-www-form-urlencoded

supported

##### 4.4.3 multipart/form-data

supported, default

##### 4.4.4 text/xml

not supported

#### 4.5 Error Indications

not supported

### 5 Datatypes

schemas not supported

### 6 Constraints

#### 6.1 XForms Constraints

##### 6.1.1 type

not currently used.

##### 6.1.2 readOnly

not currently used

##### 6.1.3 required

supported, class="required"

##### 6.1.4 relevant

supported, does not render control

##### 6.1.5 calculate

not supported

##### 6.1.6 isValid

supported, sets class="invalid" if false

##### 6.1.7 maxOccurs

supported, used for rendering repeats

##### 6.1.8 minOccurs

supported, used for rendering repeats

#### 6.2 Schema Constraints

not supported

#### 6.3 Additional Schema Examples

not supported

#### 6.4 Binding

supported

### 7 XPath Expressions in XForms

#### 7.1 XPath Datatypes

not supported

#### 7.2 Instance Data

dom no supported, no client side processing

#### 7.3 Evaluation Context

properly implemented, i think

#### 7.4 XForms Core Function Library

only those functions supported by libXML's xpath implementation

### 8 Form Controls

#### 8.1 input

supported

#### 8.2 secret

supported

#### 8.3 textarea

supported

#### 8.4 output

supported

#### 8.5 upload

supported

#### 8.6 range

not supported

#### 8.7 button

supported

#### 8.8 submit

supported

#### 8.9 selectOne

supported

#### 8.10 selectMany

supported

#### 8.11 Common Markup for selection controls

##### 8.11.1 choices

supported

##### 8.11.2 item

supported

##### 8.11.3 itemset

supported

##### 8.11.4 value

supported

#### 8.12 Common Markup

##### 8.12.1 Common Attributes

- xml:lang not supported

- class supported

- navIndex not supported

- accessKey supported

##### 8.12.2 Single Node Binding Attributes

supported

##### 8.12.3 Nodeset Binding Attributes

supported

##### 8.12.4 Common Child Elements

###### 8.12.4.1 caption

supported, creates field label

###### 8.12.4.2 help

not supported

###### 8.12.4.3 hint

supported, creates "title" (rollover)

###### 8.12.4.4 alert

not supported

###### 8.12.4.5 extension

not supported

### 9 XForms User Interface

#### 9.1 group

supported

#### 9.2 switch

not supported

#### 9.3 repeat

supported, startIndex and number attributes not supported

##### 9.3.1 Repeat Processing

no cursors

##### 9.3.2 Nested Repeats

supported

##### 9.3.3 User Interface Interaction

not supported

### 10 XForms Actions

not supported

### 11 Submit

#### 11.1 xforms-submit Event

not supported

#### 11.2 Submission Options

For obvious reasons, the options supported are limited due to browser limitations.

URI scheme

- http supported

- https supported

- mailto not supported

- file not supported

method

- post not supported

- get supported

- put not supported

- form-data-post supported

- urlencoded-post supported