XSL Templates
Templates can be compared to procedures in a structural programming language. Templates contain programming logic expressed in terms of XSLT instructions that process the source tree and change the result tree. In some cases, even a single template can be used to transform your source tree into a result tree. In fact, XSLT has a special mechanism called Literal Result Element as Stylesheet, which enables you to embed all your XSLT processing logic in the body of the result document you want to create.Templates can either be explicitly named or contain a match expression. When the XSLT processor encounters an xsl:apply-templates instruction, it attempts to match the nodes that were selected with the most appropriate template (using the match expression). Sometimes, more than one template might match. XSLT specifies a complex set of rules to help resolve this conflict by assigning priorities to various kinds of match expressions (patterns). Additionally, a template may itself specify an explicit priority, which the XSLT processor considers while determining which template to instantiate.