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

Re: Unexpected result from <a href="...">...</a> in so

Subject: Re: Unexpected result from <a href="...">...</a> in some cases
From: Quinn Taylor <quinntaylor@xxxxxxx>
Date: Tue, 19 Aug 2008 21:18:24 -0600
Re:  Unexpected result from <a href="...">...</a> in so
Ken, thanks so much for taking the time to help out. Sure enough, your solution works as advertised. :-)

One thing I'd like to simplify/optimize is the number of recursive descents. It seems that your code recurses all the way down to the base case and back up for each path element to correctly construct the parent href. This is certainly not an O(n^3) algorithm, but it seems like a triangular number (http://mathworld.wolfram.com/TriangularNumber.html ). For very long paths, this creates more work than necessary. Even so, I'll take what works over what doesn't. :-)

- Quinn

Come to think of it, a smart implementation could avoid recursion altogether and opt for a linear algorithm. The whole point is that you need to know how many ../ to string together for each path component. Note that this is always equal to the number of slashes between a given component and the last component. Thus, counting the / in a path (with a judicious use of contains() and substring-after() at the very beginning, then decrementing for each path element should give the correct count. Inside the <a> tags, a simple loop up to the current count should create the correct number of ../ in the link. I'm going to give that a shot as soon as I get my toddler to bed. ;-)

- Quinn

Current Thread


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.
First Name
Last Name
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.