Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context:
XSLT (Extensible Stylesheet Language Transformations) transforms XML by applying templates to nodes. Understanding “context” (the current node, position, and size) is essential to writing correct match patterns and select expressions with XPath. This question checks whether learners grasp that XSLT is fundamentally context-driven.
Given Data / Assumptions:
Concept / Approach:
When an XSLT processor applies templates, it sets the context node to the node that matched the template’s match pattern. All XPath expressions inside that template—such as select attributes on xsl:value-of or xsl:for-each—evaluate relative to the current context unless explicitly changed (for example, with xsl:for-each or xsl:apply-templates that establish a new context). This context also includes the context position and size, which functions like position() and last() can reference.
Step-by-Step Solution:
Verification / Alternative check:
Inspect how functions like current(), position(), last() behave—they rely on the current context node and node-set being processed.
Why Other Options Are Wrong:
Common Pitfalls:
Losing track of the current context after nested xsl:for-each or xsl:apply-templates, leading to wrong node selections. Use variables or absolute paths judiciously to avoid confusion.
Final Answer:
Correct
Discussion & Comments