[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Stumped: XSL 1.0 recursive template

Subject: Re: Stumped: XSL 1.0 recursive template
From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 17 Nov 2010 10:23:35 -0500
Re:  Stumped: XSL 1.0 recursive template
On Wed, Nov 17, 2010 at 9:31 AM, daniel whitney <dbf.whitney@xxxxxxxxx> 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=@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=@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=@60   nextRecordParam=(RS[60.09], RS[60.09], RS[60.09], RS[80])
        fincodeParam=@xxxxx   nextRecordParam=(RS[60.09], RS[60.09], RS[80])
            fincodeParam=@xxxxx   nextRecordParam=(RS[60.09], RS[80])
                fincodeParam=@xxxxx   nextRecordParam=(RS[80])
                    fincodeParam=@80   nextRecordParam=()

Hope that clears up what was happening.

-Brandon :)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.