none
XSLT - not to populate '0' in the output when the element is empty in input RRS feed

  • Question

  • Hi - In my Input file, there might not be occurrence of  have the field 'LineItemSubTotal'. If its not there, but in the output its still creating the field with value as'0' .

    My requirement is, if there is not input field then output field should also not be created. Below is my XSLT logic.

    <xsl:variable name="SeqTotal" select="sum(//Details[SenderNumber = $Sendnum and SequenceNumber = $SeqNumber]/LineItemSubTotal/text())"/>      


    P1



    • Edited by Reason101 Thursday, March 9, 2017 4:42 AM I
    Friday, February 24, 2017 3:23 AM

Answers

  • Just check for existence of LineItemSubTotal before the mapping.

    Something like:

    <xsl:if test="LineItemSubTotal">

    <xsl:variable name="SeqTotal" select="sum(//Details[SenderNumber = $Sendnum and SequenceNumber = $SeqNumber]/LineItemSubTotal/text())"/>  

     </xsl:if>



    Rachit Sikroria (Microsoft Azure MVP)

    Friday, February 24, 2017 3:36 AM
    Moderator