# HG changeset patch # User paulb # Date 1121627931 0 # Node ID 77c0470d7734a9bcb87ddf1f9c6033d7802510a3 # Parent 082c3973a0ede6dd39442708367097775802bd9f [project @ 2005-07-17 19:18:51 by paulb] Added conceptual model and selector documents. Improved the existing documents. diff -r 082c3973a0ed -r 77c0470d7734 docs/index.html --- a/docs/index.html Sun Jul 17 01:07:10 2005 +0000 +++ b/docs/index.html Sun Jul 17 19:18:51 2005 +0000 @@ -1,46 +1,66 @@ + + + + + Developing Web Applications with XSLTools - + + + + + +

Developing Web Applications with XSLTools

+

This documentation introduces the XSLTools package and the XSLForms -framework for developing forms-based Web applications using Python, libxml2dom, -libxml2, libxslt and (optionally) WebStack.

+framework for developing forms-based Web applications using Python, libxml2dom, +libxml2, libxslt and (optionally) WebStack.

+

Setting Up

+

First of all, let us assume that the XSLTools distribution has been unpacked and now sits in the XSLTools-0.1 directory.

+

Before we begin, we must make sure that the XSLTools package is available to Python. The easiest way to do this is to change into the XSLTools-0.1 directory and to run the setup.py script provided with the version of Python you are going to be using (possibly as a privileged user like root):

+
cd XSLTools-0.1
python setup.py install
+

If you don't want to install XSLTools in this way, or if you can't do so because you don't have root privileges, you can just make sure that the XSLTools-0.1 directory sits on your PYTHONPATH.

+

Viewing the API Documentation

+

The API documentation for use in conjunction with this guide can be found inside the apidocs directory within the XSLTools-0.1 directory. Of course, it is always possible to view the API documentation -within Python by importing modules (such as XSLOutput) +within Python by importing modules (such as XSLOutput) and using Python's built-in help function.

+

About XSLForms Applications

+ + diff -r 082c3973a0ed -r 77c0470d7734 docs/model.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/model.html Sun Jul 17 19:18:51 2005 +0000 @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + The XSLForms Conceptual Model + + + + + + + + + + +

The XSLForms Conceptual Model

+ +

In applications based on XSLForms, form data is processed as XML documents as shown in the following diagram:

+ + + + + + + + + + + + + + + +
Application
+ Starting with an initial XML document...
XSLForms
+ A template is used together with the XML document to produce a Web page...
Browser
+ The Web page contains a form which is filled out by users of the application and submitted back to the application...
XSLForms
+ The incoming form data is converted to an XML document...
Application
+ The incoming XML document is processed, validated, and so on...
XSLFormsA template is used together with the new XML document to produce a Web page...BrowserAn updated Web page is shown to the user. The page may contain a form which may be filled out and submitted...
+

The XSLForms framework therefore performs two main functions:

+ + + diff -r 082c3973a0ed -r 77c0470d7734 docs/overview.html --- a/docs/overview.html Sun Jul 17 01:07:10 2005 +0000 +++ b/docs/overview.html Sun Jul 17 19:18:51 2005 +0000 @@ -1,34 +1,59 @@ + + + + + Creating Applications: An Overview - + + + + + +

Creating Applications: An Overview

+

The following steps briefly describe how to make a new application:
+

+
    +
  1. Create a directory to hold your files
  2. +
  3. Design a template
  4. +
  5. Add structure to the template
  6. +
  7. Add selectors to the template
  8. +
  9. Prepare catalogues of multiple-choice values
  10. +
  11. Write a Web resource to display the form
  12. +
+

Recommendations

+
    +
  1. Where multiple fields exist and can be added and removed, put them inside a separate element so that the selectors can successfully identify them. Otherwise, changing element orders can result in the wrong element being selected.
  2. +
  3. Make sure that transformations on the input document produce all the necessary elements for the output document so that the resulting page gives the user the opportunity to specify data that is missing.
  4. +
+ diff -r 082c3973a0ed -r 77c0470d7734 docs/selectors.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/selectors.html Sun Jul 17 19:18:51 2005 +0000 @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Creating Applications: Add Selectors + + + + + + + + + + + + + + + + + + +

Creating Applications: Add Selectors

+ + + + +

In the previous activity we annotated the template with +structural information, and these annotations should be sufficient in +presenting XML documents as Web pages for users to interact with. +However, in our design, we also wanted to be able to add and remove +list items from the example hierarchy:

+ + + +

What we want to do is to have buttons beside each list item +(and subitem) which remove only that particular item. In addition, we +also want buttons which add items only to the particular list each +button appears beneath.
+ + + +

+ + + +

Introducing Selectors

+ + + +

Taking the HTML example from before, we add some additional annotations to the template to produce something like this:

+ + + +
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
<head>
<title>Example</title>
</head>
<body template:element="structure">

<!-- Template text between the start and the interesting part. -->

<div template:element="item">
<p>
Some item: <input template:attribute="value" name="{template:field-name()}" type="text" value="{$this-value}" />
<input name="remove={template:this-position()}" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p template:element="subitem">
Sub-item: <input template:attribute="subvalue" name="{template:field-name()}" type="text" value="{$this-value}" />
<input name="remove2={template:this-position()}" type="submit" value="Remove" />
</p>
<p>
<input name="add2={template:this-position()} type="submit" value="Add subitem" />
</p>
</div>
<p>
<input name="add={template:this-position()} type="submit" value="Add item" />
</p>

<!-- Template text between the interesting part and the end. -->

</body>
</html>
+ +

The Remove Buttons

+

Some of the attributes in the original HTML code have been changed:

+ + + + + + + +

What these amendments provide is a means for the XSLForms framework +to connect together the usage of a button in the Web form with an XML +document element.

+ + + +

The Add Buttons

+

Some additional sections have been added to the original HTML code:

+ + + +

What these amendments provide is also a means for the XSLForms framework to connect these buttons to parts of the XML document.

+ + +
+

Selector Annotation

+ + + +

Special values of the following form can be used to connect parts of +the template with elements in the XML document representation of a form:

+ + + +
+
selector={template:this-position()}
+ + + +
Given a selector name (selector in this example), +this special value produces a reference to an XML document element (or +attribute) in the final output. The referenced element or attribute is +defined by those template:element and template:attribute annotations on template elements which surround the template element within which this special value is used.
+ + + +
+ + + +

The reference guide provides a complete list of special values for use in template annotations.

+ + + +
+ + diff -r 082c3973a0ed -r 77c0470d7734 docs/structure.html --- a/docs/structure.html Sun Jul 17 01:07:10 2005 +0000 +++ b/docs/structure.html Sun Jul 17 19:18:51 2005 +0000 @@ -2,14 +2,35 @@ + + + + + + + + + + + + + + + Creating Applications: Add Structure + + + + + + @@ -17,82 +38,209 @@ + + +

Creating Applications: Add Structure

+ + +

During the design activity, it was necessary to consider the structure of the information being presented. In proper XSLForms templates, we make such structural information explicit by adding special attributes to the HTML code. Consider the hierarchy example presented in the previous activity:

- -

The XSLForms Conceptual Model

-

In XSLForms applications form data is processed as XML documents.

+ + + -

Therefore, it becomes important to imagine how we would represent + +

+Since XSLForms is all about the processing of form data as simple XML documents, it becomes important to imagine how we would represent the data described above as an XML document; something like this might -be appropriate:

-
<?xml version="1.0"?>
<item value="some value">
<subitem subvalue="some other value"/>
</item>
+be appropriate: +

+ +
<?xml version="1.0"?>
<structure>
<item value="some value">
<subitem subvalue="some other value"/>
</item>
</structure>
+ + +

Therefore, we must seek to add the following structural information to our HTML code:

+ + + + + +

What we must do is to find a way to describe how our template will map onto the form data and present it as a Web page for the purpose of user interaction.
+ + +

+ + +

Annotating the Template

+ + +

Taking the HTML example from before, we add special annotations to the template to produce something like this:

-
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">

<!-- Template text between the start and the interesting part. -->

<div template:element="item">
<p>
Some item: <input template:attribute="value" name="{template:field-name()}" type="text" value="{$this-value}" />
<input name="remove" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p template:element="subitem">
Sub-item: <input template:attribute="subvalue" name="{template:field-name()}" type="text" value="{$this-value}" />
<input name="remove2" type="submit" value="Remove" />
</p>
</div>

<!-- Template text between the interesting part and the end. -->

</html>
+ + + +
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
<head>
<title>Example</title>
</head>
<body template:element="structure">

<!-- Template text between the start and the interesting part. -->

<div template:element="item">
<p>
Some item: <input template:attribute="value" name="{template:field-name()}" type="text" value="{$this-value}" />
<input name="remove" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p template:element="subitem">
Sub-item: <input template:attribute="subvalue" name="{template:field-name()}" type="text" value="{$this-value}" />
<input name="remove2" type="submit" value="Remove" />
</p>
</div>

<!-- Template text between the interesting part and the end. -->

</body>
</html>
+ + +

The following annotations have been added:

+ + + + + +

In addition, some of the attributes in the original HTML code have been changed:

+ + + + + +

Whereas the first set of annotations reproduce the desired structure, the latter modifications are really housekeeping measures to make sure that the final output contains the correct names and values for each of the form fields shown to the user.

+ + +

Basic Template Annotation

+ + +

The following special annotations can be used to describe XML document structures in templates:

+ + +
+ + +
template:element
+ + +
This attribute should be added to an element in the template in order to mark that element and its contents as mapping onto or representing an element in the XML document version of the form. In the example, the div element is annotated with this attribute to indicate that it maps onto the item element in the XML document version of the form. It is possible to specify more than one name as the value for a template:element attribute by separating each name with a comma; for example:
+ + + + + +
<div template:element="parent,child">
<p>This is a child element in the XML document version of the form.</p>
</div>
+ + +
+ + +
The meaning of this is that the annotated element maps onto all child elements within all parent elements in the XML document version of the form. In other words, instead of having to create separate HTML elements in the template for each XML document element being represented, we can collapse the annotations into a single template:element attribute on a single HTML element.
+ + +
template:attribute
+ + +
This attribute should be added to an element in the template in order to mark that element and its contents as mapping onto  or representing an attribute in the XML document version of the form. @@ -100,23 +248,51 @@ special values which are described below - such value insert dynamic content from the XML document version of the form into the final output generated from the template.
+ + +
{$this-value}
+ + +
This special value should be used in HTML attributes where the value of an attribute from the XML document version of the form is to be included or presented in the final output. In the example, the value and subvalue attributes are presented in the value attributes of the HTML input elements in this way.
+ + +
{template:field-name()}
+ + +
This special value should be used in HTML attributes where the name of an attribute from the XML document version of the form is to be included or presented in the final output.
+ + +
+ + +

The reference guide provides a complete list of special values for use in template annotations.

+ + +
-

Adding Selectors

+ + +

Whilst the above annotations permit the template to display the data in XML documents containing form data, the other aspects of the user interface - the addition and removal of items and subitems - are not -yet modelled in the template.

+yet modelled in the template. These things will be added to the template as selectors as part of the next activity in the development process.

+ + + + +