xsl-list
[Top] [All Lists]

Re: [xsl] Stumped: XSL 1.0 recursive template

2010-11-17 09:23:49
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.

There is an additional wrinkle in your original code that I didn't
catch the first time through, but which you essentially caught when
you added the "[1]" to the expression for fincodeParam on the
recursive call.  Using a notation of "@60" for an attribute node with
value "60" and "RS[60]" for a RECORDSECTION element node with a "desc"
attribute with a value of "60", the calls to financialTemp look like
this:

    fincodeParam=(_at_)60   nextRecordParam=(RS[60.09], RS[60.09], RS[60.09], 
RS[80])
        fincodeParam=(@60.09, @60.09, @60.09, @80)
nextRecordParam=(RS[60.09], RS[60.09], RS[80])
            fincodeParam=(@60.09, @60.09, @80)
nextRecordParam=(RS[60.09], RS[80])
                fincodeParam=(@60.09, @80)   nextRecordParam=(RS[80])
                    fincodeParam=(_at_)80   nextRecordParam=()

The last call is a no-op that terminates the recursion.  The first
call gives the "false" response, since the "60" value in fincodeParam
doesn't match any of the @desc values in nextRecordParam.  The next
three all return true if for no other reason than there are "80"
values in both parameters.  By adding the "[1]" into the test, you
only compare with the first @desc value in nextRecordParam.  By
putting "[1]" into the expression for fincodeParam on the recursive
call, the calls look like this:

    fincodeParam=(_at_)60   nextRecordParam=(RS[60.09], RS[60.09], RS[60.09], 
RS[80])
        fincodeParam=(_at_)60(_dot_)09   nextRecordParam=(RS[60.09], RS[60.09], 
RS[80])
            fincodeParam=(_at_)60(_dot_)09   nextRecordParam=(RS[60.09], RS[80])
                fincodeParam=(_at_)60(_dot_)09   nextRecordParam=(RS[80])
                    fincodeParam=(_at_)80   nextRecordParam=()

Hope that clears up what was happening.

-Brandon :)

--~------------------------------------------------------------------
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>