Hi:
After working at this for a while, there is no easy solution to it than good old XSLT Loop inside a loop. Here what I finally did and working in production.
Cheers, Toraj
<xsl:for-each select="../Partner">
<ns0:Record-XMNREF0 xmlns:ns0="urn:ProcessPartner">
<ns0:Col-CLIENT>
<xsl:value-of select="Client/text()" />
</ns0:Col-CLIENT>
<ns0:Col-NRTYPE>
<xsl:value-of select="PartnerType/text()" />
</ns0:Col-NRTYPE>
<ns0:Col-NRNREF>
<xsl:value-of select="PartnerReference/text()" />
</ns0:Col-NRNREF>
<ns0:Col-NRPGRP>
<xsl:value-of select="PartnerGroup/text()" />
</ns0:Col-NRPGRP>
<ns0:Col-NRNAME>
<xsl:value-of select="PartnerName/text()" />
</ns0:Col-NRNAME>
<ns0:Col-NRADR1>
<xsl:value-of select="AddressLine1/text()" />
</ns0:Col-NRADR1>
...
<ns0:Col-NRDATE>
<xsl:value-of select="Date/text()" />
</ns0:Col-NRDATE>
<ns0:Col-NRTIME>
<xsl:value-of select="substring(Time, 1, 4)" />
</ns0:Col-NRTIME>
<xsl:variable name ="prtRef" select="PartnerReference/text()"/>
<xsl:for-each select="../Role">
<xsl:variable name="refRef" select="string(Reference)"/>
<xsl:if test="($refRef = $prtRef)">
<ns0:Record-XMNIRL0 xmlns:ns0="urn:ProcessPartner">
<ns0:Col-CLIENT>
<xsl:value-of select="Client/text()" />
</ns0:Col-CLIENT>
<ns0:Col-NITYPE>
<xsl:value-of select="PartnerRoleType/text()" />
</ns0:Col-NITYPE>
<ns0:Col-NINREF>
<xsl:value-of select="Reference/text()" />
</ns0:Col-NINREF>
......
<ns0:Col-NIDATE>
<xsl:value-of select="Date/text()" />
</ns0:Col-NIDATE>
<ns0:Col-NITIME>
<xsl:value-of select="substring(Time, 1, 4)" />
</ns0:Col-NITIME>
</ns0:Record-XMNIRL0>
</xsl:if>
</xsl:for-each>
</ns0:Record-XMNREF0>
</xsl:for-each>