Given:
<illustratedPartsCatalog>
<figure id="fig1">...</figure>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<figure id="fig2">...</figure>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
</illustratedPartsCatalog>
Each figure gets its own table of <catalogSeqNumber>s
but right now the figure1 table also includes entries for figure2 and vice versa. The processing of <catalogSeqNumber>
should stop when it reaches the next figure.
Solved with Tomalak's answer:
<xsl:template match="illustratedPartsCatalog">
<xsl:apply-templates />
</xsl:template>
I added this to the end of <xsl:template match="figure">
<xsl:if test="following-sibling::*[1][self::catalogSeqNumber] and ancestor::illustratedPartsCatalog">
<xsl:call-template name="PI-TABLE"/>
</xsl:if>
And added this to PI-TABLE (which builds the table of <catalogSeqNumber>
):
<xsl:apply-templates select="key('kCSN', @id)" />