This is a "positional grouping" problem. All grouping problems are best tackled using XSLT 2.0, which offers <xsl:for-each-group group-starting-with="page"> to address this need.
In 1.0 the techniques are basically:
(a) recursive traversal of the sibling axis (typically using xsl:apply-templates select="following-sibling::*[1]")
(b) treating it as a value-based grouping problem (using any of the techniques for value-based grouping) with generate-id(preceding-sibling::page[1]) as the grouping key.
Searching for "XSLT positional grouping" might help, also see
http://www.dpawson.co.uk/xsl/sect2/N4486.html#d5171e424
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference