You may need to customize the href
attributes generated in the HTML output beyond what you can do with stylesheet parameters. For example, your hrefs may require a different form for a help system, or for an HTTP server that remaps hrefs.
If you need complete control of generated hrefs, then consider customizing the template named href.target
. That template has two input parameters: context
is the element containing the link source, and target
is the element that is the destination of the link. The output of the template depends on whether or not you are using the chunking stylesheet.
There are two versions of the href.target
template:
For non-chunked output, the href.target
template in html/html.xsl
simply adds the #
character in front to the id
of the target of the link. If the target element does not have an id
attribute, then the stylesheet uses the generate-id()
function to create one.
For chunked output, the href.target
template in html/chunk-common.xsl
has to do quite a bit more, including the following:
It must determine if the target is a chunked element. If so, it must get the chunk filename.
If the target is inside a chunked element, it must add the #
and id
of the target.
It must compute the relative path from the file containing the link to the target file. They may be in different directories because the dbhtml dir
processing instruction was used. See the section “dbhtml dir processing instruction” for more details.
Customizing the non-chunked version is relatively easy. Customing the chunking version requires more care because it does so much more, and because it uses several other templates. Depending on what kind of changes you need to make to hrefs, you might need to trace through the sequence of templates to see where best to apply your changes.
When you customize templates from the chunking stylesheet modules, be sure to put them in the customization layer that handles chunking behavior, as described in the section “Chunking customization”.
DocBook XSL: The Complete Guide - 4th Edition | PDF version available | Copyright © 2002-2007 Sagehill Enterprises |