Dorsai wanted to output this as an HTML table with each row containing only 6 columns. The key is that the position() function is relative to the current node set. The pointer to the node (the context) is defined in the for-each select statement, so the first node selected is that with position = 1. The first tr is added to the result tree, and the current node (“.”) and its following 5 sibling nodes are selected and applied to the attribute template. This means that nodes 1-6 are selected in the first loop iteration. The mod() operation then selects node 7, because it is the next one where mod 6 = 1. The loop selects the current node (“.”), which is node 7, and its following 5 sibling nodes, selecting 7-12 and applying the template.