Я пытался воспроизвести ваш вывод с вашим данным кодом. В результате вы получите желаемый результат:
<xsl:template match="regIncludedProduct">
<fo:block>
<xsl:call-template name="getContext"/> <!-- This is the first text in the numbering so we do not need the preceding '.' -->
<xsl:text>-</xsl:text>
<xsl:value-of select="RegistrationIncludedProduct/recordId"/>
<xsl:apply-templates select="following-sibling::regPackagingHierarchyList[1]//recordId"/>
<!-- Based on your xml you can choose beween following:: and following-sibling:: , there is also the possibility to not only take the first following occurence. If you want to archive this just delete the [1] -->
</fo:block>
</xsl:template>
<xsl:template match="recordId">
<xsl:text>.</xsl:text>
<xsl:call-template name="getContext"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="."/> <!-- '.' takes the text of the current context/node you are in, which is recordId -->
</xsl:template>
<xsl:template name="getContext">
<xsl:choose>
<xsl:when test="self::regIncludedProduct">RegistrationIncludedProduct</xsl:when>
<xsl:when test="ancestor::regParentPackagingHierarchy">regChildPackagingHierarchyList</xsl:when>
<xsl:when test="ancestor::regPackagingHierarchyList">regPackagingHierarchyList</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="//regIncludedProduct"/>
</xsl:template>
Если у вас есть какие-либо вопросы, не стесняйтесь их задавать. :)