Given that, would
do what I hope it will,
no it doesn't do the right thing if you have multiple div* siblings
as your nested following-sibling::div1[1] is not finding the
next div1 from the current node but from the node returned buy your
outer following-sibling::*
If you want to avoid keys (which speed things up but make it a bit
obscure) then use a variable and count()
<xsl:template match="div1">
<xsl:variable name="n" select="count(following-sibling::*[self::divGen or
self::div1])"/>
<!-- so what you want is all the nodes that have $n div* after them
which is -->
<fo:page-sequence blah blah blah>
<xsl:apply-templates select="following-sibling::node()[
count(following-sibling::*[self::dviGen or self::div1]) = $n]"/>
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list