Within an XSLT stylesheet, the processor copies literal result elements until it encounters an instruction element. Which of the following represents a valid XSLT instruction form that causes iteration over a node-set?
-
ASELECT ... FROM ... WHERE
-
B{item, action}
-
C{for-each select}
-
D<HTML>...<\HTML>
Answer
Correct Answer: {for-each select}
Explanation
Introduction / Context:XSLT stylesheets can contain literal result elements (e.g., HTML tags) and XSLT instruction elements (e.g., xsl:for-each). The processor copies literal content until it reaches an instruction that changes processing behavior. This question asks you to recognize the iteration instruction form.
Given Data / Assumptions:
- We are working inside an XSLT stylesheet.
- We expect an instruction that iterates over selected nodes.
- The canonical instruction is xsl:for-each with a select attribute.
Concept / Approach:The xsl:for-each instruction iterates over a node-set defined by its select XPath expression, changing the processing context for each node matched.
Step-by-Step Solution:
Identify the relevant XSLT instruction for iteration.Map it to the general form “for-each select”.Select “{for-each select}”.Verification / Alternative check:Any basic XSLT tutorial shows xsl:for-each select="path/to/nodes".
Why Other Options Are Wrong:
- SQL SELECT ... FROM ... WHERE: SQL, not XSLT.
- {item, action}: not an XSLT construct.
- ...<\HTML>: literal result elements, not an instruction.
Common Pitfalls:Confusing XPath expressions (used inside select) with SQL query syntax.
Final Answer:{for-each select}