Package XSLForms :: Module Output
[show private | hide private]
[frames | no frames]

Module XSLForms.Output

XSL-based form templating.

Copyright (C) 2005, 2007 Paul Boddie <paul@boddie.org.uk>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA

Function Summary
  child_attribute(context, attribute_name, node_paths)
Exposed as {template:child-attribute(attribute_name, node_paths)}.
  child_element(context, element_name, position, node_paths)
Exposed as {template:child-element(element_name, position, node_paths)}.
  choice(context, value, true_string, false_string)
Exposed as {template:choice(value, true_string, false_string)}.
  element_path(context, field_names)
Exposed as {template:element-path(field_names)}.
  get_field_name(field_or_multi_name)
  i18n(context, value)
Exposed as {template:i18n(value)}.
  list_attribute(context, element_name, attribute_name)
Exposed as {template:list-attribute(element_name, attribute_name)}.
  multi_field_name(context, multivalue_name)
  new_attribute(context, name)
Exposed as {template:new-attribute(name)}.
  other_attributes(context, attribute_name, nodes)
Exposed as {template:other-attributes(name, nodes)}.
  other_elements(context, nodes)
Exposed as {template:other-elements(nodes)}.
  other_list_attributes(context, element_name, attribute_name, nodes)
Exposed as {template:other-list-attributes(element_name, attribute_name, nodes)}.
  other_multi_field_names(context, multivalue_name, nodes)
  path_to_context(context, attribute_ref, multivalue_name)
As a libxslt extension function, return a string containing the XSLForms path to the 'context' node, using the special "this-name" variable to complete the path if an attribute reference is required (as indicated by 'attribute_ref' being set to true).
  path_to_node(node, attribute_ref, name, multivalue)
Generate an XSLForms path to the given 'node', producing an attribute reference if 'attribute_ref' is true; for example: /package$1/discriminators$5/discriminator$1/category Otherwise an element reference is produced; for example: /package$1/discriminators$5/discriminator$1 Use the given 'name' to complete the path if an attribute reference is required (and if a genuine attribute is found at the context node - otherwise 'name' will be None and the context node will be treated like an attribute).
  selector_name(context, field_name, nodes)
Exposed as {template:selector-name(field_name, nodes)}.
  this_attribute(context)
Exposed as {template:this-attribute()}.
  this_element(context)
Exposed as {template:this-element()}.
  url_encode(context, nodes, charset)
Exposed as {template:url-encode(nodes)}.
  xslforms_range(context, range_spec)
Exposed as {template:range(range_spec)}.

Variable Summary
str libxml2_encoding = 'utf-8'

Function Details

child_attribute(context, attribute_name, node_paths)

Exposed as {template:child-attribute(attribute_name, node_paths)}.

Provides a relative path to the specifed 'attribute_name' for each element
specified in 'node_paths' (provided by calls to other extension functions in
the template). For example:

template:child-attribute('value', template:this-element()) -> '.../value'

child_element(context, element_name, position, node_paths)

Exposed as {template:child-element(element_name, position, node_paths)}.

Provides relative paths to the specifed 'element_name', having the given
'position' (1-based) under each element specified in 'node_paths' (provided
by calls to other extension functions in the template). For example:

template:child-element('comment', 1, template:this-element()) -> '.../comment$1'

choice(context, value, true_string, false_string=None)

Exposed as {template:choice(value, true_string, false_string)}.

Using the given boolean 'value', which may itself be an expression evaluated
by the XSLT processor, return the 'true_string' if 'value' is true or the
'false_string' if 'value' is false. If 'false_string' is omitted and if
'value' evaluates to a false value, an empty string is returned.

element_path(context, field_names)

Exposed as {template:element-path(field_names)}.

Convert the given 'field_names' back to XPath references.
For example:

/configuration$1/details$1/base-system$$value -> /*[position() = 1]/*[position() = 1]/base-system

If more than one field name is given - ie. 'field_names' contains a
comma-separated list of names - then only the first name is used.

To use this function effectively, use the result of another function as the
argument. For example:

template:element-path(template:this-element())
template:element-path(template:other-elements(matches))
template:element-path(template:other-elements(..))

i18n(context, value)

Exposed as {template:i18n(value)}.

Provides a translation of the given 'value' using the 'translations' and
'locale' variables defined in the output stylesheet. The 'value' may be a
string or a collection of nodes, each having a textual value, where such
values are then concatenated to produce a single string value.

list_attribute(context, element_name, attribute_name)

Exposed as {template:list-attribute(element_name, attribute_name)}.

Provides a reference to one or many elements of the given 'element_name'
found under the current element in the form data structure having
attributes with the given 'attribute_name'.

new_attribute(context, name)

Exposed as {template:new-attribute(name)}.

Provides a reference to a new attribute of the given 'name' on the current
element in the form data structure.

other_attributes(context, attribute_name, nodes)

Exposed as {template:other-attributes(name, nodes)}.

Provides a reference to attributes in the form data structure of the given
'attribute_name' residing on the specified 'nodes' (described using an XPath
expression in the template).

other_elements(context, nodes)

Exposed as {template:other-elements(nodes)}.

Provides a reference to other elements in the form data structure according
to the specified 'nodes' parameter (an XPath expression in the template).

other_list_attributes(context, element_name, attribute_name, nodes)

Exposed as {template:other-list-attributes(element_name, attribute_name, nodes)}.

Provides a reference to other elements in the form data structure, found
under the specified 'nodes' (described using an XPath expression in the
template) having the given 'element_name' and bearing attributes of the
given 'attribute_name'.

path_to_context(context, attribute_ref, multivalue_name=None)

As a libxslt extension function, return a string containing the XSLForms
path to the 'context' node, using the special "this-name" variable to
complete the path if an attribute reference is required (as indicated by
'attribute_ref' being set to true). If 'multivalue_name' is set, produce a
reference to a multivalued field using the given string as the attribute
name.

path_to_node(node, attribute_ref, name, multivalue=0)

Generate an XSLForms path to the given 'node', producing an attribute
reference if 'attribute_ref' is true; for example:

/package$1/discriminators$5/discriminator$1/category

Otherwise an element reference is produced; for example:

/package$1/discriminators$5/discriminator$1

Use the given 'name' to complete the path if an attribute reference is
required (and if a genuine attribute is found at the context node -
otherwise 'name' will be None and the context node will be treated like an
attribute).

If 'multivalue' is true and 'attribute_ref' is set, produce an attribute
reference using the given 'name':

/package$1/categories$1/category$$name

If 'multivalue' is true and 'attribute_ref' is not set, produce an attribute
reference using the given 'name' of form (element, attribute):

/package$1/categories$1/element$$attribute

selector_name(context, field_name, nodes)

Exposed as {template:selector-name(field_name, nodes)}.

Provides a selector field name defined using 'field_name' and referring to
the given 'nodes'. For example:

template:selector-name('add-platform', package/platforms) -> 'add-platform=/package$1/platforms$1'

NOTE: The 'nodes' must be element references.

this_attribute(context)

Exposed as {template:this-attribute()}.

Provides a reference to the current attribute in the form data structure.

this_element(context)

Exposed as {template:this-element()}.

Provides a reference to the current element in the form data structure.

url_encode(context, nodes, charset='utf-8')

Exposed as {template:url-encode(nodes)}.

Provides a "URL encoded" string created from the merged textual contents of
the given 'nodes', with the encoded character values representing characters
in the optional 'charset' (UTF-8 if not specified). Note that / and #
characters are replaced with their "URL encoded" character values.

If a string value is supplied for 'nodes', this will be translated instead.

template:url-encode(./text(), 'iso-8859-1')

xslforms_range(context, range_spec)

Exposed as {template:range(range_spec)}.

The 'range_spec' is split up into 'start', 'finish' and 'step' according to
the following format:

start...finish...step

Provides the Python range function by producing a list of numbers, starting
at 'start', ending one step before 'finish', and employing the optional
'step' to indicate the magnitude of the difference between successive
elements in the list as well as the "direction" of the sequence. By default,
'step' is set to 1.

NOTE: This uses a single string because template:element and other
NOTE: annotations use commas to separate fields, thus making the usage of
NOTE: this function impossible if each range parameter is exposed as a
NOTE: function parameter.
NOTE: The returning of values from this function is not fully verified, and
NOTE: it is probably better to use other extension functions instead of this
NOTE: one to achieve simple results (such as str:split from EXSLT).

Variable Details

libxml2_encoding

Type:
str
Value:
'utf-8'                                                                

Generated by Epydoc 2.1 on Wed Jun 6 01:27:25 2007 http://epydoc.sf.net