XSLTools

Annotated docs/reference.html

607:fb25bbeaabc5
2007-07-07 paulb [project @ 2007-07-07 21:22:07 by paulb] Fixed licensing references.
paulb@283 1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
paulb@283 2
<html xmlns="http://www.w3.org/1999/xhtml"><head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type" /><title>Template Attribute Reference</title>
paulb@283 3
<meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" /> <link href="styles.css" rel="stylesheet" type="text/css" /></head>
paulb@283 4
<body><h1>Template Attribute Reference</h1>
paulb@283 5
<p>This document presents each of the attributes used in
paulb@283 6
templates to annotate the structure of the XML documents being
paulb@440 7
presented and to modify the final output of the presented document.</p><h2>Basic Annotations</h2><p>The annotation attributes in this section are the most basic of those available. Apart from <code>template:element</code> and <code>template:i18n</code>, it is usually preferable to use the annotations listed in the "Convenience Annotations" section below.</p><h3><a name="element"></a>template:element</h3><p>This
paulb@287 8
attribute associates the template element on which it is used with an
paulb@287 9
element from the XML document being presented. Matching elements are
paulb@287 10
found from the&nbsp;current position (or context), where the position
paulb@393 11
is updated upon entering a template element with a <code>template:element</code> or&nbsp;<code>template:attribute</code> annotation.</p><p>Example:</p><pre>&lt;p template:element="item"&gt;<br />  For each item element found, this section is produced.<br />  &lt;span template:element="subitem"&gt;<br />    For each subitem element found within an item element, this is produced.<br />  &lt;/span&gt;<br />  &lt;span template:element="other"&gt;<br />    This is produced for each other element found within an item element.<br />  &lt;/span&gt;<br />&lt;/p&gt;</pre><p>Example:</p><pre>&lt;p template:element="first,second,third"&gt;<br />  For each third element found, this section is produced.<br />&lt;/p&gt;</pre><p>Syntax:</p><pre>element-name1[,element-name2[,...]]</pre><p>Related attributes:</p><ul><li><code>template:init</code></li></ul><h3><a name="attribute"></a>template:attribute</h3><p>This attribute associates the template element on which it is used with an attribute in the XML document being presented.</p><p>Example:</p><pre>&lt;p template:element="item"&gt;<br />  &lt;span template:attribute="value"&gt;<br />    This section is associated with the value attribute of the item element.<br />    To be really useful, we should also use other annotations to produce the value of the attribute.<br />  &lt;/span&gt;<br />&lt;/p&gt;</pre><p>Syntax:</p><pre>attribute-name</pre><p>Related attributes:</p><ul><li><code>template:value</code></li><li><code>template:attribute-field</code></li><li><code>template:attribute-button</code></li><li><code>template:attribute-area</code></li><li><code>template:attribute-list-button</code></li></ul><h3><a name="value"></a>template:value</h3><p>This attribute produces, in the final output, the value of part of the XML document being presented.</p><p>Example:</p><pre>&lt;p template:element="item"&gt;<br />  &lt;span template:attribute="value" template:value="$this-value"&gt;<br />    This text will be replaced by the value of the attribute, but the span template element will remain.<br />  &lt;/span&gt;<br />&lt;/p&gt;</pre><p>Example:</p><pre>&lt;p template:element="item"&gt;<br />  &lt;span template:attribute="value" template:value="$this-value" template:effect="replace"&gt;<br />    This text and its enclosing span element will be replaced by the value of the attribute.<br />  &lt;/span&gt;<br />&lt;/p&gt;</pre><p>Syntax:</p><pre>XPath-expression</pre><p>Here, the underlying XPath mechanisms are exposed, but a number of useful shortcuts are available:</p><ul><li><code>$this-value</code>&nbsp;produces the value of the current position&nbsp;(or context) in the XML document being presented.</li><li><code>template:this-attribute()</code>&nbsp;produces a reference to the&nbsp;current&nbsp;attribute&nbsp;(or context).</li></ul>Other XPath expressions can be used to navigate from the current position to other nodes in the XML document.<p>Related attributes:</p><ul><li><code>template:effect</code></li></ul><h3><a name="effect"></a>template:effect</h3><p>This attribute modifies the effect of a&nbsp;<code>template:value</code> annotation.</p><p>Example:</p><p>(See above.)</p><p>Syntax:</p><pre><span style="font-weight: bold;">insert</span>|<span style="font-weight: bold;">replace</span></pre><p>Related attributes:</p><ul><li><code>template:effect</code></li><li><code>template:attribute-area</code></li></ul><h3><a name="if"></a>template:if</h3><p>This
paulb@287 12
attribute permits the inclusion of a section of the template document
paulb@287 13
according to a test performed on the XML document being presented.</p><p>Example:</p><pre>&lt;p template:if="@value = 'true'"&gt;<br />  If the value attribute is set to the string value 'true', include this section.<br />&lt;/p&gt;</pre><p>Syntax:</p><pre>XPath-expression</pre><p>Here,
paulb@287 14
the underlying XPath mechanisms are exposed, and any XPath expression
paulb@444 15
which tests aspects of the XML document can be written.</p><h3><a name="i18n"></a>template:i18n</h3><p>This
paulb@440 16
attribute is used to translate the textual contents of an element to
paulb@440 17
another language where additional parameters specifying the language
paulb@440 18
and the whereabouts of the translations have been provided to the
paulb@527 19
stylesheet in the output generation process.</p><p>Example:</p><pre>&lt;span template:i18n="-"&gt;Hello&lt;/span&gt;</pre><p>In this example, the contents of the&nbsp;<code>span</code> element would be replaced with an appropriate translation for the text&nbsp;<code>Hello</code><span></span>.</p><p>Example:</p><pre>&lt;span template:i18n="hello"&gt;Hello&lt;/span&gt;</pre><p>In this example, the contents of the <code>span</code> element would be replaced with an appropriate translation using the token <code>hello</code><span></span> as a key in the translation dictionary.</p><p>Example:</p><pre>&lt;span template:i18n="{$this-value}"&gt;Hello&lt;/span&gt;</pre><p>In this example, the value of the special template variable&nbsp;<code>$this-value</code> is used as a key in the translation dictionary.</p><p>Syntax:</p><pre><span style="font-weight: bold;">-</span>|<span style="font-weight: bold;">{</span>expression<span style="font-weight: bold;">}</span>|token</pre><p>See the <a href="internationalisation.html">"Internationalisation"</a> document for more information on this attribute.</p><h2>Initialisation Annotations</h2><p>The annotation attributes in this section control the initialisation of documents where this is done by the XSLForms toolkit.</p><h3><a name="init"></a>template:init</h3><p>This attribute controls the creation of elements in the initialisation process and is used together with&nbsp;<code>template:element</code>. For each element name listed in a&nbsp;<code>template:element</code> annotation, the corresponding value in a&nbsp;<code>template:init</code> annotation states whether or how such elements are to be initialised.</p><p>Example:</p><pre>&lt;p template:element="item" template:init="no"&gt;<br />  Such item elements will not be created automatically when the document is initialised.<br />&lt;/p&gt;</pre><p>Example:</p><pre>&lt;p template:element="first,second,third" template:init="yes,yes,no"&gt;<br />  The first and second elements will be created automatically when the document is initialised.<br />  No third elements will be created automatically when the document is initialised.<br />&lt;/p&gt;</pre><p>Syntax:</p><pre><span style="font-weight: bold;">yes</span>|<span style="font-weight: bold;">no</span>|<span style="font-weight: bold;">auto</span>[,<span style="font-weight: bold;">yes</span>|<span style="font-weight: bold;">no</span>|<span style="font-weight: bold;">auto</span>[,...]]</pre><p>Here,&nbsp;<code>yes</code> means that an element will be created automatically,&nbsp;<code>no</code> means that an element will not be created automatically (relying on the existence of such elements from before), and&nbsp;<code>auto</code>
paulb@287 20
means that the initialisation process will attempt to guess whether an
paulb@287 21
element should be created automatically (by looking for selectors which
paulb@287 22
use the element's name and only creating elements where no such
paulb@287 23
selectors could be found). Where no values are provided,&nbsp;<code>auto</code> is assumed.</p><p>Related attributes:</p><ul><li><code>template:element</code></li></ul><h2>Convenience Annotations</h2><p>The
paulb@287 24
annotation attributes in this section provide more convenient ways of
paulb@393 25
presenting the XML document information in the final output.</p><h3><a name="attribute-field"></a>template:attribute-field</h3><p>This
paulb@287 26
attribute associates the template element on which it is used with an
paulb@287 27
attribute from the XML document, whilst providing certain other
paulb@393 28
attributes in the final output:</p><ul><li>The&nbsp;<code>name</code> attribute is used to identify the location of the attribute in the XML document being presented.</li><li>The&nbsp;<code>value</code> attribute is used to present the value of the attribute from the XML document.</li></ul><p>Example:</p><pre>&lt;input template:attribute-field="name" name="..." value="..." type="text"/&gt;</pre><p>This would be output as follows:</p><pre>&lt;input name="path-to-name" value="value-of-name" type="text"/&gt;</pre><p>...where&nbsp;<code>path-to-name</code> and&nbsp;<code>value-of-name</code> would be replaced with the appropriate computed values.</p><p>Syntax:</p><pre>attribute-name</pre><p>Related attributes:</p><ul><li><code>template:attribute-area</code></li><li><code>template:attribute-button</code></li></ul><p>Implementing attributes:</p><ul><li><code>template:attribute</code></li></ul><h3><a name="attribute-area"></a>template:attribute-area</h3><p>This
paulb@287 29
attribute associates the template element on which it is used with an
paulb@287 30
attribute from the XML document being presented, much in the way
paulb@287 31
that&nbsp;<code>template:attribute-field</code> does. However, the
paulb@287 32
attribute value is not inserted into an attribute in the final output;
paulb@287 33
instead it is inserted into the output in a different way according to
paulb@393 34
additional information specified in the annotation.</p><p>Example:</p><pre>&lt;textarea template:attribute-area="name" name="..." cols="40" rows="5"&gt;<br />  This text will be replaced by the value of the name attribute from the document being presented.<br />  The textarea element will enclose the attribute value in the final output.<br />&lt;/textarea&gt;</pre><p>Example:</p><pre>&lt;p&gt;<br />  The name is:<br />  &lt;span&nbsp;template:attribute-area="name,replace"&gt;<br />    This text will be replaced in the final output, and the span element will not be reproduced.<br />  &lt;/span&gt;<br />&lt;/p&gt;</pre><p>Syntax:</p><pre>attribute-name[,<span style="font-weight: bold;">insert</span>|<span style="font-weight: bold;">replace</span>]</pre><p>By default, the value of&nbsp;<code>attribute-name</code> is inserted within the template element on which the annotation appears, and this is equivalent to specifying&nbsp;<code>insert</code>. If&nbsp;<code>replace</code> is specified, the template element is entirely replaced by the value of&nbsp;<code>attribute-name</code>.</p><p>Related attributes:</p><ul><li><code>template:attribute-field</code></li></ul><p>Implementing attributes:</p><ul><li><code>template:attribute</code></li></ul><h3><a name="attribute-button"></a>template:attribute-button</h3><p>This attribute associates the template element on which it is used
paulb@287 35
with an attribute from the XML document, whilst providing certain other
paulb@393 36
attributes in the final output, much like&nbsp;<code>template:attribute-field</code> does, but with features which make the presentation of buttons and related user interface controls much simpler:</p><ul><li>The&nbsp;<code>name</code> attribute is used to identify the location of the attribute in the XML document being presented.</li><li>The&nbsp;<code>value</code> attribute is used to present a specified value associated with the button being activated.</li><li>An additional named attribute is used to indicate whether the button was activated or set.</li></ul><p>Example:</p><pre>&lt;input template:attribute-button="question-type,text,checked" name="..." value="..." type="radio"/&gt;</pre><p>This would produce a "radio" button like the following:</p><pre>&lt;input name="path-to-question-type" value="text" type="radio"/&gt;</pre><p>If the value of&nbsp;<code>question-type</code> was set to text, output like the following would be produced:</p><pre>&lt;input name="path-to-question-type" value="text" type="radio" checked="checked"/&gt;</pre><p>In an XHTML document, this would cause the "radio" button to appear selected or activated.</p><p>Syntax:</p><pre>attribute-name,attribute-value,attribute-to-create-when-set</pre><p>Related attributes:</p><ul><li><code>template:attribute-field</code></li><li><code>template:attribute-list-button</code></li></ul><p>Implementing attributes:</p><ul><li><code>template:attribute</code></li><li><code>template:expr</code></li><li><code>template:expr-attr</code></li></ul><h3><a name="selector-field"></a>template:selector-field</h3><p>This
paulb@287 37
attribute permits the definition of references to the parts of the XML
paulb@287 38
document being presented which are associated with the template
paulb@287 39
elements in which it is used. When used in certain HTML form-related
paulb@287 40
elements, it becomes possible to receive and obtain such references
paulb@287 41
from the XSLForms toolkit and to then access the selected parts of the
paulb@287 42
original document.</p><p>Example:</p><pre>&lt;p template:element="item"&gt;<br />  &lt;input template:selector-field="remove" name="..." value="Remove this item" type="submit"/&gt;<br />&lt;/p&gt;</pre><p>Example:</p><pre>&lt;p template:element="item"&gt;<br />  An item...<br />&lt;/p&gt;<br />&lt;input template:selector-field="add,item" name="..." value="Add item" type="submit"/&gt;</pre><p>Syntax:</p><pre>selector-name[,element-name]</pre><p>The
paulb@287 43
optional element name can be used to associate the selector with other
paulb@287 44
elements; when this is done, the initialisation of the XML document
paulb@287 45
will be affected such that the named element will not be automatically
paulb@287 46
created in the initialisation process, since the presence of the
paulb@287 47
selector implies that such elements can be added and removed in the
paulb@393 48
application user interface.</p><p>Related attributes:</p><ul><li><code>template:element</code></li></ul><h2>Multiple-choice Annotations</h2><p>The annotation attributes in this section provide ways of presenting enumerations and selections of values.</p><h3><a name="multiple-choice-field"></a>template:multiple-choice-field</h3><p>This
paulb@287 49
attribute associates the template element on which it is used with an
paulb@287 50
attribute in the XML document being presented whose value is to be
paulb@287 51
chosen from a list of possibilities. The list itself is represented by
paulb@287 52
a list of elements, each having an attribute with a&nbsp;distinct
paulb@287 53
value;&nbsp;such information is added in the initialisation of the
paulb@287 54
document before it is presented, since it is not part of the
paulb@467 55
"essential" information in the document.</p><p>Example:</p><pre>&lt;select template:multiple-choice-field="base-system,value" name="..."&gt;<br />  ...<br />&lt;/select&gt;</pre><p>Example:</p><pre>&lt;select template:multiple-choice-field="-,question-type" name="..."&gt;<br />  ...<br />&lt;/select&gt;</pre><p>See below for an example combining this attribute with the <code>template:multiple-choice-value</code> attribute.</p><p>Syntax:</p><pre>element-name|<span style="font-weight: bold;">-</span>,attribute-name[,<span style="font-weight: bold;">new</span>|,<span style="font-weight: bold;">new</span>,<span style="font-weight: bold;">dynamic</span>|,,<span style="font-weight: bold;">dynamic</span>]</pre><p>Where the special value&nbsp;<code>-</code>
paulb@287 56
is given as the element name, the context element is chosen as the
paulb@287 57
element in the XML document being presented whose attribute is
paulb@467 58
involved. Where the optional parameter&nbsp;<code>new</code> is given, the attribute is assumed not to already exist on the element. Where the optional parameter&nbsp;<code>dynamic</code> is given, the source of the multiple-choice values is considered to be found dynamically rather than from another document.</p><p>Related attributes:</p><ul><li><code>template:multiple-choice-value</code></li><li><code>template:multiple-choice-list-field</code></li></ul><p>Implementing attributes:</p><ul><li><code>template:element</code></li><li><code>template:attribute</code></li></ul><h3><a name="multiple-choice-value"></a>template:multiple-choice-value</h3><p>This
paulb@287 59
attribute associates the template element on which it is used with an
paulb@287 60
element in the XML document being presented whose purpose is to hold
paulb@428 61
one of a list of selectable values (as described above).</p><p>Example:</p><pre>&lt;select template:multiple-choice-field="base-system,value" name="..."&gt;<br />  &lt;option template:multiple-choice-value="base-system-enum,value,selected" value="..."/&gt;<br />&lt;/select&gt;</pre><p>This presents the following document fragment:</p><pre>&lt;base-system value="c"&gt;<br />  &lt;base-system-enum value="a"/&gt;<br />  &lt;base-system-enum value="b"/&gt;<br />  &lt;base-system-enum value="c"/&gt;<br />&lt;/base-system&gt;</pre><p>The output from the combination of the above would be as follows:</p><pre>&lt;select name="path-to-base-system"&gt;<br />  &lt;option value="a"&gt;a&lt;/option&gt;<br />  &lt;option value="b"&gt;b&lt;/option&gt;<br />  &lt;option value="c" selected="selected"&gt;c&lt;/option&gt;<br />&lt;/select&gt;</pre><h4>Values and Labels</h4><p>Labels different from the actual values employed can be specified using an extra parameter in the annotation:</p><pre>&lt;select template:multiple-choice-field="base-system,value" name="..."&gt;<br />  &lt;option template:multiple-choice-value="base-system-enum,value,selected,text()" value="..."/&gt;<br />&lt;/select&gt;</pre><p>This
paulb@428 62
additional parameter is an XPath expression whose context is the
paulb@428 63
current value-bearing element. The above example selects the text from
paulb@428 64
inside each&nbsp;<code>base-system-enum</code> element in the modified document fragment presented below.</p><p>A modified document fragment providing the labels can be written as follows:</p><pre>&lt;base-system value="c"&gt;<br />  &lt;base-system-enum value="a"&gt;A&lt;/base-system-enum&gt;<br />  &lt;base-system-enum value="b"&gt;B&lt;/base-system-enum&gt;<br />  &lt;base-system-enum value="c"&gt;C&lt;/base-system-enum&gt;<br />&lt;/base-system&gt;</pre><p>The output from the modified combination would be as follows:</p><pre>&lt;select name="path-to-base-system"&gt;<br />  &lt;option value="a"&gt;A&lt;/option&gt;<br />  &lt;option value="b"&gt;B&lt;/option&gt;<br />  &lt;option value="c" selected="selected"&gt;C&lt;/option&gt;<br />&lt;/select&gt;</pre><p>Syntax:</p><pre>list-element-name,list-attribute-name,attribute-to-create-when-selected[,content-expression]</pre><p>Related attributes:</p><ul><li><code>template:multiple-choice-field</code></li><li><code>template:multiple-choice-list-value</code></li></ul><p>Implementing attributes:</p><ul><li><code>template:element</code></li><li><code>template:expr</code></li><li><code>template:expr-attr</code></li><li><code>template:value</code></li></ul><h3><a name="multiple-choice-list-field"></a>template:multiple-choice-list-field</h3><p>This attribute is similar to&nbsp;<code>template:multiple-choice-field</code>
paulb@287 65
except that it associates the template element on which it is used with
paulb@287 66
an element in the XML document being presented containing a list
paulb@287 67
of&nbsp;elements whose values have been selected. This list of selected
paulb@287 68
elements is expanded before presentation to include elements whose
paulb@287 69
values have not been selected. Consequently, the selected elements are
paulb@287 70
marked in a particular way to distinguish them from the non-selected
paulb@467 71
elements.</p><p>Example:</p><pre>&lt;select template:multiple-choice-list-field="question-types,question-type-enum,question-type" name="..." multiple="multiple"&gt;<br />  ...<br />&lt;/select&gt;</pre><p>See below for an example combining this attribute with the <code>template:multiple-choice-list-value</code> attribute.</p><p>Syntax:</p><pre>element-name|<span style="font-weight: bold;">-</span>,list-element-name,list-attribute-name[,<span style="font-weight: bold;">dynamic</span>]</pre><p>Here,&nbsp;<code>element-name</code> is the element in the document being presented which contains the selected value elements; if the special value&nbsp;<code>-</code> is given then the context element is the element containing the selected value elements. The&nbsp;<code>list-element-name</code> and&nbsp;<code>list-attribute-name</code> indicate the details of the elements providing the list of selectable values.&nbsp;Where the optional parameter&nbsp;<code>dynamic</code> is given, the source of the multiple-choice values is considered to be found dynamically rather than from another document.</p><p>Related attributes:</p><ul><li><code>template:multiple-choice-list-value</code></li><li><code>template:multiple-choice-list-element</code></li><li><code>template:multiple-choice-field</code></li></ul><p>Implementing attributes:</p><ul><li><code>template:element</code></li></ul><h3><a name="multiple-choice-list-value"></a>template:multiple-choice-list-value</h3><p>This attribute is similar to&nbsp;<code>template:multiple-choice-value</code>
paulb@287 72
in that it associates the template element on which it is used with an
paulb@287 73
element holding a value in a list of selectable values, with the
paulb@287 74
principal difference that potentially many such values may be selected
paulb@428 75
in this case.</p><p>Example:</p><pre>&lt;select template:multiple-choice-list-field="question-types,question-type-enum,question-type" multiple="multiple"&gt;<br />  &lt;option template:multiple-choice-list-value="question-type-enum,question-type,selected" value="..."/&gt;<br />&lt;/select&gt;</pre><p>This presents the following document fragment:</p><pre>&lt;question-types&gt;<br />  &lt;question-type-enum question-type="text"/&gt;<br />  &lt;question-type-enum question-type="choice" value-is-set="true"/&gt;<br />  &lt;question-type-enum question-type="special" value-is-set="true"/&gt;<br />&lt;/question-types&gt;</pre><p>The output from the combination of the above would be as follows:</p><pre>&lt;select name="path-to-question-types" multiple="multiple"&gt;<br />  &lt;option value="text"&gt;text&lt;/option&gt;<br />  &lt;option value="choice" selected="selected"&gt;choice&lt;/option&gt;<br />  &lt;option value="special" selected="selected"&gt;special&lt;/option&gt;<br />&lt;/select&gt;</pre><h4>Values and Labels</h4><p>Labels different from the actual values employed can be specified using an extra parameter in the annotation:</p><pre>&lt;select template:multiple-choice-list-field="question-types,question-type-enum,question-type" multiple="multiple"&gt;<br />  &lt;option template:multiple-choice-list-value="question-type-enum,question-type,selected,text()" value="..."/&gt;<br />&lt;/select&gt;</pre><p>This additional parameter is an XPath expression whose context is
paulb@428 76
the current value-bearing element. The above example selects the text
paulb@428 77
from inside each&nbsp;<code>base-system-enum</code> element in the modified document fragment presented below.</p><p>A modified document fragment providing the labels can be written as follows:</p><pre>&lt;question-types&gt;<br />  &lt;question-type-enum question-type="text"&gt;Text&lt;/question-type-enum&gt;<br />  &lt;question-type-enum question-type="choice" value-is-set="true"&gt;Choice&lt;/question-type-enum&gt;<br />  &lt;question-type-enum question-type="special" value-is-set="true"&gt;Special&lt;/question-type-enum&gt;<br />&lt;/question-types&gt;</pre><p>The output from the modified combination would be as follows:</p><pre>&lt;select name="path-to-question-types" multiple="multiple"&gt;<br />  &lt;option value="text"&gt;Text&lt;/option&gt;<br />  &lt;option value="choice" selected="selected"&gt;Choice&lt;/option&gt;<br />  &lt;option value="special" selected="selected"&gt;Special&lt;/option&gt;<br />&lt;/select&gt;</pre><p>Syntax:</p><pre>list-element-name,list-attribute-name,attribute-to-create-when-selected[,content-expression]</pre><p>Related attributes:</p><ul><li><code>template:multiple-choice-list-field</code></li><li><code>template:multiple-choice-value</code></li></ul><p>Implementing attributes:</p><ul><li><code>template:element</code></li><li><code>template:expr</code></li><li><code>template:expr-attr</code></li><li><code>template:value</code></li></ul><h3><a name="multiple-choice-list-element"></a>template:multiple-choice-list-element</h3><p>This attribute works in much the same way as <code>template:multiple-choice-list-field</code> except that it does not add a&nbsp;<code>name</code> attribute to the template element on which it is used. The purpose of this attribute, along with&nbsp;<code>template:attribute-list-button</code>, is to provide an alternative approach to presenting lists of selectable values.</p><p>Example:</p><pre>&lt;p template:multiple-choice-list-element="question,question-types,question-type"&gt;<br />  ...<br />&lt;/p&gt;</pre><p>See below for an example combining this attribute with the <code>template:attribute-list-button</code> attribute.</p><p>Syntax:</p><pre>element-name|<span style="font-weight: bold;">-</span>,list-element-name,list-attribute-name</pre><p>Here,&nbsp;<code>element-name</code> is the element in the document being presented which contains the selected value elements; if the special value&nbsp;<code>-</code> is given then the context element is the element containing the selected value elements. The&nbsp;<code>list-element-name</code> and&nbsp;<code>list-attribute-name</code> indicate the details of the elements providing the list of selectable values.</p><p>Related attributes:</p><ul><li><code>template:multiple-choice-list-field</code></li><li><code>template:attribute-list-button</code></li></ul><p>Implementing attributes:</p><ul><li><code>template:element</code></li></ul><h3><a name="attribute-list-button"></a>template:attribute-list-button</h3><p>This attribute works in much the same way as&nbsp;<code>template:attribute-button</code>
paulb@287 78
does, but instead presents a button or related user interface control
paulb@287 79
whose state reflects the presence of an attribute on an element in a
paulb@287 80
collection of elements.</p><p>Example:</p><pre>&lt;p template:multiple-choice-list-element="question,question-types,question-type"&gt;<br />  &lt;input template:attribute-list-button="question-type,checked" name="..." value="..." type="checkbox"/&gt;<br />&lt;/p&gt;</pre><p>Given an XML document like this...</p><pre>&lt;question&gt;<br />  &lt;question-types question-type="text" value-is-set="true"/&gt;<br />  &lt;question-types question-type="choice"/&gt;<br />&lt;/question&gt;</pre><p>...the following would be produced as output:</p><pre>&lt;p&gt;<br />  &lt;input name="path-to-question-type" value="text" type="checkbox" checked="checked"/&gt;<br />&lt;/p&gt;<br />&lt;p&gt;<br />  &lt;input name="path-to-question-type" value="choice" type="checkbox"/&gt;<br />&lt;/p&gt;</pre><p>Syntax:</p><pre>attribute-name,attribute-to-create-when-set</pre><p>Related attributes:</p><ul><li><code>template:multiple-choice-list-element</code></li><li><code>template:attribute-button</code></li></ul><p>Implementing attributes:</p><ul><li><code>template:attribute</code></li><li><code>template:expr</code></li><li><code>template:expr-attr</code></li></ul><h2>Internal Annotations</h2><p>The special annotations&nbsp;<code>template:expr</code> and&nbsp;<code>template:expr-attr</code>
paulb@287 81
are used respectively to test an XPath expression in the current
paulb@287 82
context and to provide the name of an attribute which is to be created
paulb@557 83
in the final output, should the expression evaluate to a true value.</p><h2>Housekeeping Annotations</h2><p>In order to support explicit, additional namespaces in output document processing, the special&nbsp;<code>expr-prefix</code>
paulb@557 84
attribute can be used to ensure the presence of a namespace declaration
paulb@557 85
in the generated stylesheet files. Consider the usage of various
paulb@557 86
stylesheet extension functions:</p><pre>&lt;body&gt;<br />  &lt;p&gt;<br />    &lt;span template:value="sum(str:split('1 2 3 4 5'))"&gt;result&lt;/span&gt;<br />  &lt;/p&gt;<br />&lt;/body&gt;</pre><p>For the stylesheet which produces the output, the&nbsp;<code>str</code>
paulb@557 87
namespace will need to be declared somewhere. To do this, we must not
paulb@557 88
only declare the namespace in the template document, but we must also
paulb@557 89
provide a hint to the stylesheet processor that the namespace is
paulb@557 90
important (even though it is only mentioned in the text of an
paulb@557 91
attribute, which might persuade some XML processing toolkits to abandon
paulb@557 92
the namespace declaration).</p><pre>&lt;body xmlns:str="http://exslt.org/strings" str:expr-prefix="str http://exslt.org/strings"&gt;<br />  &lt;p&gt;<br />    &lt;span template:value="sum(str:split('1 2 3 4 5'))"&gt;result&lt;/span&gt;<br />  &lt;/p&gt;<br />&lt;/body&gt;</pre><p>What the special <code>expr-prefix</code>
paulb@557 93
attribute does is to provide that hint to the stylesheet processor,
paulb@557 94
although XSLTools also uses the attribute for other internal purposes.
paulb@557 95
Consequently, the resulting output stylesheet is able to find the&nbsp;<code>str:split</code> extension function and to evaluate the expected result.</p><h3>Fixing Annotations</h3><p>One important application of the <code>expr-prefix</code>
paulb@557 96
attribute is the restoration of damaged attributes after the editing of
paulb@557 97
a template document using a less than careful HTML editor. Consider the
paulb@557 98
above document fragment after a small edit in Nvu:</p><pre>&lt;body expr-prefix="str http://exslt.org/strings" str="http://exslt.org/strings"&gt;<br />  &lt;p&gt;<br />    &lt;span value="sum(str:split('1 2 3 4 5'))"&gt;result!&lt;/span&gt;<br />  &lt;/p&gt;<br />&lt;/body&gt;</pre><p>Nvu has obviously decided to remove the&nbsp;<code>str</code> and&nbsp;<code>template</code> namespace prefixes. To revert this damage, a tool is provided with XSLTools called&nbsp;<code>xslform_fix.py</code> (found in the&nbsp;<code>scripts</code> directory in the source distribution), and this tool will attempt to re-add namespace declarations for&nbsp;<code>template</code> automatically (since the <code>template</code>&nbsp;namespace is obviously the basis of XSLForms) along with any namespaces declared using&nbsp;<code>expr-prefix</code> attributes. The tool is invoked as follows:</p><pre>xslform_fix.py template.xhtml template_fixed.xhtml</pre><p>Since
paulb@557 99
namespace declarations may be moved to the root element of the new
paulb@557 100
template document, it is possible that some problems may result
paulb@557 101
with&nbsp;documents using namespaces in advanced ways, but the tool
paulb@557 102
should provide a reasonable solution for most documents.</p></body></html>