1 Reply Latest reply: Nov 1, 2012 12:04 PM by SRAY01 RSS

    How to import an XML element into a loop parameter is XSL

    SRAY01
      Hi,
      We are using XSL template to generate output in a pdf format. The input in an XML file. In the XSL we have a loop. Currently the initial and final value of the loop counter is hardcoded in the xsl file.

      <xsl:call-template name="forloop">
           <xsl:with-param name="i">1</xsl:with-param>
           <xsl:with-param name="count">6</xsl:with-param>
      </xsl:call-template>

      Down below we are using
           <xsl:template name="forloop">
                <xsl:param name="i"/>
                <xsl:param name="count"/>
                <xsl:if test="$i &lt;=$count">
                     <fo:table-row>
      ---
                     <xsl:call-template name="forloop">
                          <xsl:with-param name="i">
                               <xsl:value-of select="$i + 1"/>
                          </xsl:with-param>
      etc, etc.

      Query :
      Currently the final value of the loop is hardcoded to 6. I want to set its value based of an element BAR_CODE_PRINT_NUM value (which can be either 0 or 6) of the XML File.
      <LIST_G_BAR_CODE_PRINT>
      <G_BAR_CODE_PRINT>
      <BAR_CODE_PRINT>Y</BAR_CODE_PRINT>
      <BAR_CODE_PRINT_NUM>6</BAR_CODE_PRINT_NUM>
      </G_BAR_CODE_PRINT>
      </LIST_G_BAR_CODE_PRINT>

      Can anyone please tell me how this is to be done. I have tried the following but it did not work.
      Approach 1 :
      <xsl:if test="LIST_G_BAR_CODE_PRINT/G_BAR_CODE_PRINT/BAR_CODE_PRINT_NUM &gt; 3">
           <xsl:with-param name="count">6</xsl:with-param>
      </xsl:if>
      <xsl:if test="LIST_G_BAR_CODE_PRINT/G_BAR_CODE_PRINT/BAR_CODE_PRINT_NUM &lt; 3">
           <xsl:with-param name="count">0</xsl:with-param>
      </xsl:if>
      Approach 2 :
      <xsl:with-param name="count"><xsl:value-of disable-output-escaping="no" select="LIST_G_BAR_CODE_PRINT/G_BAR_CODE_PRINT/BAR_CODE_PRINT_NUM"/>
      </xsl:with-param>

      Thanks