xslt terminology

XSLT Terminology

XSLT Terminology Clarification.

Source: W3C Recommendation 16 November 1999

Revision: Draft 0.c

Editor comment: These definitions are meant to be explanatory rather than exact. For precision, see the W3C recommendations. They are the the clearest definitions I have... until someone mails me a better one. <grin> I do need help to complete it. See the question marks.

If something is confusing, then perhaps it should be fixed. Please let me know.

Maintained by DaveP,

Miloslav Nic has created a glossary, see Zvon Glossary: The glossary is XML focused but the relation to XML can be very loose. Unsuccessful searches are logged and manually scanned for possible inclusion to the database.

The glossary can be also used from your own pages: http://zvon.org/index.php?nav_id=171

The back-end software was written by Jakub Vrana.

Terminology

@

The @ character is an abbreviation for the attribute:: axis. Combined with the name of an attribute, it identifies that attribute for the current node.

..

The string .. is an abbreviation for parent::node().

*

A *, by itself identifies all of the element children of the context node. It can also be used with @ (@*) to identify all attributes, or in other expressions as a general wildcard for 'all'."

.

The . character is an abbreviation for self::node().

/

the / character at the start of a location path makes it absolute, i.e. starting at the root node of a document.

//

The string // is an abbreviation for descendant-or-self::node().

AVT:

see Attribute Value Template

ATTRIBUTE SET:

The set of attributes associated with an element. xsl:use-attribute-sets may be used to preset attributes in an RTF.

ATTRIBUTE VALUE TEMPLATE:

This is an expression surrounded by curly braces ({}) and used in a template. Attribute value templates allow you to assign a value to an attribute in the output using an expression, rather than a fixed value. The final value output for the attribute is determined by evaluting the expression, changing it to a string and replacing both the expression and the curly braces with the string.

AXIS:

There are 13 axes defined in XPath:

child
descendant
parent
ancestor
following-sibling
preceding-sibling
self
following
preceding
attribute
namespace
descendant-or-self
ancestor-or-self.

Each specifies a 'direction' relative to the context node and can be used to provide an initial selection of nodes.

CONTEXT:

The items in scope with respect to the current position in the document. This includes the current node, its number within the current context, the list of in scope variables and the list of in scope namespaces.

CONTEXT NODE:

The context node is where XPATH addressing starts. It is the source document node currently being processed by the XSLT processor as specified by a template. However, within square brackets the current node is usually different from the context node.

CONTEXT POSITION:

The context position comes from the position of the current node in the current node list; the first position is 1, rather than 0 as in some languages.

CONTEXT SIZE:

The size of the CURRENT NODE LIST.

CURRENT NODE:

The current node is the element, or node in a list of elements, that is currently being processed by a template. Current nodes may also be attributes or namespaces rather than elements.

CURRENT NODE LIST:

The list of nodes resulting from the triggering of a template. The more general the template, the longer the current node list, and vice versa. The list changes for each template that is triggered by matching on the source document content. The current node is always a member of the current node list. The context size comes from the size of the current node list. When a template is instantiated, it is always instantiated with respect to a current node and a current node list.

CURRENT TEMPLATE:

The XSL template being acted upon at any particular moment in time as the XSLT processor processes the document using a stylesheet.

DOCUMENT ORDER:

A traversal of the document tree from start to end, in written order. The ancestor and preceding axes use reverse document order and the attribute and namespace axes are unordered. If parentheses are used for grouping, you will always get forward document order.

OK, I've been corrected(DC): the attribute and namespace are both forwards axes.

What Dave means about paremthesese is ancestor::*[1] gives you the first ancestor in reverse document order ie your parent whereas (ancestor::*)[1] gives you your first ancestor in document order, ie your most ancient ancestor; Adam (or Eve) in some cultures.

Mike adds: ancestor::*[1] selects the immediate ancestor (the parent) (ancestor::*)[1] selects the ultimate ancestor (the document element)

EXPANDED NAME:

When namespaces are used, an element may be seen as <mine:lname> . mine is a 'shorthand' version of the namespace definition for the element, i.e. http://mine/own/url. The expanded name is then http://mine/own/url:lname. the part after the latter colon is named the LOCAL PART. The expanded-name consisting of the local part of the name and the possibly null URI reference is used as the name of the object. The default namespace is not used for unprefixed names. From XPATH. The namespaces of an element node come from the in-scope namespaces property. The local part of the expanded-name of the element node comes from the local name property. The namespace URI of the expanded-name of the element node comes from the namespace URI property. Plain English version please????

EXPRESSION:

An expression is evaluated to yield an object, which has one of the following four basic types; a node-set, a boolean, a number or a string. Expressions are used in XSLT for a variety of purposes including: Selecting nodes for processing; Specifying conditions for different ways of processing a node; Generating text to be inserted in the result tree.

EXTENSION ELEMENT:

The element extension mechanism allows namespaces to be designated as extension namespaces. When a namespace is designated as an extension namespace and an element with a name from that namespace occurs in a template, then the element is treated as an instruction rather than as a literal result element. The namespace determines the semantics of the instruction. E.g. xmlns:date="http://www.jclark.com/xt/java/java.util.Date"

EXTENSION FUNCTION:

A function provided by an XSLT processor which is not part of the recommendation from W3C.

IMPORT:

The end result is to insert the imported stylesheet into the current stylesheet at the insertion point. Importing a stylesheet is the same as including it except that the template rules in the importing stylesheet take precedence over template rules and definitions in the imported stylesheet.

IMPORT TREE:

???? The xsl:stylesheet elements encountered during processing of a stylesheet that contains xsl:import elements are treated as forming an import tree. In the import tree, each xsl:stylesheet element has one import child for each xsl:import element that it contains. Plain English Please!!!!

INCLUDE:

xsl:include includes other stylesheet content into the current one.

INSTANTIATE:

When a template is triggered by some part of the XML document being processed by the XSLT processor, the template is said to be instantiated.

KEY:

A scheme for having several lookup tables, each having its own keyspace name. The function named "key" accepts the name of a keyspace and a key to be looked up within that keyspace, and it returns a node-set (q.v.) comprising the nodes that the key points to. Typically, the key is a string constant and only one node is returned, but multi-node inputs and outputs are possible. When declaring a keyspace, you tell the processor to "use" some attribute or child (or similarly locatable sub-node) as the key for each eligible node, and typically you would want to "use" something that is unique for each node. (See section 12.2 of the spec, which also includes reasons why keys are more flexible than IDs.)

LITERAL RESULT ELEMENT:

In a template, an element in the stylesheet that does not belong to the XSLT namespace is used to create content in the result tree.

LOCATION PATH:

There are two kinds of location path: relative location paths and absolute location paths. A location path describes how a specific part of a document may be found. Location paths describe the address of one node with respect to another. A location path is composed of a series of steps. Each step consists of an axis, a node test and optional predicates . The syntax for a location step is the axis name and node test separated by a double colon, followed by zero or more expressions each in square brackets. For example, in child::para[position()=1], child is the name of the axis, para is the node test and [position()=1] is a predicate.

LRE:

see LITERAL RESULT ELEMENT

MATCH PATTERN:

see PATTERN

MATCHING:

The action of an XSLT processor of using input document content and XSLT templates to determine which template is to be instatiated and hence actioned.

MODE:

A way to segregate templates so that they will only be considered when the XSLT processor is "in [a certain] mode" by way of xsl:apply-templates being invoked with the mode specified by name. This is presented as the means for applying more than one template to an input node. (See section 5.7 of the spec, which is terse.)

NAMED TEMPLATE:

An xsl:template with a name attribute specifies a named template, which can be invoked by that name. An xsl:call-template invokes a template by name; it has a required name attribute that identifies the template to be invoked. xsl:call-template does not change the current node or the current node list.

NAMESPACE:

A W3C recommendation, used by XPATH. See http://www.w3.org/TR/REC-xml-names. XML namespaces provide a simple method for qualifying element and attribute names used in Extensible Markup Language documents by associating them with namespaces identified by URI references.

NODE:

A single point on the document tree. Can be any one of an element node, attribute node, namespace node, processing instruction node, comment node or text node.

NODE SET:

An unordered collection of nodes without duplicates or node-set: non-repeating set of nodes from anywhere in the source tree(s);

You get node-sets from a source tree (which is usually derived from an XML document), and you tell the XSLT processor to create, in steps (a fragment at a time, in a nested fashion), a result tree, via the instructions and literal result elements you put in the stylesheet. Output, such as an XML or HTML document, may be derived from the result tree.

> If I have a node-set, will I be able to access the children
> of the nodes in that node-set?

No; not in pure XSLT. This is what the node-set extensions in various implementations are for, though, as you guessed. These are functions that supplement the standard XPath & XSLT functions, taking a result tree fragment argument and returning a node-set. You can use the function call as the first LocationStep in an expression, like:

<xsl:variable name="aFragment">
  <div style="font-weight: bold">
    <p>hi!</p>
  </div>
</xsl:variable>
<xsl:value-of select="xt:node-set($aFragment)/div/p"/>

These convert-to-node-set functions are generally used for sorting and grouping operations, although they may not be necessary now that key-based methods have been devised.

What you can do in an extension function depends on the implementation. Certainly with Saxon, when you pass a node-set to an extension function there are methods to navigate from any node to its children, siblings, parent, etc.

The node-set() extension function is there to make result tree fragments navigable in the same way that node-sets are.

NODE TEST:

A node test identifies nodes in the document that meet the criteria of the test. The simplest type of test is nodes that match an element name.

NODE TYPE:

There are seven node types: element, attribute, text, processing instruction, comment, namespace, and root. These are: the elements, attributes, text, processing instructions, and comments in a document. Namespace nodes represent the namespaces used in the document. The root node is the root of the document. In every XML document, there is exactly one root node, which the node that contains the (optional) prologue and the document element.

PATTERN:

A pattern is a kind of EXPRESSION. An expression that is also a pattern always evaluates to a node-set. The main use of patterns is to identify which nodes a template can apply to, viz. it can apply to any node that matches the pattern specified in its select attribute. In a pattern, | indicates alternatives; a node matches a pattern with one or more | separated alternatives if it matches any one of the alternatives. Each alternative is a sequence of STEPs separated by / or //; it is matched from right to left: a node matches an alternative only if the rightmost step matches the node and a suitable element matches each of the other steps; if the separator is / then only the parent is a suitable element; if the separator is //, then any ancestor is a suitable element. Patterns are also used for numbering and for declaring keys.

PRECEDENCE:

It is possible for a source node to match more than one template rule. The precedence rules of XSLT determine which one is acted up. See XSLT section 5.5. Not to be confused with import precedence, which determines the precedence of imported stylesheets. Not to be confused with PRIORITY

PREDICATE:

A predicate filters a node-set with respect to an axis to produce a new node-set. A predicate occurs in square brackets after the a node test. For example, para selects all of the para children of the context node. Adding the predicate [3]: para[3] selects only the third para element. XPATH section 4 and XSLT section 12 enumerate all the functions for use in predicates.

QUALIFIED NAME:

The name of an internal XSLT object, specifically a named template, a mode, an attribute set, a key, a decimal-format, a variable or a parameter is specified as a qualified name. If it has a prefix, then the prefix is expanded into a URI reference using the namespace declarations in effect on the attribute in which the name occurs.

PRIORITY:

The priority of a template rule is specified by the priority attribute. It can be positive or negative. Higher numbers have higher priorities.

ROOT NODE:

The root node is the root of the document tree. This is not the same as the node corresponding to the document element. (It is that nodes parent.)

RESULT TREE:

The output produced by running an XSLT stylesheet over an XML document using an XSLT engine.

RESULT TREE FRAGMENT:

Is the result of instantiating some `template' (ie xsl:template or content of a non empty xsl:variable or xsl:param) it may be copied to the output with xsl:copy-of, or converted to a string and used as a string in an expression. Also defined as a hierarchical branch of nodes created for the result tree. (It is not possible to gain access to the internal tree structure of the rtf without the use of non standard EXTENSION FUNCTION) Also described as: An RTF is a tree. It is part of the state (working data) of a stylesheet during its execution. It is created by instantiating a template, non-empty xsl:variable element (or xsl:param or xsl:with-param) with no select attribute, and it can be used in two ways: by referencing that variable in an xsl:copy-of instruction, which copies the RTF tree (minus its root node) to the current position in the current output tree (which may be the final result tree or another RTF), or by referencing it in any other context, in which case it is converted to a string.

RTF:

See Result Tree Fragment

RULE:

see TEMPLATE

SELECT:

A location path selects a set of nodes relative to the context node. The selection is a node set.

STEP:

One item of a location path. Steps may be joined with slashes to form a more complex location path. Hence the seqence step1/step2/step3 forms a sequence which is actioned left to right. Each step in turn selects a set of nodes relative to a context node.

TEMPLATE

See TEMPLATE RULE, below.

TEMPLATE RULE:

A node from a source document is processed by finding all the template rules with patterns that match the node, and choosing the best amongst them; the chosen rule's template is then instantiated with the node as the current node and with the list of source nodes as the current node list. A template typically contains instructions that select source nodes for processing. The process of matching, instantiation and selection is continued until no new source nodes are available.

TOP-LEVEL ELEMENT:

An xml element which is a direct descendant from the document element of a stylesheet.

VARIABLE:

A variable is a name that may be bound to a value. The value to which a variable is bound (the value of the variable) can be an object of any of the types that can be returned by expressions. There are two elements that can be used to bind variables: xsl:variable and xsl:param. The difference is that the value specified on the xsl:param variable is only a default value for the binding; when the template or stylesheet within which the xsl:param element occurs is invoked, parameters may be passed that are used in place of the default values.

XPATH:

XPath is a language that describes how to locate specific elements (and attributes, processing instructions, etc.) in a document. It allows you to locate specific content within an XML document. XPATH treats an XML document as a logical ordered tree,

XSL

XSL specifies the styling of an XML document by using XSLT to describe how the document is transformed into another XML document that uses the formatting vocabulary.

First there was XSL, which was conceived as a language to do styling (i.e. to define how an XML document should be rendered). Then XSLT was carved out as a separate sub-language to do the first part of styling, which is transformation. This was the first part to be implemented, so a lot of people used XSL and XSLT as near synonyms. Microsoft implemented a very early draft of XSLT, before it was called XSLT, so in Microsoft documentation XSL now means "the Microsoft 1998 dialect of XSLT"; but in the W3C standards world (and they invented the name) it means "a yet-to-be-completed standard that includes separate components for XML transformation and formatting".

XSLT

A language for transforming XML documents into other XML documents. XSLT is not intended as a completely general-purpose XML transformation language. Rather it is designed primarily for the kinds of transformations that are needed when XSLT is used as part of XSL.