xsl-list
[Top] [All Lists]

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

2008-08-19 16:06:11

On Aug 19, 2008, at 2:41 PM, G. Ken Holman wrote:

At 2008-08-19 14:19 -0600, Quinn Taylor wrote:
I've created a recursive template (printRecursivePath) to process a
directory path and build up a string of links from the right side so
as to correctly increase the number of "../" elements for parent link.

Sorry ... I do not understand what you want.

Sorry, I thought that using the commented code might give an idea, and I was aiming for brevity. I'm not just trying to create a relative path from an absolute path. Allow me to clarify...

I'm using this for browsing Subversion repositories hosted from Apache, using the mod_dav_svn module, which provides XML output that can be styled. (For example, http://svn.macosforge.org/repository/macports/trunk/www/ uses the default XSL file, which I find pretty hideous.) I'm trying to make it easier to link directly to any directory along the path, and any path should include spaces on either side of the slashes, and a "[root]" link at the beginning.

For an example of what I'm talking about, compare the default HTML (http://svn.collab.net/repos/svn/trunk/doc/ ) with the output produced by ViewVC (http://svn.collab.net/viewvc/svn/trunk/doc/ ), specifically the gray bar on the top of the latter.

What result to you expect for your test string "/path/to/resource"?

<a href="../../../">[root]</a> / <a href="../../">path</a> / <a href="../">to</a> / resource

What result to you expect for "/to/resource"?

<a href="../../">[root]</a> / <a href="../">to</a> / resource

What result to you expect for "/resource"?

<a href="../">[root]</a> / resource

What result to you expect for "resource"?

I don't handle this one, since all my paths provided by subversion will have a leading / to indicate the full repository path.

The problem occurs for path components between the first and the last
component.

Because you are not passing your intermediate results to the recursively called template.

Actually, all the text which is generated by a recursive call to the template is saved in a variable using this chunk of code:

<!-- Make a tail-recursive call and store the text result in a variable -->
<xsl:variable name="recursiveResult">
        <xsl:call-template name="printRecursivePath">
                <xsl:with-param name="text" select="$tail"/>
        </xsl:call-template>
</xsl:variable>

If you run my code with the commented code un-commented, you can actually see that $parentPath has the value I want, it just isn't printing out what I need.

<snip>

But I'm only guessing what you want from your succinct description. If you give some examples then someone on the list can probably guide you to the right result.

For now, though, look at what I'm doing below when I pass the intermediate results to the called template ... that may be the bit you are missing. When I write recursive templates I always need to keep track of what is being built along the way, or the intermediate work gets lost. This appears to be the evidence you are presenting, so I'm guessing that is your issue.

Note that even what I have below is incomplete since I don't know what you want to do with "resource" as your input path.

I hope this helps.

. . . . . . . . . . . . Ken

Since I didn't fully explain what I hoped to see, the code you sent doesn't directly solve my problem, but does have some nice things I can glean to hopefully make mine cleaner and more robust.

Thanks,
 - Quinn

<snip>

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