↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

XSLT ForEach

The stylesheet matches the document root, switches output to text, and starts a named template with start and end parameters. The template checks whether the start is within the end, prints the number when both are equal, and otherwise splits the range at the midpoint and calls itself twice.

Reading notes
#

  • The root template calls displayNumbers with pStart set to 1 and pEnd set to 1000000.
  • displayNumbers takes two parameters, pStart and pEnd.
  • When pStart is not greater than pEnd, the template continues.
  • If pStart equals pEnd, it outputs the current number followed by a line break.
  • Otherwise, it computes vMid as floor(($pStart + $pEnd) div 2).
  • It then calls displayNumbers for the left half from pStart to vMid.
  • It calls displayNumbers again for the right half from vMid+1 to pEnd.