1.1 --- a/docs/advanced.html Sat Sep 08 16:53:18 2007 +0000
1.2 +++ b/docs/advanced.html Sat Sep 08 16:53:34 2007 +0000
1.3 @@ -1,8 +1,8 @@
1.4 +<?xml version="1.0" encoding="iso-8859-1"?>
1.5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1.6 <html xmlns="http://www.w3.org/1999/xhtml"><head>
1.7 <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type" />
1.8 -
1.9 - <title>Advanced Template Design</title><meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.10 + <title>Advanced Template Design</title>
1.11 <link href="styles.css" rel="stylesheet" type="text/css" /></head>
1.12 <body>
1.13 <h1>Advanced Template Design</h1>
1.14 @@ -11,60 +11,47 @@
1.15 data documents (or just general XML documents with no special
1.16 connection to Web forms). However, since XSLForms templates build upon
1.17 XSL transformations, it is also possible to employ certain XSL
1.18 -techniques to present the information in various different ways.</p><h2>Templates and Transformations</h2><p>When prepared, XSLForms templates are converted to XSL stylesheets, and
1.19 -when form data is displayed, such XSL stylesheets are used to
1.20 +techniques to present the information in various different ways.</p><h2>Templates and Transformations</h2><p>When prepared, XSLForms templates are converted to XSL stylesheets, and
1.21 +when form data is displayed, such XSL stylesheets are used to
1.22 transform the form data to a representation which looks like the
1.23 original template, but with different parts of the template populated
1.24 -with the form data. The process can be illustrated as
1.25 -follows:</p><table style="text-align: left; width: 80%;" align="center" border="0" cellpadding="5" cellspacing="5">
1.26 -
1.27 +with the form data. The process can be illustrated as
1.28 +follows:</p>
1.29 +<table style="text-align: left; width: 80%;" align="center" border="0" cellpadding="5" cellspacing="5">
1.30 <tbody>
1.31 -
1.32 <tr>
1.33 -
1.34 -
1.35 -
1.36 <th style="border: 1px solid rgb(0, 0, 0); background-color: rgb(193, 255, 102); text-align: center; vertical-align: top;">Template<br />
1.37 -
1.38 <span class="method">A template presents the general form of the final output.</span></th>
1.39 -
1.40 <th style="border-style: solid; border-width: 1px; text-align: center; vertical-align: top;">Stylesheet<br />
1.41 -
1.42 <span class="method">Templates are converted to stylesheets, which are like programs specially designed to present XML information.</span></th>
1.43 -
1.44 <th style="border: 1px solid rgb(0, 0, 0); background-color: rgb(255, 204, 255); text-align: center; vertical-align: top;">Output<br />
1.45 -
1.46 <span class="method">The final output is produced when a stylesheet is combined with an XML document.</span></th>
1.47 -
1.48 </tr>
1.49 -
1.50 -
1.51 -
1.52 -
1.53 </tbody>
1.54 -</table><p>Since the stylesheet is based on XSL, which is a rich
1.55 +</table>
1.56 +<p>Since the stylesheet is based on XSL, which is a rich
1.57 language in its own right, advanced template design techniques can
1.58 involve some of the features of XSL - at least those which do not
1.59 affect the simplicity or general structure of our templates.</p><h2>Template Extension Functions and Variables</h2><p>One
1.60 area where XSL features are already employed to affect the final output
1.61 -in XSLForms is in the toolkit's use of template extension
1.62 +in XSLForms is in the toolkit's use of template extension
1.63 functions and special variables - the latter being used in the output
1.64 production process. For example, we might decide to use the lower level
1.65 -template functions to present the value of an attribute:</p><pre><span template:attribute="some-attribute" template:value="$this-value">xxx</span></pre><p>In the above example, we reference the special variable <code>$this-value</code> which refers to the value of <code>some-attribute</code>. An example of template functions in use looks like this:</p><pre><span id="{template:this-element()}">xxx</span></pre><p>In the above example, we invoke the template function <code>template:this-element</code>
1.66 +template functions to present the value of an attribute:</p><pre><span template:attribute="some-attribute" template:value="$this-value">xxx</span></pre><p>In the above example, we reference the special variable <code>$this-value</code> which refers to the value of <code>some-attribute</code>. An example of template functions in use looks like this:</p><pre><span id="{template:this-element()}">xxx</span></pre><p>In the above example, we invoke the template function <code>template:this-element</code>
1.67 in order to create a unique identifier in the final output. Since we
1.68 -use the function inside an attribute which is not prefixed with <code>template</code>, we must enclose the expression between <code>{</code> and <code>}</code> characters.</p><h2>Beyond Template Extension Functions</h2><p>Since
1.69 +use the function inside an attribute which is not prefixed with <code>template</code>, we must enclose the expression between <code>{</code> and <code>}</code> characters.</p><h2>Beyond Template Extension Functions</h2><p>Since
1.70 the above template extension functions and variables are merely special in the
1.71 sense that XSLForms provides them to produce its output, and since they
1.72 are accessed in the stylesheet using normal XSL-based mechanisms, there
1.73 is no technical barrier to using other kinds of valid XSL (or more
1.74 precisely, XPath) expressions in cases such as those given above. The
1.75 -rules for using such expressions in attributes are straightforward:</p><ul><li>Attributes prefixed with <code>template</code> can contain expressions as one would write them normally.</li><li>Other attributes must have their expressions enclosed between <code>{</code> and <code>}</code> characters so that the expression is evaluated and replaced with the result in the final output.</li></ul><p>Here is a trivial example of the usage of an XPath expression, based on one of the above examples:</p><pre><span template:attribute="some-attribute" template:value="string-length($this-value)">xxx</span></pre><p>In the above example, we invoke the standard XPath function <code>string-length</code> in order to produce within the <code>span</code> element the length of the value of <code>some-attribute</code> (instead of the actual value).</p><p>More
1.76 +rules for using such expressions in attributes are straightforward:</p><ul><li>Attributes prefixed with <code>template</code> can contain expressions as one would write them normally.</li><li>Other attributes must have their expressions enclosed between <code>{</code> and <code>}</code> characters so that the expression is evaluated and replaced with the result in the final output.</li></ul><p>Here is a trivial example of the usage of an XPath expression, based on one of the above examples:</p><pre><span template:attribute="some-attribute" template:value="string-length($this-value)">xxx</span></pre><p>In the above example, we invoke the standard XPath function <code>string-length</code> in order to produce within the <code>span</code> element the length of the value of <code>some-attribute</code> (instead of the actual value).</p><p>More
1.77 interesting applications of XPath expressions and non-XSLForms
1.78 functions arise when using more of the potential of XPath to select
1.79 arbitrary elements and attributes and to perform calculations on the
1.80 selected nodes. The following example originates from the Configurator
1.81 -example application:</p><pre><span template:value="sum(/configuration//*[@value-is-set]/@price) + sum(/configuration//*[@value = ../@value]/@price)"></span></pre><p>This complicated expression, to be inserted within the <code>span</code> element, finds all elements in the system configuration having the <code>value-is-set</code>
1.82 +example application:</p><pre><span template:value="sum(/configuration//*[@value-is-set]/@price) + sum(/configuration//*[@value = ../@value]/@price)"></span></pre><p>This complicated expression, to be inserted within the <code>span</code> element, finds all elements in the system configuration having the <code>value-is-set</code>
1.83 attribute and adds their prices together; this total is combined with
1.84 the sum of the prices from all elements marked as selected in their
1.85 respective lists. In other words, it gets the total of all selected
1.86 -components and inserts it into the final output.</p></body></html>
1.87 \ No newline at end of file
1.88 +components and inserts it into the final output.</p></body></html>