I am blessed to work with the SAP B1 Integration Framework, XSLT 1.0 but supports EXSLT at least. So we have this input XML. Result of JDBC SQL...
<xsl:apply-templates select="//jdbc:ResultSet[1]/Row" mode="payment"/>
<xsl:apply-templates select="//jdbc:ResultSet[2]/Row" mode="positions"/>
<xsl:template match="jdbc:Row" mode="payment">
<Documents>
<row>
<xsl:apply-templates mode="fields"/>
<row>
</Documents>
</xsl:template>
<xsl:template match="jdbc:Row" mode="positions">
<Document_Lines>
<row>
<xsl:apply-templates mode="fields"/>
</row>
</Document_Lines>
</xsl:template>
<xsl:template match="*" mode="fields">
... do stuff ...
</xsl:template>
The only reason I have these payment and positions modes is this static wrapper element, Documents/rows, Document_Lines/rows
How do I get rid of this duplication and somehow pass the wrapper with exslt:node-set ? Or some other way?