Menu

1 / 2

XSLT template matching explained with examples

DEV Community·Alexandre Vazquez·6 months ago
#jmXlPoit
#coding#programming#tutorial#webdev#templates
Reading 0:00
15s threshold

Template matching is the mechanism that drives every XSLT transformation. Understanding how the processor selects templates — and what happens when multiple templates could match — is the difference between a stylesheet that works reliably and one that produces surprising output. This post covers everything you need to know.

How match patterns work

When the processor visits a node, it evaluates every template's match attribute as an XPath pattern. A pattern is a restricted form of XPath that tests properties of a node rather than selecting nodes from a starting point. If the pattern is satisfied, that template is a candidate.

Enter fullscreen mode

Exit fullscreen mode

Priority and conflict resolution

More than one template can match the same node. The processor resolves the conflict using priority.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.