Squashed a bug in "output filename" template: needed to use xsl:for-each to set context node before doing an xsl:number to get proper numbering results in all cases.