Home > Enterprise >  Adding Count For each multiple conditions loop and returning total records XSLT
Adding Count For each multiple conditions loop and returning total records XSLT

Time:03-08

<xsl:variable name="z">0</xsl:variable>
<xsl:variable name="x">0</xsl:variable>
  <xsl:for-each select="wd:Report_Entry">
    <xsl:choose>
      <xsl:when test="count(wd:Supplier_Invoice_Line_group)>1">
        <xsl:for-each select="wd:Supplier_Invoice_Line_group">
          <xsl:value-of select="$z =$z 1 "/>
         </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$x =$x 1 "/>
        </xsl:otherwise>
    </xsl:choose>
    </xsl:for-each>
<xsl:value-of select="$x $z"/>

I'm not getting any results for the above conditions. I'm trying to declare 2 variables for 2 different loops. Then adding those records to get total counts. Appreciate if anyone can guide me.

CodePudding user response:

It seems where you have <xsl:value-of select="$x $z"/> you just could use <xsl:value-of select="sum((wd:Report_Entry/count(wd:Supplier_Invoice_Line_group), count(wd:Report_Entry[not(wd:Supplier_Invoice_Line_group)])))"/>. That assumes XSLT 2 or later.

  • Related