apply-templates

The apply-templates keyword instructs the XSLT to recursively process any the children of the source element.

Syntax
<apply-templates> ::= "apply-templates" ( "using" <expression> )? ( "scope" <expression> )? ( "{" <sort>? <with>* "}" )?
Options
using an (optional) XPath expression indicating the node and children to match.
scope the (optional) scope (mode) of this template, matching that defined in an match statement.
Elements
<with> an (optional) parameter carried into the invoked match templates via a with.
<sort> the (optional) definition of how the match templates should be applied and sorted.
Examples
match using "//list" { apply-templates { with param-1 "'List Title'" sort using "a" descending } }

This says that when any list is detected then the children of "//list" are processed with a parameter param-1 with a value of "'List Title'" (a simple string), and the results of applying the templates sorted with the <a> element in descending order.

<template match="/"> <apply-templates> <with-param name="param-1" select="'List Title'"/> <sort select="a" order="descending"/> </apply-templates> </template>

Note that if the "descending" instruction had been "ascending" or omitted then this is the default value and the "order" attribute would be also omitted in the output XSLT.

As an aside the above can also be written, with the same effect, as

match using "//list" { apply-templates { with param-1 { text "List Title" } sort using "a" descending } }
Errors

A simple misspelling.

stylesheet { version "1.0" match using "node() | @*" priority "-1" scope "inline-text" { copy { apply-templates usin "@*" apply-templates } } }

will give the error

**** (106) Unexpected symbol "usin" in line 6 Check spelling, did you mean "using" ?

An illegal or misspelled keyword on the following line

stylesheet { version "1.0" match using "node() | @*" priority "-1" scope "inline-text" { copy { apply-templates using "@*" apply-template } } }

will give a similar error

**** (106) Unexpected symbol "apply-template" in line 7 Check spelling, did you mean "apply-templates" ?
Copyright 2024 Hugh Field-Richards. All Rights Reserved.