Templates

[Example 6] <C>

An XSL processors parses an XML source and tries to find a matching template rule. If it does, instructions inside matching template are evaluated.

[Example 72] <C>

Parts of XML document to which template should be applied are determined by location paths. The required syntax is specified in the XPath specification. Simple cases looks very similar to filesystem addressing. (This stylesheet)

[Example 73] <C>

Processing always starts with template match="/" . This is the root element and its only child is document element, in our case xslTutorial. Many stylesheets do not contain this element explicitly. When an explicit template does not exist implicit template, which contains instruction is called. This instruction means: processes all of the children of the current node, including text nodes. Compare This stylesheet and This stylesheet. When template for a node exists, there is no default processing (This stylesheet). If you want to include descendants of the node, you have to explicitly request their templates (This stylesheet).

[Example 8] <C>

Template can match from selection of location paths, individual paths being separated with |.(This stylesheet). Wildcard * selects all possibilities.Compare This stylesheet with This stylesheet. Compare with Example 73.

[Example 4] <C>

// is very common in location paths. When it is used at the beginning of location path, it means: select all nodes in the document of the specified type. (This stylesheet). In the middle of a location path it means: select all nodes which appear in a node selected with the first part of location path. (This stylesheet

[Example 71] <C>

Modes allow an element to be processed multiple times, each time producing a different result.In This stylesheet one of the modes does not exist.

[Example 69] <C>

Often several templates match selected element in XML source. It must be therefore decided which one to use. The templates are ordered according their priority which can be specified with priority attributte. If the template does not have this attribute, its priority is calculated according to several rules. This stylesheet and This stylesheet differ by priority of their templates. This stylesheet shows the default action in the absence of priority attributes. Template CCC has lower priority than CCC/CCC, as it is less specific. Compare This stylesheet and This stylesheet. Template CCC has lower priority than both CCC/CCC or AAA/CCC/CCC, but the latest two have the same priority. In such a case an XSLT processor may signal the error; if it does not signal the error, it must recover by choosing, from amongst the matching template rules that are left, the one that occurs last in the stylesheet. In This stylesheet less specific * has lower priority than CCC. Computed priorities ranges fromt -0.5 to 0.5. XSLT spec gives more details.