Fixed a bug that caused broken links in some TOCs.
authorMichael Smith <xmldoc@users.sourceforge.net>
Thu, 19 Jul 2007 07:17:45 +0000 (07:17 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Thu, 19 Jul 2007 07:17:45 +0000 (07:17 +0000)
commitfce093affad6261af0e23a52d701a1edba93320d
treef02046a056845bf34ebd218e1c54f5027f0a260c
parent07e20991bc3c1c92e5e3257f545984a749ede327
Fixed a bug that caused broken links in some TOCs.
This change affects the code for generating links in HTML output.
It adds a new optional "toc.context" parameter to the href.target
template, and based on the value of that parameter, handles
link-generation in TOCs differently under a certain condition.

The gory details:

  The code now checks to see if the output dir of any file being
  linked to in a particular TOC is different from the output dir
  the TOC is written to. If it is different, we do not call the
  trim.common.uri.paths[1] template.

  The reason is that, given the following case:

  1. we are chunking into separate dirs

  2. output for the TOC is written to current dir, but the file
     being linked to is written to some subdir "foo".

  For that case, links to that file in that TOC did not show
  the correct path - they omitted the "foo".

  The cause of that problem was that the trim.common.uri.paths
  template was being called under all conditions. But it's
  apparent that we don't want to call trim.common.uri.paths in
  the case where a linked file is being written to a different
  directory than the TOC that contains the link, because doing
  so will cause a necessary (not redundant) directory-name
  part of the link to get inadvertently trimmed, resulting in
  a broken link to that file.

  Thus, the conditional check was added to catch this case and to
  handle it differently

  [1] The purpose of the trim.common.uri.paths template is to
  prevent cases where, if we didn't call it, we end up with
  unnecessary, redundant directory names getting output; for
  example, "foo/foo/refname.html".
xsl/html/autotoc.xsl
xsl/html/chunk-common.xsl