Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Namespace fixup is then applied, but this doesn't need to do anything, because all the required prefixes are already declared.
When the time comes to serialize this result tree, namespace nodes are used to generate namespace declarations. So the output (ignoring the XML declaration) should be this:
XSLT 2.0 (unlike 1.0) really doesn't give the implementation any latitude to generate anything else in this situation. In 1.0, there was a general rule that the serializer could add any namespace declarations it chose, and by implication that it could give elements and attributes any prefix that it chose. In 2.0, the namespace fixup process is only allowed to add namespaces if they are actually needed to make the tree consistent, and in this case, they aren't.
Example of
The following example generates an XSLT stylesheet consisting of a single global variable declaration, whose name and default value are supplied as parameters. Although this is a trivial stylesheet, it could be useful when incorporated into another more useful stylesheet using
This example is available in the code download as
alias.xsl
.
Source
No source document is required. You can run this with Saxon using the command:
java -jar c:\saxon\saxon9.jar -it:main -xsl:alias.xsl
The
-it
option on the command line causes the transformation to start at the template named
main
.
Stylesheet
xmlns:xsl=“http://www.w3.org/1999/XSL/Transform”
xmlns:oxsl=“http://www.w3.org/local-alias”>
stylesheet-prefix=“oxsl”
result-prefix=“xsl”/>
Output
If you default the values of the parameters
variable-name
and
default-value
, the output is as follows.
version=“1.0”>
See Also
Literal Result Elements
in Chapter 3, on page 112.
xsl:next-match
The
Changes in 2.0
This instruction is new in XSLT 2.0. It was introduced as an improved alternative to
Format
Position
Attributes
None.
Content
The element may be empty, or it may contain one or more
Effect
current template rule
. A template rule becomes the current template rule when it is invoked using
Closely associated with this is the
current mode
. When a template rule is invoked using
instruction becomes the current mode (if no mode is named, then the default unnamed mode becomes the current mode). The current mode reverts to the default (unnamed) mode when a stylesheet function is called.
There is a clear analogy here with object-oriented programming. Writing a template rule that overrides another is like writing a method that overrides a method defined on the superclass.
super()
function in object-oriented programming languages, allowing the new template rule to refine the behavior of the original template rule, rather than replacing it completely.