I have just started learning XSL(T) and I wonder how apply-templates
work? I do not understand the recursively applies templates part of it as it is written in my b
You use
to invoke the
:s you have defined.
calls a matching template for each node in the set.
You can control processing order by specifying a select
attribute on apply-templates
.
See this example from w3schools:
My CD Collection
Title:
Artist:
The first apply-templates
calls the cd
template each time an element named "cd"
is encountered.
The cd
template, in turn calls the title
and artist
templates to process the children elements of
.
title
is processed before artist
. Note, that the order of artist
and title
elements in the source XML makes no difference.
You could think of apply-templates
as analoguous to a subroutine call in procedural languages.