user3757953
user3757953

Reputation: 3

xslt for-each statement displaying duplicates

This is the xml:

          <root>
            ...
            <payment-schedule>
              <loan>
                <l-number id='0'>00321-123456789-01</l-number>
                <financed id='0'>2500.0000</financed>
              </loan>
              <loan>
                <l-number id='1'>00321-123456789-02</l-number>
                <financed id='1'>3000.0000</financed>
              </loan>
            </payment-schedule>
          </root>

This is the xslt:

          <!--Repeating Rows Displays Loans-->
          <xsl:apply-templates select="loan"/>

          </xsl:template>

          <xsl:template match="loan">
            <xsl:for-each select="/root/payment-schedule/loan">
              <fo:table-row>
                <fo:table-cell border-right-style="solid" border-width="0.2mm" padding-left="2mm">
                </fo:table-cell>
                <fo:table-cell border-right-style="solid" border-width="0.2mm" padding-left="2mm">
                  <fo:block font-weight="bold">
                    <xsl:value-of select="l-number" />:  $<xsl:value-of select='format-number(financed, "#.00")'/>
                  </fo:block>
                </fo:table-cell>
              </fo:table-row>
            </xsl:for-each>
          </xsl:template>

Here is the output:

00321-123456789-01:  $2500.00
00321-123456789-02:  $3500.00
00321-123456789-01:  $2500.00
00321-123456789-02:  $3500.00

I have spent way too much time trying to remove these duplicate nodes. Help!!!!

Upvotes: 0

Views: 229

Answers (1)

Ian Roberts
Ian Roberts

Reputation: 122414

You have a template that fires once for each loan, and in that template you're again doing a for-each over all the loan elements. Remove the for-each and you should get the result you require.

 <xsl:template match="loan">
   <fo:table-row>
     <!-- ... -->

Upvotes: 1

Related Questions