# HG changeset patch # User paulb # Date 1131476640 0 # Node ID f1145b6cae5d274499c1ced7c2aa08834b108cfb # Parent 54d65557c69ebcdae54d32d506c09ec1ed987625 [project @ 2005-11-08 19:04:00 by paulb] Made minor fixes (POST -> post in request methods, removed form elements around example form controls). Added an elementary JavaScript function reference. Updated the overview, adding links to future documentation. Tidied the template design documentation. Added a style for definition list titles. diff -r 54d65557c69e -r f1145b6cae5d docs/JavaScript-reference.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/JavaScript-reference.html Tue Nov 08 19:04:00 2005 +0000 @@ -0,0 +1,8 @@ + + + + + JavaScript Function Reference + + +

JavaScript Function References

The following JavaScript functions are available for the triggering of in-page updates:

requestUpdateArea

Parameters:

url
The URL (which may be relative to the current page or resource) to which the update shall be sent. For example:
'platforms'
The above example causes an update to be sent to the location platforms relative to the current page.
sourceAreasStr
A comma-separated list of regions in the form data which affect the outcome of the update. For example:
'/package$1/platforms$1'
Typically, one would use an XSLT/template function to provide such information. For example:
'{template:other-elements(..)}'
Selector fields may be specified in addition to regions:
'{template:selector-name('remove_platform', .)}'
The above example causes the remove_platform selector field to be included in the update.
targetName
The element identifier (specified by an HTML or XML id attribute) within which the outcome of the update shall appear.
targetAreasStr
A comma-separated list of regions in the form data which are affected by the update. See the sourceAreasStr parameter for more details.
elementPath
A simple path into the form data, defining the scope of the update.

requestUpdate

Parameters:

url
The URL (which may be relative to the current page or resource) to which the update shall be sent. See the description of the url parameter for the requestUpdateArea function for more details.
fieldNamesStr
A comma-separated list of fields in the form data which affect the outcome of the update. For example:
'/package$1/name'
Typically, one would use an XSLT/template function to provide such information. For example:
'{template:other-attributes('name', .)}'
The above example causes the field associated with the name attribute on the current element to be included in the update.
targetName
The element identifier (specified by an HTML or XML id attribute) within which the outcome of the update shall appear.
targetFieldNamesStr
A comma-separated list of fields in the form data which are affected by the update. See the fieldNamesStr parameter for more details.
elementPath
A simple path into the form data, defining the scope of the update.
\ No newline at end of file diff -r 54d65557c69e -r f1145b6cae5d docs/design.html --- a/docs/design.html Tue Nov 08 19:02:02 2005 +0000 +++ b/docs/design.html Tue Nov 08 19:04:00 2005 +0000 @@ -1,12 +1,9 @@ - - + - Creating Applications: Design a Template - - - + + Creating Applications: Design a Template +

Creating Applications: Design a Template

@@ -24,7 +21,7 @@

The Template Outline

In raw HTML - that is, the code which defines how a Web page is made - we may wish to design the skeleton (or outline) of the page:

-
<?xml version="1.0"?>
<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. -->

<!-- The interesting part which we will design below. -->

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

</form>
</body>
</html>
+
<?xml version="1.0"?>
<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. -->

<!-- The interesting part which we will design below. -->

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

</form>
</body>
</html>

Most visual editors for Web pages will add such details automatically when creating a new page, but there are a few things to remember to check:

@@ -33,8 +30,7 @@ choose to create XHTML pages. We casually refer to our XHTML templates as being "HTML" throughout this documentation, and the well-formed stipulation is just assumed, but it should be noted that old-style -ill-formed HTML, where start and end tags need not match, will not work with XSL transformations +ill-formed HTML, where start and end tags need not match, will not work with XSL transformations and will therefore not work with XSLForms.
  • We add a form element to the outline so that @@ -46,11 +42,10 @@ label and a text field. Alongside these things, we may also wish to have a button which can be pressed to remove that item from its list. The visual representation of this might resemble the following:

    -
    +

    Some -item:

    -
    +item:

    +

    The HTML code which produces this representation might look like this:

    <div>
    <p>
    Some item: <input name="value" type="text" value="some value" />
    <input name="remove" type="submit" value="Remove" />
    </p>
    </div>
    @@ -67,13 +62,11 @@ the above design for the items by adding some additional text and a similar label, field and button arrangement for each of the subitems. For example:

    -
    -

    Some item: 

    + +

    Some item: 

    Itself containing more items:

    -

    Sub-item:

    -
    +

    Sub-item:

    +

    This representation might be expressed in HTML as follows:

    <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>

    In the above example, the div element encloses the @@ -90,15 +83,13 @@ We can thus extend our visual representation to incorporate such details. For example:

    -
    -

    Some item: 

    + +

    Some item: 

    Itself containing more items:

    -

    Sub-item:

    +

    Sub-item:

    -
    +

    This representation might be expressed in HTML as follows:

    <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>
    <input name="add2" type="submit" value="Add subitem" />
    </p>
    </div>
    <p>
    <input name="add" type="submit" value="Add item" />
    </p>

    In the above example, the new buttons have been added alongside the @@ -112,12 +103,10 @@

    Saving the Template

    Adding the above modifications to the outline, we end up with the following HTML code:

    -
    <?xml version="1.0"?>
    <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>
    <p>
    <input name="add2" type="submit" value="Add subitem" />
    </p>
    </div>
    <p>
    <input name="add" type="submit" value="Add item" />
    </p>

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

    </form>
    </body>
    </html>
    +
    <?xml version="1.0"?>
    <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>
    <p>
    <input name="add2" type="submit" value="Add subitem" />
    </p>
    </div>
    <p>
    <input name="add" type="submit" value="Add item" />
    </p>

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

    </form>
    </body>
    </html>

    Once you are happy with the design of the page, save it to the directory created earlier (perhaps choosing the name structure_template.xhtml), then proceed to adding -structure information in the next stage of the process.

    - - +structure information in the next stage of the process.

    + \ No newline at end of file diff -r 54d65557c69e -r f1145b6cae5d docs/multiple.html --- a/docs/multiple.html Tue Nov 08 19:02:02 2005 +0000 +++ b/docs/multiple.html Tue Nov 08 19:04:00 2005 +0000 @@ -30,7 +30,7 @@

    Taking the example HTML code from before, we can add a definition of this new list 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>
    Some item: <input template:attribute-field="value" name="..." type="text" value="..." />
    <input name="..." template:selector-field="remove" type="submit" value="Remove" />
    </p>
    <p>
    Item type:
    <select template:multiple-choice-field="type,value" name="...">
    <option template:multiple-choice-value="type-enum,value,selected" value="..." />
    </select>
    </p>
    <p>
    Itself containing more items:
    </p>
    <p template:element="subitem">
    Sub-item: <input template:attribute-field="subvalue" name="..." type="text" value="..." />
    <input name="..." template:selector-field="remove2" type="submit" value="Remove" />
    </p>
    <p>
    <input name="..." template:selector-field="add2,subitem" type="submit" value="Add subitem" />
    </p>
    </div>
    <p>
    <input name="..." template:selector-field="add,item" type="submit" value="Add item" />
    </p>

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

    </form>
    </body>
    </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">
    <form action="" method="post">

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

    <div template:element="item">
    <p>
    Some item: <input template:attribute-field="value" name="..." type="text" value="..." />
    <input name="..." template:selector-field="remove" type="submit" value="Remove" />
    </p>
    <p>
    Item type:
    <select template:multiple-choice-field="type,value" name="...">
    <option template:multiple-choice-value="type-enum,value,selected" value="..." />
    </select>
    </p>
    <p>
    Itself containing more items:
    </p>
    <p template:element="subitem">
    Sub-item: <input template:attribute-field="subvalue" name="..." type="text" value="..." />
    <input name="..." template:selector-field="remove2" type="submit" value="Remove" />
    </p>
    <p>
    <input name="..." template:selector-field="add2,subitem" type="submit" value="Add subitem" />
    </p>
    </div>
    <p>
    <input name="..." template:selector-field="add,item" type="submit" value="Add item" />
    </p>

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

    </form>
    </body>
    </html>

    There are a lot of details here that need to be explained. Here is what was done:

      diff -r 54d65557c69e -r f1145b6cae5d docs/multivalue.html --- a/docs/multivalue.html Tue Nov 08 19:02:02 2005 +0000 +++ b/docs/multivalue.html Tue Nov 08 19:04:00 2005 +0000 @@ -4,7 +4,6 @@ Creating Applications: Adding Multivalued Fields -

      Creating Applications: Adding Multivalued Fields

      Although some applications only require multiple-choice fields where @@ -23,19 +22,19 @@

      We shall now take advantage of those HTML form fields which permit users to select one or many values presented in a list or menu.

      -
      +

      Some item: 

      Item type:

      Itself containing more items:

      Sub-item:

      -
      + From the item type list many value may now be selected.

      Taking the example HTML code from before, we can add a definition of this new list 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>
      Some item: <input template:attribute-field="value" name="..." type="text" value="..." />
      <input name="..." template:selector-field="remove" type="submit" value="Remove" />
      </p>
      <p>
      Item type:
      <select name="..." template:multiple-choice-list-field="type,type-enum,value" multiple="multiple">
      <option template:multiple-choice-list-value="type-enum,value,selected" value="..." />
      </select>
      </p>
      <p>
      Itself containing more items:
      </p>
      <p template:element="subitem">
      Sub-item: <input template:attribute-field="subvalue" name="..." type="text" value="..." />
      <input name="..." template:selector-field="remove2" type="submit" value="Remove" />
      </p>
      <p>
      <input name="..." template:selector-field="add2,subitem" type="submit" value="Add subitem" />
      </p>
      </div>
      <p>
      <input name="..." template:selector-field="add,item" type="submit" value="Add item" />
      </p>

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

      </form>
      </body>
      </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">
      <form action="" method="post">

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

      <div template:element="item">
      <p>
      Some item: <input template:attribute-field="value" name="..." type="text" value="..." />
      <input name="..." template:selector-field="remove" type="submit" value="Remove" />
      </p>
      <p>
      Item type:
      <select name="..." template:multiple-choice-list-field="type,type-enum,value" multiple="multiple">
      <option template:multiple-choice-list-value="type-enum,value,selected" value="..." />
      </select>
      </p>
      <p>
      Itself containing more items:
      </p>
      <p template:element="subitem">
      Sub-item: <input template:attribute-field="subvalue" name="..." type="text" value="..." />
      <input name="..." template:selector-field="remove2" type="submit" value="Remove" />
      </p>
      <p>
      <input name="..." template:selector-field="add2,subitem" type="submit" value="Add subitem" />
      </p>
      </div>
      <p>
      <input name="..." template:selector-field="add,item" type="submit" value="Add item" />
      </p>

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

      </form>
      </body>
      </html>

      From the previous single-valued case, some crucial changes have been made:

        diff -r 54d65557c69e -r f1145b6cae5d docs/overview.html --- a/docs/overview.html Tue Nov 08 19:02:02 2005 +0000 +++ b/docs/overview.html Tue Nov 08 19:04:00 2005 +0000 @@ -20,5 +20,5 @@
      1. Adding multivalued fields
      2. Recommendations and advice
      3. Adding in-page updates
      4. -

      A topic-by-topic guide to XSLTools:

      Some other resources:

      +

    A topic-by-topic guide to XSLTools:

    Some other resources:

    \ No newline at end of file diff -r 54d65557c69e -r f1145b6cae5d docs/selectors.html --- a/docs/selectors.html Tue Nov 08 19:02:02 2005 +0000 +++ b/docs/selectors.html Tue Nov 08 19:04:00 2005 +0000 @@ -26,7 +26,7 @@

    Taking the example HTML code from before, we add some of these selector 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>
    Some item: <input template:attribute-field="value" name="..." type="text" value="..." />
    <input name="..." template:selector-field="remove" type="submit" value="Remove" />
    </p>
    <p>
    Itself containing more items:
    </p>
    <p template:element="subitem">
    Sub-item: <input template:attribute="subvalue" name="{template:this-attribute()}" type="text" value="{$this-value}" />
    <input name="..." template:selector-field="remove2" type="submit" value="Remove" />
    </p>
    <p>
    <input name="..." template:selector-field="add2,subitem" type="submit" value="Add subitem" />
    </p>
    </div>
    <p>
    <input name="..." template:selector-field="add,item" type="submit" value="Add item" />
    </p>

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

    </form>
    </body>
    </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">
    <form action="" method="post">

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

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

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

    </form>
    </body>
    </html>

    The Remove Buttons

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

    diff -r 54d65557c69e -r f1145b6cae5d docs/structure.html --- a/docs/structure.html Tue Nov 08 19:02:02 2005 +0000 +++ b/docs/structure.html Tue Nov 08 19:04:00 2005 +0000 @@ -4,7 +4,6 @@ Creating Applications: Add Structure -

    Creating Applications: Add Structure

    Earlier, we defined the structure of the form @@ -42,7 +41,7 @@ document correctly.

    Completing the Template

    The template in full should now look something like this:

    -
    <?xml version="1.0"?>
    <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>
    Some item: <input template:attribute-field="value" name="..." type="text" value="..." />
    <input name="remove" type="submit" value="Remove" />
    </p>
    <p>
    Itself containing more items:
    </p>
    <p template:element="subitem">
    Sub-item: <input template:attribute-field="subvalue" name="..." type="text" value="..." />
    <input name="remove2" type="submit" value="Remove" />
    </p>
    <p>
    <input name="add2" type="submit" value="Add subitem" />
    </p>
    </div>
    <p>
    <input name="add" type="submit" value="Add item" />
    </p>

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

    </form>
    </body>
    </html>
    +
    <?xml version="1.0"?>
    <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>
    Some item: <input template:attribute-field="value" name="..." type="text" value="..." />
    <input name="remove" type="submit" value="Remove" />
    </p>
    <p>
    Itself containing more items:
    </p>
    <p template:element="subitem">
    Sub-item: <input template:attribute-field="subvalue" name="..." type="text" value="..." />
    <input name="remove2" type="submit" value="Remove" />
    </p>
    <p>
    <input name="add2" type="submit" value="Add subitem" />
    </p>
    </div>
    <p>
    <input name="add" type="submit" value="Add item" />
    </p>

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

    </form>
    </body>
    </html>

    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, as shown in diff -r 54d65557c69e -r f1145b6cae5d docs/styles.css --- a/docs/styles.css Tue Nov 08 19:02:02 2005 +0000 +++ b/docs/styles.css Tue Nov 08 19:04:00 2005 +0000 @@ -75,3 +75,8 @@ background-color: rgb(153, 153, 255); } + dt { padding: 0.25em; + margin-top: 1em; + margin-bottom: 1em; + background-color: rgb(238, 238, 238); + } diff -r 54d65557c69e -r f1145b6cae5d docs/template-design.html --- a/docs/template-design.html Tue Nov 08 19:02:02 2005 +0000 +++ b/docs/template-design.html Tue Nov 08 19:04:00 2005 +0000 @@ -46,10 +46,13 @@ and to request that some operation be performed on those selected elements. Two common selector types are those concerning the addition and removal of elements.

    Selectors as Buttons

    In the collection elements example above, we saw the usage of a selector which could be used to add elements to a document:

    <input template:selector-field="add-hard-disk,hard-disk" type="submit" name="..." value="Add hard disk"/>

    This would produce the following HTML form control:

    As described in the "Using the XSLFormsResource API" document, the above selector (with the name add-hard-disk) -could be obtained and the associated collection of elements used to -insert new elements within the specified elements. Similarly, a +could be obtained in the application itself, and the collection of +elements associated with the selector used as a collection of places to +insert new elements into the form data document. Similarly, a selector which could be used to remove elements from a document could -be specified as follows:

    <input template:selector-field="remove-hard-disk" type="submit" name="..." value="Remove hard disk"/>

    This would produce the following HTML form control:

    Again, such a selector could be obtained and its associated elements removed from the document.

    Selectors as Checkboxes

    Whilst +be specified as follows:

    <input template:selector-field="remove-hard-disk" type="submit" name="..." value="Remove hard disk"/>

    This would produce the following HTML form control:

    Again, +such a selector could be obtained in the application, and the +associated elements could then be removed from the document.

    Selectors as Checkboxes

    Whilst selectors can be modelled conveniently with buttons, since they may cause an immediate update to the form data with feedback from the operation occurring immediately, other form controls can be used to @@ -58,7 +61,7 @@ document as being selected, with the application left to determine what kind of operation should be applied to the selection.

    Attribute Values

    A simple attribute value is defined to be a value, freely editable set in -an attribute on some element in a document. For example, in an XML document:

    <element attribute="value"/>

    The +an attribute on some element in a document. For example, in the form data document:

    <element attribute="value"/>

    The following sections describe ways in which the value can be viewed, edited or changed through the presentation of the attribute in the template.

    Editable Fields

    If we are to permit an attribute value to be edited, we might choose the following template representation:

    <input template:attribute-field="attribute" name="..." value="..." type="text"/>

    This would produce the following HTML form control:

    Note