# HG changeset patch # User paulb # Date 1121639692 0 # Node ID 4deb57f556b05f71378c39eba1c0302cbed906de # Parent 839da32932e9944fcffaf693d889c7bfaeee2ae9 [project @ 2005-07-17 22:34:52 by paulb] Changed the example HTML code to match the working example code. Added more selector documentation. diff -r 839da32932e9 -r 4deb57f556b0 docs/design.html --- a/docs/design.html Sun Jul 17 22:33:17 2005 +0000 +++ b/docs/design.html Sun Jul 17 22:34:52 2005 +0000 @@ -2,14 +2,21 @@
+ + + + +To design a template, create a new Web page using whichever tools or applications you feel most comfortable with. Given that XSLForms applications involve Web forms, @@ -29,11 +38,11 @@ is not that important to use the correct names in each of the fields - these will be added later.
-Here are some tips for -designing the template:
+The following sections discuss various techniques used in designing a template.
Think about your form in terms of the structure of the data being represented. You may want to have a list of items where each item can be edited by changing a text field @@ -42,17 +51,23 @@ like this:
+ -The HTML code which produces this item might look like this:
+ +The HTML code which produces this item in a Web page might look like this:
-<p>+ +
Some item: <input name="value" type="text" value="some value" />
<input name="remove" type="submit" value="Remove" />
</p>
<html xmlns="http://www.w3.org/1999/xhtml">+
<head>
<title>Example</title>
</head>
<body>
<!-- Template text between the start and the interesting part. -->
<form action="" method="POST">
<p>
Some item: <input name="value" type="text" value="some value" />
<input name="remove" type="submit" value="Remove" />
</p>
<!-- Template text between the interesting part and the end. -->
</form>
</body>
</html>
Although you will only need to "paint" one such item in the document, you should imagine that when @@ -61,38 +76,52 @@ an HTML element which can be replicated many times at a particular position in a document, like this:
+<p>+
Some item: <input name="value" type="text" value="some value" />
<input name="remove" type="submit" value="Remove" />
</p>
<p>
Some item: <input name="value" type="text" value="some value" />
<input name="remove" type="submit" value="Remove" />
</p>
<p>
Some item: <input name="value" type="text" value="some value" />
<input name="remove" type="submit" value="Remove" />
</p>
Making sure that the final form of the list is sensible HTML code is an activity explored later in the development process.
+Although we need not consider the structure of the template too deeply, given the above advice about how structure should be represented in HTML, it is interesting to consider hierarchical or nested structures. For example, each item in a list may itself contain a number of other items; for example:
+ +Given that the whole of the above fragment is a single item in a list, to ensure that the above advice is heeded about items being easily replicated, we need to enclose the fragment in a single HTML element, like this:
-<div>+ +
<p>
Some item: <input name="value" type="text" value="some value" />
<input name="remove" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p>
Sub-item: <input name="subvalue" type="text" value="some other value" />
<input name="remove2" type="submit" value="Remove" />
</p>
</div>
<html xmlns="http://www.w3.org/1999/xhtml">+
<head>
<title>Example</title>
</head>
<body>
<form action="" method="POST">
<!-- Template text between the start and the interesting part. -->
<div>
<p>
Some item: <input name="value" type="text" value="some value" />
<input name="remove" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p>
Sub-item: <input name="subvalue" type="text" value="some other value" />
<input name="remove2" type="submit" value="Remove" />
</p>
</div>
<!-- Template text between the interesting part and the end. -->
</form>
</body>
</html>
In the above example, the div
element encloses the
outer list item. Meanwhile, the inner list item is itself enclosed
@@ -100,13 +129,17 @@
example enclosed its simple list item. Consider the above example with
replicated items:
<div>+
<p>
Some item: <input name="value" type="text" value="some value" />
<input name="remove" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p>
Sub-item: <input name="subvalue" type="text" value="some other value" />
<input name="remove2" type="submit" value="Remove" />
</p>
<p>
Sub-item: <input name="subvalue" type="text" value="some other value" />
<input name="remove2" type="submit" value="Remove" />
</p>
<p>
Sub-item: <input name="subvalue" type="text" value="some other value" />
<input name="remove2" type="submit" value="Remove" />
</p>
</div>
<div>
<p>
Some item: <input name="value" type="text" value="some value" />
<input name="remove" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p>
Sub-item: <input name="subvalue" type="text" value="some other value" />
<input name="remove2" type="submit" value="Remove" />
</p>
</div>
Once you are happy with the design of the page, save it to the directory created earlier, then proceed to adding structure information in the next stage of the process.
+ diff -r 839da32932e9 -r 4deb57f556b0 docs/selectors.html --- a/docs/selectors.html Sun Jul 17 22:33:17 2005 +0000 +++ b/docs/selectors.html Sun Jul 17 22:34:52 2005 +0000 @@ -2,52 +2,25 @@ - - - - - - - - - +In the previous activity we annotated the template with -structural information, and these annotations should be sufficient in +
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:
@@ -56,150 +29,174 @@What we want to do is to have buttons beside each list item +
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.
-
-
Taking the HTML example from before, we add some additional annotations to the template to produce something like this:
+So, we need to add buttons to the Web form which, +upon being pressed, provide information about their context to +the XSLForms framework and subsequently to the application, so that we +know which part of the form is to be altered. To make sure that such +contextual information is available in the Web form, we must include +such references in the descriptions of these buttons in the template.
- +The concept of a "selector" is a reference which is expressed +in a special notation in the template, converted to concrete references +in the final output, and can be interpreted when a user submits a form +such that the associated section of the XML document version of the +form data can be identified in connection with an action. In other +words, we write a special value into the definition of a button in a +Web form which can automatically be used to refer to other form data +when the form is submitted.
-<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>
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">
<form action="" method="POST">
<!-- Template text between the start and the interesting part. -->
<div template:element="item">
<p>
<span template:attribute="value">
Some item: <input name="{template:field-name()}" type="text" value="{$this-value}" />
</span>
<input name="remove={template:this-position()}" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p template:element="subitem">
<span template:attribute="subvalue">
Sub-item: <input name="{template:field-name()}" type="text" value="{$this-value}" />
</span>
<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. -->
</form>
</body>
</html>
Some of the attributes in the original HTML code have been changed:
- +Some of the attributes in the original HTML code have been +changed:
input
element for the first Remove
button (mapping to item
elements in the XML document) has a modified name
attribute, containing the special remove={template:this-position()}
value.input
element for the
+first Remove
button (mapping
+to item
elements in the XML document)
+has a modified name
attribute,
+containing the special remove={template:this-position()}
+value.input
element for the second Remove
button (mapping to subitem
elements in the XML document) has a modified name
attribute, containing the special remove2={template:this-position()}
value.input
element for the second Remove
+button (mapping to subitem
elements in the
+XML document) has a modified name
+attribute, containing the special remove2={template:this-position()}
+value.What these amendments provide is a means for the XSLForms framework +
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.
Remove
button appears within the p
element which is annotated as mapping onto the item
+ Remove
button
+appears within the p
element which is
+annotated as mapping onto the item
element in the XML document. This means that the special value added
above will, in the final output, refer to that specific list item from
the XML document.Remove
button appears within the p
element which is annotated as mapping onto the subitem
+ Remove
button appears
+within the p
element which is
+annotated as mapping onto the subitem
element in the XML document. This means that the special value added
-above will, in the final output, refer to that specific list (sub)item from
+above will, in the final output, refer to that specific list (sub)item
+from
the XML document.Some additional sections have been added to the original HTML code:
+ +Some additional sections have been added to the original HTML +code:
subitem
paragraph, containing an input
element which employs the special add2={template:this-position()}
value in the name
attribute to represent an Add subitem
button.subitem
+paragraph, containing an input
+element which employs the special add2={template:this-position()}
+value in the name
attribute to
+represent an Add subitem
button.item
section, containing an input
element which employs the special add={template:this-position()}
value in the name
attribute to represent an Add item
button.item
+section, containing an input
element
+which employs the special add={template:this-position()}
+value in the name
attribute to
+represent an Add item
button.What these amendments provide is also a means for the XSLForms framework to connect these buttons to parts of the XML document.
+What these amendments provide is also a means for the XSLForms +framework to connect these buttons to parts of the XML document.
Add subitem
button appears outside the p
element mapping onto the subitem
element in the XML document. Instead, it appears within the p
element mapping onto the item
+ Add subitem
button appears
+outside the p
element mapping onto
+the subitem
element in the XML
+document. Instead, it appears within the p
+element mapping onto the item
element in the XML document. This means that the special value added
-above will, in the final output, refer to a specific item
from
-the XML document, and the consequence of adding a subitem
will be the extension of that list of subitem
elements within that item
element.item
+from
+the XML document, and the consequence of adding a subitem
+will be the extension of that list of subitem
+elements within that item
element.
- Add item
button appears outside the p
element mapping onto the item
-element in the XML document. Instead, it appears within the body
element mapping onto the top-level structure
+ Add item
button
+appears outside the p
+element mapping onto the item
+element in the XML document. Instead, it appears within the body
+element mapping onto the top-level structure
element in the XML document. This means that the special value added
above will, in the final output, refer to the top-level structure
element in
-the XML document, and the consequence of adding an item
will be the extension of the main list of item
elements.item
will
+be the extension of the main list of item
+elements.
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:
- - +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()}
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.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.
- - +The reference guide +provides a complete list of special values for use in template +annotations.
Whilst many forms consist only of text fields and action buttons, other types of data are very likely to also be used. Multiple-choice or enumerated value fields in forms are covered in the next activity in the development process.
+ diff -r 839da32932e9 -r 4deb57f556b0 docs/structure.html --- a/docs/structure.html Sun Jul 17 22:33:17 2005 +0000 +++ b/docs/structure.html Sun Jul 17 22:34:52 2005 +0000 @@ -5,6 +5,8 @@ + + @@ -14,6 +16,9 @@ + + + @@ -28,6 +33,8 @@ + + @@ -41,11 +48,13 @@ +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 @@ -54,14 +63,18 @@ +
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"?>+
<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:
+item
.value
.subitem
.subvalue
.structure
.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.
+
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">
<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>
<html xmlns="http://www.w3.org/1999/xhtml"+ @@ -151,15 +185,19 @@ +
xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
<head>
<title>Example</title>
</head>
<body template:element="structure">
<form action="" method="POST">
<!-- Template text between the start and the interesting part. -->
<div template:element="item">
<p>
<span template:attribute="value">
Some item: <input name="{template:field-name()}" type="text" value="{$this-value}" />
</span>
<input name="remove" type="submit" value="Remove" />
</p>
<p>
Itself containing more items:
</p>
<p template:element="subitem">
<span template:attribute="subvalue">
Sub-item: <input name="{template:field-name()}" type="text" value="{$this-value}" />
</span>
<input name="remove2" type="submit" value="Remove" />
</p>
</div>
<!-- Template text between the interesting part and the end. -->
</form>
</body>
</html>
template:element
attributes were added to the HTML elements which will be replicated when presenting the final output.template:attribute
attributes were added to the form input
elements.template:attribute
attributes were added to some new HTML span
elements.In addition, some of the attributes in the original HTML code have been changed:
+input
elements' name
attributes have been redefined to use the special {template:field-name()}
value.input
elements' value
attributes have been redefined to use the special {$this-value}
value.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.
+Note also that a namespace declaration is required for the template
attributes, and it is usually best to put this declaration on the top-level html
element in the template.
The following special annotations can be used to describe XML document structures in templates:
+template:element
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
@@ -237,12 +292,14 @@
+
template:attribute
template:attribute
annotation exposes various
special values which are described below - such value insert dynamic
@@ -251,10 +308,12 @@
+
{$this-value}
{template:field-name()}
The reference guide provides a complete list of special values for use in template annotations.
+ +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 @@ -294,5 +359,6 @@ +