XPath addresses the tree
XPath expressions select nodes and compute values over the XDM data model. Paths, predicates and functions form the selection language used by XSLT, XQuery and many XML APIs. Namespace bindings are part of name matching and must be declared deliberately.
Templates transform nodes
XSLT applies template rules to selected nodes. A template can create literal result elements, compute attributes and values, or delegate processing with xsl:apply-templates. The rule-based model supports overriding behavior without one central procedural loop.
Variables are values, not mutable slots
An XSLT variable binds a value within its scope. It is not reassigned like a variable in an imperative language. Accumulators, iteration constructs and functional expressions provide other ways to compute results when processing needs state-like behavior.
Versions matter
XPath 1.0 and XSLT 1.0 use a smaller type and function system than modern XPath 3.1 and XSLT 3.0. A stylesheet copied from a browser example may not work in a 3.0 package unchanged, and a 3.0 expression will not run in the browser’s built-in 1.0 processor.
Debug with small inputs
Reduce a failing transformation to the smallest document that retains the relevant namespaces and structure. Inspect selected nodes, confirm the initial template and output method, and distinguish an empty selection from a rule whose output is later overridden.
Implementation notes
Write XPath expressions against the data model, not the source document’s visual indentation or prefix spelling. Bind namespaces explicitly and decide whether typed values from schema-aware processing are part of the contract. Small named functions can centralize normalization and comparison rules that would otherwise be copied across many templates.
For XSLT 3.0 packages, separate public components from internal modes and functions. Declare expected parameter and result types, use accumulators only when their streaming or state model is justified, and keep serialization at the outer boundary. A transformation library is easier to compose when its core returns nodes or values rather than immediately writing files.
Failure modes
XPath version differences change available functions, type conversions and error behavior. A browser’s built-in XSLT 1.0 engine cannot execute a stylesheet written for a 3.0 processor. Detect the processor and version at deployment, and fail with an actionable message instead of producing a partial or empty result.
Textual output comparison can report harmless prefix or attribute-order changes while missing a semantic error. Parse XML results and compare expanded names and values. For HTML, test the DOM and accessibility behavior. For text and JSON output, define encoding, newline and number serialization expectations explicitly.
Review checklist
- XPath version declared
- Namespaces explicit
- Public package surface defined
- Serialization isolated
- Structural tests used
- Processor compatibility verified
Questions for a design review
Use this reference to make a review decision, not merely to recognize terminology. Record the concrete document, schema, processor or consumer being discussed; the language and processor versions; and the behavior that must remain compatible. A useful review produces fixtures and an owner for every unresolved assumption.
- What executable example or test demonstrates the intended behavior for xpath addresses the tree?
- What executable example or test demonstrates the intended behavior for templates transform nodes?
- What executable example or test demonstrates the intended behavior for variables are values, not mutable slots?
- What executable example or test demonstrates the intended behavior for versions matter?
- What executable example or test demonstrates the intended behavior for debug with small inputs?
Include at least one ordinary case, one boundary case and one deliberately invalid or unsupported case. Check the result in the actual production toolchain, because parsers, validators, code generators and reasoners do not all implement the same optional features. Store the selected contract version with the test result, then repeat the review when a dependency, namespace, profile or public declaration changes.
Continue with a working reference
XSLT through HTML templates · XProc pipelines
Frequently asked questions
01What does the XSLT and XPath Tutorial reference cover?
Learn the relationship between XPath selection and XSLT template rules for transforming XML into HTML, XML, text and JSON.
02When should I use this Technical reference guidance?
Use it when designing, reviewing or updating a system that depends on XSLT and XPath Tutorial. Apply the guidance to a concrete example and record any project-specific policy that goes beyond the standard.
03How can I verify a XSLT and XPath Tutorial design decision?
Create a minimal positive example, a negative or boundary example, and run both through the same processors and consumer versions used in production. Keep the expected outcome with the fixture so the decision remains reproducible.
04What are the limitations of this Technical reference reference?
The page explains a focused technical decision; it does not replace the complete specification, processor documentation or integration testing. Version-specific behavior and external dependencies must still be verified in the target environment.