BizTalk - XSLT Munchien adding another field to group records

I have following xslt, which creates separate records only using invoice field. I have a requirement where it should create separate record for each unique invoice and id fields. Below is my XSLT. How can I achieve this with my below xslt ?

<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0" version="1.0" xmlns:s0="http://Brightstar.Integration.IPMSerengeti.Schemas.Invoices" xmlns:ns0="http://Brightstar.Integration.Serengeti.IPM.Schemas.IPM_SR">
  <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
  <xsl:template match="/">
    <xsl:apply-templates select="/s0:invoices" />
  </xsl:template>
  
<xsl:key name="groups" match="invoice" use="invoice"/>

  <xsl:template match="/s0:invoices" >
<ns0:Root>
      <xsl:for-each select="invoice[generate-id(.)=generate-id(key('groups',invoice))]">

        <xsl:sort select="id" order="ascending"/>

        <req>
          <xsl:attribute name="CpnyId">
            <xsl:value-of select="1011"/>
          </xsl:attribute>

          <xsl:attribute name="VendId">
            <xsl:value-of select="id/text()"/>
          </xsl:attribute>

          <xsl:attribute name="InvcNbr">
            <xsl:value-of select="invoice/text()"/>
          </xsl:attribute>

          <xsl:attribute name="InvcDate">
            <xsl:value-of select="concat(substring(date,7,4),'-',substring(date,1,2),'-',substring(date,4,2),'+00:00')"/>
          </xsl:attribute>

          <xsl:attribute name="ReqAmt">
            <xsl:value-of select="sum(key('groups', invoice)/amount)"/>
          </xsl:attribute>

       
          <xsl:for-each select="key('groups',invoice) ">
            <rit>
              <xsl:attribute name="CpnyId">
              <xsl:value-of select="company"/>
              </xsl:attribute>

              <xsl:attribute name="Acct">
                <xsl:value-of select="account"/>
              </xsl:attribute>
                      
              <xsl:attribute name="Sub">
                <xsl:value-of select="subaccount"/>
              </xsl:attribute>


              <xsl:attribute name="TranAmt">
                <xsl:value-of select="amount"/>
              </xsl:attribute>
          
              <xsl:attribute name="Descr">
                <xsl:value-of select="description"/>
              </xsl:attribute>

            </rit>

          </xsl:for-each>
          <!-- </Detail>-->
        </req>

      </xsl:for-each>
    </ns0:Root>


</xsl:template>
</xsl:stylesheet>
June 23rd, 2015 10:29am

use a scripting functoid, it will help you create unique id
Free Windows Admin Tool Kit Click here and download it now
June 25th, 2015 2:49am

How is this question different to the one I already answered at the bottom of this thread?\

Regards,

Ren

June 25th, 2015 2:54am

Rene, what if I have to concatenate multiple fields like invoice, id, date, ExchangeRate ??
Free Windows Admin Tool Kit Click here and download it now
June 25th, 2015 6:52am

What do you mean with that? Do you want to group on these conditions?

Can you provide an example of what your input looks like and the desired output?

June 25th, 2015 6:55am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics