none
BizTalk - XSLT summation ? RRS feed

  • Question

  • I have following xslt , I want <ReqAmt> to be sum of <TranAmt> present in <rit> node.

    <?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.Serengeti.Schemas.Invoices" xmlns:ns0="http://Munchein.Grouping">
      <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" >
    
        <Root>
          <xsl:for-each select="invoice[generate-id(.)=generate-id(key('groups',invoice))]">
    
            <xsl:sort select="id" order="ascending"/>
    
            <req>
    
              <CpnyId>
                <xsl:value-of select="1011"/>
              </CpnyId>
              
              <!--VendorID-->
              <VendId>
                <xsl:value-of select="id/text()"/>
              </VendId>
    
               <!--InvoiceID-->
              <InvcNbr>
                <xsl:value-of select="invoice/text()"/>
              </InvcNbr>
    
              <!--InvoiceDate-->
    
              <InvcDate>
                <xsl:value-of select="date/text()"/>
              </InvcDate>
    
              <ReqAmt>
                <xsl:value-of select="amount"/>
              </ReqAmt>
    
              <!--InvoiceDueDate-->
              <InvoiceDueDate>
                <xsl:value-of select="due/text()"/>
              </InvoiceDueDate>
              
    
    
    
              <!--<Detail>-->
    
              <xsl:for-each select="key('groups',invoice)">
                <rit>
                  <CpnyId>
                    <xsl:value-of select="company"/>
                  </CpnyId>
    
                  <Acct>
                    <xsl:value-of select="account"/>
                  </Acct>
    
                  <Sub>
                    <xsl:value-of select="subaccount"/>
                  </Sub>
    
                  <TranAmt>
                    <xsl:value-of select="amount"/>
                  </TranAmt>
    
    
                  <Descr>
                    <xsl:value-of select="description"/>
                  </Descr>
    
                
    
    
                </rit>
    
              </xsl:for-each>
              <!-- </Detail>-->
            </req>
    
          </xsl:for-each>
        </Root>
    
      </xsl:template>
    </xsl:stylesheet>
    
    

    My output is

    <Root xmlns:ns0="http://Munchein.Grouping"><req><CpnyId>1011</CpnyId><VendId>21000002289</VendId><InvcNbr>20150603E</InvcNbr><InvcDate>06/03/2015</InvcDate><ReqAmt>550.00</ReqAmt><InvoiceDueDate>06/03/2015</InvoiceDueDate><rit><CpnyId>1011</CpnyId><Acct>4000010</Acct><Sub>US00-DLSMD-102000-000-10-AC3</Sub><TranAmt>550.00</TranAmt><Descr></Descr></rit><rit><CpnyId>1011</CpnyId><Acct>6001880</Acct><Sub>AU00-00000-101000-ACE-00-000</Sub><TranAmt>550.00</TranAmt><Descr></Descr></rit></req><req><CpnyId>1011</CpnyId><VendId>21000002289</VendId><InvcNbr>20150603A</InvcNbr><InvcDate>06/01/2015</InvcDate><ReqAmt>7171.00</ReqAmt><InvoiceDueDate>06/03/2015</InvoiceDueDate><rit><CpnyId>1011</CpnyId><Acct>6001880</Acct><Sub>AU00-00000-101000-ACE-00-000</Sub><TranAmt>7171.00</TranAmt><Descr>AX Test</Descr></rit></req><req><CpnyId>1011</CpnyId><VendId>21000002289</VendId><InvcNbr>20150603B</InvcNbr><InvcDate>06/01/2015</InvcDate><ReqAmt>88.00</ReqAmt><InvoiceDueDate>06/04/2015</InvoiceDueDate><rit><CpnyId>1011</CpnyId><Acct>6001880</Acct><Sub>AU00-00000-101000-ACE-00-000</Sub><TranAmt>88.00</TranAmt><Descr>AX Test</Descr></rit><rit><CpnyId>1011</CpnyId><Acct>4000010</Acct><Sub>AU00-00000-101000-ACE-00-000</Sub><TranAmt>80.00</TranAmt><Descr>AX Test</Descr></rit><rit><CpnyId>1031</CpnyId><Acct>4000010</Acct><Sub>US00-DLSMD-102000-000-10-AC3</Sub><TranAmt>80.00</TranAmt><Descr>AX Test</Descr></rit></req></Root>
    How can I update my XSLT to make my Req node summation of <rit> node ?


    MBH

    Thursday, June 11, 2015 2:50 PM

Answers

  • Hi,

    You can use your key for that:

    use sum(key('groups',invoice)/amount) in ReqAmount

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

    Regards,


    René

    • Marked as answer by JaguarsJag Friday, June 12, 2015 1:40 PM
    Friday, June 12, 2015 1:06 PM
  • Replace the following:

    <xsl:key name="groups" match="invoice" use="invoice"/>

    with

    <xsl:key name="groups" match="invoice" use="concat(invoice, '#', id)"/>

    and

    <xsl:for-each select="invoice[generate-id(.)=generate-id(key('groups',invoice))]">

    with

    <xsl:for-each select="invoice[generate-id(.)=generate-id(key('groups',concat(invoice, '#', id)))]">

    and

    <xsl:for-each select="key('groups',invoice)">with

    <xsl:for-each select="key('groups',concat(invoice, '#', id)">

    • Marked as answer by JaguarsJag Tuesday, June 23, 2015 6:20 PM
    Tuesday, June 23, 2015 5:20 PM
  • <Sub>
    		<xsl:if test="subaccount != '----'">
    			<xsl:value-of select="subaccount" />
    		</xsl:if>
    </Sub>

    Morten la Cour



    • Edited by la Cour Thursday, July 2, 2015 5:23 PM
    • Marked as answer by JaguarsJag Thursday, July 2, 2015 8:37 PM
    Thursday, July 2, 2015 5:21 PM

All replies

  • Hi,

    I believe you can use the SUM  function to aggregate the value of these nodes in a single one.

    https://msdn.microsoft.com/en-us/library/ms256160%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

    Regards


    When an answer is helpful, please vote as helpful, propose as answer and/or mark as answer

    Thursday, June 11, 2015 3:31 PM
  • As you can see in bold , for common 20150603E record, as per my XSLT :

    <ReqAmt>1100 </ReqAmt> in Header Record  and  550 and 550 each in detail record.

    It is all coming from 1 field.

    APPLE INC.|21000002289|20150603E|06/03/2015|550.00||1011|4000010|US00-DLSMD-102000-000-10-AC3|06/03/2015
    APPLE INC.|21000002289|20150603E|06/03/2015|550.00||1011|6001880|AU00-00000-101000-ACE-00-000|06/03/2015
    APPLE INC.|21000002289|20150603A|06/01/2015|7171.00|AX Test|1011|6001880|AU00-00000-101000-ACE-00-000|06/03/2015
    APPLE INC.|21000002289|20150603B|06/01/2015|88.00|AX Test|1011|6001880|AU00-00000-101000-ACE-00-000|06/04/2015
    APPLE INC.|21000002289|20150603B|06/01/2015|80.00|AX Test|1011|4000010|AU00-00000-101000-ACE-00-000|06/04/2015
    APPLE INC.|21000002289|20150603B|06/01/2015|80.00|AX Test|1011|4000010|US00-DLSMD-102000-000-10-AC3|06/04/2015
    6|$$$6100$$$


    MBH

    Thursday, June 11, 2015 3:44 PM
  • If I am using '//' ..it is taking sum of all the lines, I just need the sum of matching ones as mentioned bold in the above . How is this possible ?

    xsl:templatematch="/">
    <xsl:value-ofselect='sum(//a)'/>
    </xsl:template>

      

    MBH

    Thursday, June 11, 2015 4:23 PM
  • Iam stuck here, anybody has any suggestions on how to achieve this scenario will be great help.

    MBH

    Friday, June 12, 2015 3:08 AM
  • Use conditional XSLT

    <xsl:value-of select="sum(//parentOfa[someid = myid]/a)" />

    Morten la Cour

    Friday, June 12, 2015 4:51 AM
  • Morten, what does it mean ? someid = my id ? Do I need to provide any fields/elements present in my schema for thst my id ? Or its an default expression ?

    MBH

    Friday, June 12, 2015 10:53 AM
  • If I use the above condition its giving '0' output

    <ReqAmt>0</ReqAmt> .

    For the above test file mentioned, I need output in the Header like ...

    1100

    7171

    248


    MBH

    Friday, June 12, 2015 11:29 AM
  • Hi

    Morten has just explained a way of doing it. you should not translate it literally to your application.

    Basically, you need to access the parent invoice, identifying it by some ID (invoideID), and sum all the amount fields of this invoice. (I understand that it's the result you are expecting).

    Can you post the XML you are processing?. It could help.

    It should be something like that, but we can accurate better with the source XML.

    <xsl:value-of select="sum(//invoice[id = myid]/amount)" />
    Where myid should be the identifier of the invoide you are processing.

    Regards.


    When an answer is helpful, please vote as helpful, propose as answer and/or mark as answer


    • Edited by ohawari Friday, June 12, 2015 11:40 AM
    Friday, June 12, 2015 11:38 AM
  • I tried this, but it didn't work

    <ReqAmt>
        <xsl:value-of select="sum(//invoice[id = invoice]/amount)" />              
    </ReqAmt> 

    this is the screenshot of my schema


    MBH


    • Edited by JaguarsJag Friday, June 12, 2015 11:47 AM info
    Friday, June 12, 2015 11:44 AM
  • You can store the ID of the invoice you are currently processing;

    <xsl:variable name="var1" select="./id/text()" />

    Then in the SUM, set the following:

     <xsl:value-of select="sum(//invoice[id = $var1]/amount)" />
    Regards


    When an answer is helpful, please vote as helpful, propose as answer and/or mark as answer

    Friday, June 12, 2015 12:43 PM
  • Hi,

    You can use your key for that:

    use sum(key('groups',invoice)/amount) in ReqAmount

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

    Regards,


    René

    • Marked as answer by JaguarsJag Friday, June 12, 2015 1:40 PM
    Friday, June 12, 2015 1:06 PM
  • Thanks Rene, that did the track.

    Appreciate guys for help


    MBH

    Friday, June 12, 2015 1:41 PM
  • I have below XSLT which is producing output in element form, but my schema is in attribute. I want my output to be generated in attribute form. How can I achieve this ?

    <?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.Serengeti.Schemas.Invoices" xmlns:ns0="http://Munchein.Grouping">
      <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" >
      
        <Root>
          <xsl:for-each select="invoice[generate-id(.)=generate-id(key('groups',invoice))]">
    
            <xsl:sort select="id" order="ascending"/>
    
            <req>
    
              <CpnyId>
                <xsl:value-of select="1011"/>
              </CpnyId>
              
              <!--VendorID-->
              <VendId>
                <xsl:value-of select="id/text()"/>
              </VendId>
    
               <!--InvoiceID-->
              <InvcNbr>
                <xsl:value-of select="invoice/text()"/>
              </InvcNbr>
    
              <!--InvoiceDate-->
    
              <InvcDate>
                <xsl:value-of select="concat(substring(date,7,4),substring(date,1,2),substring(date,4,2))" />        
             </InvcDate>
                 
               <ReqAmt>
            <xsl:value-of  select="sum(key('groups', invoice)/amount)"/>
               </ReqAmt>
               
             <!--<Detail>-->
    
              <xsl:for-each select="key('groups',invoice)">
                <rit>
                  <CpnyId>
                    <xsl:value-of select="company"/>
                  </CpnyId>
    
                  <Acct>
                    <xsl:value-of select="account"/>
                  </Acct>
    
                  <Sub>
                    <xsl:value-of select="subaccount"/>
                  </Sub>
    
                  <TranAmt>
                    
                    <xsl:value-of select="amount"/>
                  </TranAmt>
    
                  <Descr>
                    <xsl:value-of select="description"/>
                  </Descr>
    
                </rit>
    
              </xsl:for-each>
              <!-- </Detail>-->
            </req>
    
          </xsl:for-each>
        </Root>
    
      </xsl:template>
    </xsl:stylesheet>
    
    

    Output schema :


    MBH

    Monday, June 15, 2015 2:20 PM
  • Replace the element names with: <xsl:attribute name="[elementname]">, i.e. for the above replace <CpnyId> with <xsl:attribute name="CpnyId"> and </CpnyId> with </xsl:attribute>.Do the same for the other elements.

    Regards,

    René

    Monday, June 15, 2015 2:25 PM
  • The above XSLT is throwing following error on validation. How can I fix this ?

    Error 2 The 'InvcDate' attribute is invalid - The value '20150603' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:date' - The string '20150603' is not a valid Date


    MBH

    Monday, June 15, 2015 2:38 PM
  • Provide a valid date to the attributes value like '2015-06-03'.

    From your initial post it looks like your removing the hyphens from the date, which leads to an invalid date according to the XSD specs. 

    Monday, June 15, 2015 2:43 PM
  • so how should I update my logic in XSLT ?

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


    MBH

    Monday, June 15, 2015 2:45 PM
  • Depends how date looks like in your source document, if it is 2015-06-03 you can just use <xsl:value-of select="date"/>, otherwise you can use <xsl:value-of select="concat(substring(date,7,4), '-',substring(date,1,2),'-',substring(date,4,2))"/>
    Monday, June 15, 2015 3:09 PM
  • this is the format of date in source file : 06/03/2015.

    The destination field is of datatype 'date'


    MBH


    • Edited by JaguarsJag Monday, June 15, 2015 3:15 PM info
    Monday, June 15, 2015 3:11 PM
  • Then use the second approach, assuming the '06' is the month part of the date.
    Monday, June 15, 2015 3:13 PM
  • yes '06' is month, 03 is date, 2015 is year.

    But in 2nd approach we are making that to string (substring format) but the destination field is date (data type). Is that still ok ?


    MBH

    Monday, June 15, 2015 3:18 PM
  • Yes, you're reformatting the string to represent the string in the proper XSD date format, i.e. yyyy-MM-dd
    Monday, June 15, 2015 3:20 PM
  • Hello Rene, for the above XSLT on top of this forum, the <req> record is been created based on invoice attribute being unique, I am having hard time to fix the above XSLT. The logic should be updated by creating records when having unique invoice and id fields. How can I update my logic?

    MBH

    Tuesday, June 23, 2015 3:10 PM
  • Replace the following:

    <xsl:key name="groups" match="invoice" use="invoice"/>

    with

    <xsl:key name="groups" match="invoice" use="concat(invoice, '#', id)"/>

    and

    <xsl:for-each select="invoice[generate-id(.)=generate-id(key('groups',invoice))]">

    with

    <xsl:for-each select="invoice[generate-id(.)=generate-id(key('groups',concat(invoice, '#', id)))]">

    and

    <xsl:for-each select="key('groups',invoice)">with

    <xsl:for-each select="key('groups',concat(invoice, '#', id)">

    • Marked as answer by JaguarsJag Tuesday, June 23, 2015 6:20 PM
    Tuesday, June 23, 2015 5:20 PM
  • Hello Rene, after changing as above suggested the structure works fine...but the field "ReqAmt" is populating null ?

    The amount was populating correct before changing the key with 'invoice' and 'id'. Now after changing it, it is outputting as '0' ??

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


    MBH


    • Edited by JaguarsJag Tuesday, June 23, 2015 7:45 PM info
    Tuesday, June 23, 2015 7:32 PM
  • Ah missed that one, that should be changed identically, i.e.

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

    Tuesday, June 23, 2015 8:54 PM
  • Hello Rene, for the above XSLT at the starting of this page...the requirement is, if SubAccount is having some valid data send it out and if there is value coming  as   (----) only 4 dashes, send empty data (null) out.

    How can I update my XSLT ?

                  <Sub>
                    <xsl:value-of select="subaccount"/>
                  </Sub>
    
    


    MBH

    Thursday, July 2, 2015 2:45 PM
  • <Sub>
    		<xsl:if test="subaccount != '----'">
    			<xsl:value-of select="subaccount" />
    		</xsl:if>
    </Sub>

    Morten la Cour



    • Edited by la Cour Thursday, July 2, 2015 5:23 PM
    • Marked as answer by JaguarsJag Thursday, July 2, 2015 8:37 PM
    Thursday, July 2, 2015 5:21 PM
  • Hi la Cour, for the above XSLT what I am producing is working, but now the change is if the data is coming empty in any of the fields, that record should not be populated. The source and destination schema is same

    My schema is below :

    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://Brightstar.Integration.Serengeti.IPM.Schemas.IPM_SR" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="Root">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="1" maxOccurs="unbounded" name="req">
              <xs:complexType>
                <xs:sequence>
                  <xs:element minOccurs="1" maxOccurs="unbounded" name="rit">
                    <xs:complexType>
                      <xs:simpleContent>
                        <xs:extension base="xs:string">
                          <xs:attribute name="CpnyId" type="xs:string" use="required" />
                          <xs:attribute name="Acct" type="xs:string" use="required" />
                          <xs:attribute name="Sub" type="xs:string" use="optional" />
                          <xs:attribute name="TranAmt" use="required">
                            <xs:simpleType>
                              <xs:restriction base="xs:decimal">
                                <xs:minExclusive value="0" />
                              </xs:restriction>
                            </xs:simpleType>
                          </xs:attribute>
                          <xs:attribute name="Descr" type="xs:string" use="required" />
                        </xs:extension>
                      </xs:simpleContent>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute name="CpnyId" type="xs:string" use="required" />
                <xs:attribute name="VendId" type="xs:string" use="required" />
                <xs:attribute name="InvcNbr" type="xs:string" use="required" />
                <xs:attribute name="InvcDate" type="xs:date" use="required" />
                <xs:attribute name="ReqAmt" use="required">
                  <xs:simpleType>
                    <xs:restriction base="xs:decimal">
                      <xs:minExclusive value="0" />
                    </xs:restriction>
                  </xs:simpleType>
                </xs:attribute>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
        <xs:unique name="VendId_InvcNbr">
          <xs:selector xpath="req" />
          <xs:field xpath="@CpnyId" />
          <xs:field xpath="@VendId" />
          <xs:field xpath="@InvcNbr" />
        </xs:unique>
      </xs:element>
    </xs:schema>

    The xml instance for below is

    <?xml version="1.0" encoding="utf-8"?>
    <ns0:Root xmlns:ns0="http://Brightstar.Integration.Serengeti.IPM.Schemas.IPM_SR">
    	<req CpnyId="1011" VendId="21000002395" InvcNbr="INVOICE-S04" InvcDate="2015-06-05+00:00" ReqAmt="62442.81">
    		<rit CpnyId="1011" Acct="6005000" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="36558.51" Descr="BLACK ERROR: LINE OK L1" />
    		<rit CpnyId="1011" Acct="6005000" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="25884.30" Descr="BLACK ERROR: LINE OK L2" />
    	</req>
    	<req CpnyId="1011" VendId="21000002396" InvcNbr="INVOICE-S04" InvcDate="2015-06-05+00:00" ReqAmt="61510.560000000005">
    		<rit CpnyId="1011" Acct="" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="48952.23" Descr="BLACK ERROR - ACCOUNT - ERROR LINE L3" />
    		<rit CpnyId="1011" Acct="6005000" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="12558.33" Descr="BLACK ERROR: LINE OK L4" />
    	</req>
    	<req CpnyId="1011" VendId="21000002397" InvcNbr="INVOICE-S04" InvcDate="2015-06-05+00:00" ReqAmt="55998.86">
    		<rit CpnyId="1037" Acct="6005000" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="20456.87" Descr="BLACK ERROR: LINE OK L5" />
    		<rit CpnyId="1011" Acct="6005000" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="35541.99" Descr="BLACK ERROR: LINE OK L6" />
    	</req>
    	<req CpnyId="1011" VendId="21000002398" InvcNbr="INVOICE-S04" InvcDate="2015-06-05+00:00" ReqAmt="62442.81">
    		<rit CpnyId="1037" Acct="6005000" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="" Descr="BLACK ERROR - AMOUNT - ERROR LINE L7" />
    		<rit CpnyId="1011" Acct="6005000" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="39452.21" Descr="BLACK ERROR - DATE - ERROR LINE L8" />
    	</req>
    </ns0:Root>

    You see in above xml instance in bold data is empty, if so I don't need to create that record, skip that record. I am having hard time doing this by putting logic through scripting functoids as its disassembling each other. How can we achieve this using XSLT ?

    This is my current 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 userCSharp" version="1.0" xmlns:ns0="http://Brightstar.Integration.Serengeti.IPM.Schemas.IPM_SR" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp">
      <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
       <xsl:template match="/">
        <xsl:apply-templates select="/ns0:Root" />
      </xsl:template>
       <xsl:template match="/ns0:Root">
         <ns0:Root>
           <xsl:for-each select="req">
            <xsl:variable name="var:v1" select="userCSharp:Test(string(@VendId) , string(@InvcNbr) , string(@InvcDate) , string(rit/@TranAmt) , string(rit/@CpnyId) , string(rit/@Acct) , string(@ReqAmt))" />
            <xsl:variable name="var:v2" select="userCSharp:LogicalEq(string($var:v1), 'true')"/>
           <xsl:if test="$var:v2">
              <req>
                 <xsl:attribute name="CpnyId">
                  <xsl:value-of select="@CpnyId" />
                </xsl:attribute>
                 <xsl:attribute name="VendId">
                  <xsl:value-of select="@VendId" />
                </xsl:attribute>
                 <xsl:attribute name="InvcNbr">
                  <xsl:value-of select="@InvcNbr" />
                </xsl:attribute>
                 <xsl:attribute name="InvcDate">
                  <xsl:value-of select="@InvcDate" />
                </xsl:attribute>
                 <xsl:attribute name="ReqAmt">
                  <xsl:value-of select="@ReqAmt" />
                </xsl:attribute>
                 <rit>
                  - <xsl:attribute name="CpnyId">
                    <xsl:value-of select="rit/@CpnyId" />
                  </xsl:attribute>
                   <xsl:attribute name="Acct">
                    <xsl:value-of select="rit/@Acct" />
                  </xsl:attribute>
                   <xsl:if test="rit/@Sub">
                     <xsl:attribute name="Sub">
                      <xsl:value-of select="rit/@Sub" />
                    </xsl:attribute>
                  </xsl:if>
                   <xsl:attribute name="TranAmt">
                    <xsl:value-of select="rit/@TranAmt" />
                  </xsl:attribute>
                   <xsl:attribute name="Descr">
                    <xsl:value-of select="rit/@Descr" />
                  </xsl:attribute>
                </rit>
              </req>
            </xsl:if>
          </xsl:for-each>
        </ns0:Root>
      </xsl:template> 
    </xsl:stylesheet>

    i.e When VedId ,InvcNbr ,InvcDate , TranAmt, CpnyId, Acct , ReqAmt are not empty then populate the records or else skip it.


    MBH




    • Edited by JaguarsJag Monday, July 6, 2015 10:07 PM INFO
    Monday, July 6, 2015 8:31 PM
  • Hi La Cour, do you know how can I achieve this above scenario ? I am stuck. You help will be highly appreciated.

    MBH

    Tuesday, July 7, 2015 1:43 PM