Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Curly brackets can never be nested. You can use them only to include an XPath expression in the text of a stylesheet attribute; they cannot be used within an XPath expression itself. You can always achieve the required effect some other way; for example, instead of:
write:
The
concat()
function, described in Chapter 13, performs concatenation of strings.
Attribute value templates cannot be used anywhere you like in the stylesheet. They can be used only for those attributes that are specifically identified as attribute value templates in the XSLT Recommendation. The following table gives a complete list of all the places you can use attribute value templates.
Element | Attributes Interpreted as Attribute Value Templates |
Literal result elements | All attributes except those in the XSLT namespace |
Extension elements | As defined by the specification of each extension element |
regex , flags | |
name, namespace, separator | |
name, namespace | |
collation | |
terminate | |
name | |
format, lang, letter-value, ordinal, grouping-separator, grouping-size | |
name | |
format, href, method, byte-order-mark, cdata-section-elements, doctype-public, doctype-system, encoding, escape-uri-attributes, include-content-type, indent, media-type, normalization-form, omit-xml-declaration, standalone, undeclare-prefixes, output-version | |
lang, order, collation, data-type, case-order | |
separator |
In all other contexts, don't even think of trying to use them because the curly braces will either be ignored or cause an error to be reported. It can be very tempting, if you want to use
However, you can't, because the
name
attribute (or any other attribute of
Why are attribute value templates rationed so severely? The restrictions are there deliberately to make life easier for the XSLT processor:
When an XPath expression within an attribute value template is evaluated, the context is the same as for any other expression in the stylesheet. The idea of an expression having a context was introduced in Chapter 2, on page 84: it determines the meaning of constructs such as
.
, which refers to the context node, and
position()
, which refers to the context position. Variables and namespace prefixes may be used within the expression only if they are in scope at that point in the stylesheet. The context item, context position, and context size are determined from the sequence being processed in the most recent call of
Simplified Stylesheets
A simplified stylesheet uses an abbreviated syntax in which the
The original purpose of this facility was to allow people with HTML-authoring skills but no programming experience to write simple stylesheets with a minimum of training. A simplified stylesheet has a skeleton that looks like the target document (which is usually HTML, although it doesn't have to be), and uses XSLT instructions to fill in the variable parts.
A stylesheet module is interpreted as a simplified stylesheet if the outermost element is not
xsl:version
attribute. For XSLT 2.0 the value should be
1.0
or
2.0
(use
2.0
if your stylesheet depends on features defined in XSLT 2.0, or
1.0
if you also want it to work with XSLT 1.0 processors). When the
xsl:version
attribute is greater than
2.0
, forward-compatible processing mode is enabled. This is discussed later in this chapter on page 130.