| Page 1 |
Any XML document can be used as a Templatotron template. If it does not contain any attribute from Templatotron namespace,
it simply creates an XSLT stylesheet which when applied on any other XML document it will produce the template one. It is
not very useful behaviour but it can have its use as a test that a Templatotron implementation is functioning properly.
|
| Page 2 |
Elements and attributes from the Templatotron namespace ("http://zvon.org/templatotron") adds functionality.
The basic usage is shown in this example. Elements in final output are created from the template by following algorithm: take
the local-name of the element from Templatotron namespace and create an element from a namespace of the nearest ancestor not
from Templatotron namespace. Create this element for every node matched by t:select attribute with text contents taken from
these nodes.
|
| Page 3 |
It is a common requirement to create nested nodes. If the value of a t:select attribute is a relative XPath it is taken relative
to the nodes returned by the t:select attribute on the nearest ancestor element with this attribute. If there is no such element
than it is taken relative to the root "/" and so it is equal to the absolute XPath created by concatenating "/" and the value
of the attribute.
|
| Page 4 |
Attributes from other namespaces then the Templatotron one which occurs on the t:* elements appear on the outputted elements.
The parts inside "{}" brackets are evaluated as in XSLT.
|
| Page 5 |
If the value to be computed is not a node-set but an XPath function then t:value-of attribute is used instead of t:select.
|
| Page 6 |
If an attribute from Templatotron namespace occurs on an element not from this namespace, it creates an attribute with the
same local-name and with value evaluated by XPath expression inside @t:* attribute.
|
| Page 7 |
If an attribute from Templatotron namespace occurs on an element from this namespace, and its local name is neither t:select
not t:value-of then it creates an variable which can be used on descendants of the element. Names of the variables must be
unique in the document.
|
| Page 8 |
Because there is a predefined behavior for all elements from Templatotron namespace, it is necessary to introduce the second
namespace for Templatotron instructions which are specified as an element. This namespace is "http://zvon.org/templatotron/instruction".
The most common usage is the use of ti:empty element. By default the elements created with t:* elements uses t:select matched
values for their content. In some cases only an element should be created without content. In these cases ti:empty indicates
this aim.
|
| Page 9 |
ti:key creates keys to be used with the same semantics as the XSLT ones. They can be created at any level in the template
but their names must be unique.
|
| Page 10 |
Sometimes it is required that t:* elements should output elements in different namespace than their parent. In this case an
element tn:namespace from "http://zvon.org/templatotron/namespace" can be used. This attribute determines the required target
namespace.
|
| Page 11 |
Attributes can be cast to a namespace using @tn:* syntax where the name of @tn:* attribute must correspond to the name of
@t:* attribute.
|