xsl-list
[Top] [All Lists]

Re: [xsl] Stumped: XSL 1.0 recursive template

2010-11-17 08:36:51
Sorry quick revision. I had to put the "[1]" in both the "when" test
<xsl:when test="$fincodeParam = $nextRecordParam----[1]----/@desc">
and when recursively calling the template.

On Wed, Nov 17, 2010 at 9:31 AM, daniel whitney 
<dbf(_dot_)whitney(_at_)gmail(_dot_)com> wrote:
Thanks for the response Brandon. But I'm still having problems
understanding what's happening here. With the example I provided the
attribute values I am comparing are:
60, 60.09, 60.09, 60.09, 80.

The comparisons being returned are:
False, True, True, True. It's the last test evaluating to True that
confuses me. Why when I'm on the last desc value of 60.09 and the
following-sibling value is 80 (which is the last RECORDSECTION in the
transform) does it evaluate to TRUE? As a test I changed all the desc
values so that they were unique. I ran the transform and every test
came back True except for the first one.

So I fooled around with your suggestion and found that by putting the
[1]  when I recusively calling the template it worked. But I don't
know why.

     <xsl:call-template name="financialTemp">
       <xsl:with-param name="nextRecordParam"
select="$nextRecordParam[position() &gt; 1]"/>
       <xsl:with-param name="fincodeParam"
select="$nextRecordParam----[1]----/@desc"/>
     </xsl:call-template>

Thanks,

Dan

On Tue, Nov 16, 2010 at 3:33 PM, Brandon Ibach
<brandon(_dot_)ibach(_at_)single-sourcing(_dot_)com> wrote:
On Tue, Nov 16, 2010 at 2:09 PM, daniel whitney 
<dbf(_dot_)whitney(_at_)gmail(_dot_)com> wrote:
Sorry if this gets posted twice ...

I'm stumped. I cannot figure out why the @desc test in the
financialTemp template is always evaluating to true, when the values
being output are different.
I'm simply trying to remove lines with the same desc attribute value
in the RECORDSECTION[(_at_)colformat='colbody'] elements.

The test is:   $fincodeParam = $nextRecordParam/@desc

This will evaluate to true if the string value of $fincodeParam (the
value of the "desc" attribute of the RECORDSECTION currently being
processed) is equal to the value of the "desc" attribute of ANY
following-sibling RECORDSECTION whose "colformat" attribute has a
value of "colbody".

I think you'll get what you want by putting a "[1]" before "/@desc" in
the above test.

-Brandon :)

          <xsl:for-each 
select="//RECORDSECTION[(_at_)colformat='colbody'][1]">
            <xsl:call-template name="financialTemp">
              <xsl:with-param name="nextRecordParam"
select="following-sibling::RECORDSECTION[(_at_)colformat='colbody']"/>
              <xsl:with-param name="fincodeParam" select="@desc"/>
            </xsl:call-template>
          </xsl:for-each>

  <xsl:template name="financialTemp">
    <xsl:param name="nextRecordParam"/>
    <xsl:param name="fincodeParam"/>

    <xsl:if test="$nextRecordParam[1]">
      <xsl:choose>
        <xsl:when test="$fincodeParam = $nextRecordParam/@desc">
[...]
        </xsl:when>
        <xsl:otherwise>
[...]
        </xsl:otherwise>
      </xsl:choose>
      <xsl:call-template name="financialTemp">
        <xsl:with-param name="nextRecordParam"
select="$nextRecordParam[position() &gt; 1]"/>
        <xsl:with-param name="fincodeParam" 
select="$nextRecordParam/@desc"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>