How to Understand template calls in XSLT
Because the style sheet is descriptive rather than procedural, we will not assume that the first template is the start of the call, nor take "/" as a sitting
Start node.
The style sheet discovers the call relationship between templates and automatically finds the call start point.
For example:
Source. xml
/*------------*/
<? XML version = "1.0"?>
<? XML-stylesheet type = "text/XSL" href = "books. XSL"?>
<Source>
<Bold> Hello, world. </bold>
<Red> I am </red>
<Italic> fine. </italic>
</Source>
Books. XSL
/*-----------*/
<XSL: stylesheet version = '1. 0'
Xmlns: XSL = 'HTTP: // www.w3.org/5o/#/transform'>
<XSL: output method = "html" indent = "yes"/>
<XSL: template match = "/source">
<XSL: Apply-templates select = "/"/>
</XSL: Template>
</XSL: stylesheet>
Result:
Hello, world.
I am
Fine.
<XSL: Apply-templates select = "/"/> is a call statement. The select attribute selects the context node again.
The template that matches the current context node is called.