XML interview question · Most asked

How does XSLT work? Explain templates and apply-templates.

Create a free account to save this page, take notes and track your progress. Sign in

Summary

An XSLT stylesheet is a set of template rules. The processor starts at the root, finds the best-matching template, and the template outputs content and calls xsl:apply-templates to process selected nodes with their own matching templates. Built-in rules copy text and recurse when no template matches.

Longer Answer

Push style (apply-templates, one template per node type) is more maintainable than one big xsl:for-each. The identity transform plus overrides is the standard way to make small changes to a document.

Key Points

  • Template rules match patterns.
  • apply-templates recurses.
  • Built-in rules.
  • Identity transform pattern.

Deep dive: XML Tutorial: XSLT Basics

Explanation

What interviewers look for

Push vs pull and the identity transform.

More most-asked XML questions

← All XML questions

Was this page helpful?