xsl-list
[Top] [All Lists]

## Re: [xsl] Unexpected result from <a href="...">...</a> in some cases

2008-08-19 22:18:49
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

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

 Current Thread [xsl] Unexpected result from ... in some cases, Quinn Taylor Re: [xsl] Unexpected result from ... in some cases, G. Ken Holman Re: [xsl] Unexpected result from ... in some cases, Quinn Taylor Re: [xsl] Unexpected result from ... in some cases, Quinn Taylor Re: [xsl] Unexpected result from ... in some cases, G. Ken Holman Re: [xsl] Unexpected result from ... in some cases, Quinn Taylor Re: [xsl] Unexpected result from ... in some cases, Quinn Taylor <= Re: [xsl] Unexpected result from ... in some cases, Quinn Taylor