Xslt 1.0中的递归循环

时间:2017-06-01 20:26:00

标签: recursion xslt-1.0 bi-publisher oracle-apps

我正在进行递归循环。以下是示例代码。

循环只执行一次。它在达到最大计数(20次)之前不会执行。

如果这是一个问题,你能帮忙吗?

谢谢, 拉吉

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xdoxslt='http://www.oracle.com/XSL/Transform/java/oracle.apps.xdo.template.rtf.XSLTFunctions'>
<xsl:output method="text" omit-xml-declaration="yes" />
   <xsl:variable name="nl">
      <xsl:value-of select="'&#xD;'"/>
      <xsl:text xml:space="preserve">&#10;</xsl:text>
   </xsl:variable>
   <xsl:template match = "ARCHIVE_CHEQUE_WRITER">
      <xsl:for-each select="CHEQUE">
         <xsl:variable name="ded" select="./AC_DEDUCTIONS"/>
         <xsl:variable name="dedcount" select="count($ded)"/>
         <xsl:variable name="earn" select="./AC_EARNINGS"/>
         <xsl:variable name="earncount" select="count($earn)"/>
         <xsl:value-of select="$dedcount"/>
         <xsl:value-of select="$nl"/>
         <xsl:value-of select="$earncount"/>
         <xsl:value-of select="$nl"/>        
         <xsl:text>Starting New Record*******</xsl:text>
         <xsl:value-of select="$nl"/>
            <xsl:for-each select="./AC_DEDUCTIONS">
                  <xsl:text>This is sample template</xsl:text>
                  <xsl:value-of select="$nl"/>
            </xsl:for-each>
         <xsl:value-of select="$nl"/>
         <xsl:value-of select="$nl"/>
         <xsl:call-template name="recursive-loop">          
            <xsl:with-param name="pCount" select="20"/>
         </xsl:call-template>
      </xsl:for-each>
   </xsl:template>
   <xsl:template name="recursive-loop">
      <xsl:param name="pStart" select="1"/>
      <xsl:param name="pCount"/>
      <xsl:text> value of parameters</xsl:text>
      <xsl:value-of select="$nl"/>
      <xsl:value-of select="$pStart"/>
      <xsl:value-of select="$pCount"/>
      <xsl:value-of select="$nl"/>    
      <xsl:if test="$pCount > pStart">
         <xsl:call-template name="recursive-loop">
            <xsl:with-param name="pStart" select="$pStart+1"/>
            <xsl:with-param name="pCount" select="$pCount"/>
         </xsl:call-template>
      </xsl:if>   
   </xsl:template>
</xsl:stylesheet>

1 个答案:

答案 0 :(得分:1)

您忘记在模板中使用$作为变量pStart

<xsl:if test="$pCount > $pStart">
    <xsl:call-template name="recursive-loop">
        <xsl:with-param name="pStart" select="$pStart+1"/>
        <xsl:with-param name="pCount" select="$pCount"/>
    </xsl:call-template>
</xsl:if>