This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
[docbook-apps] Re: user.head.contentend patch for docbook-xsl 1.62.4
On Fri, Oct 31, 2003 at 02:31:42PM +0100, W. Borgert wrote:
> Hello,
>
> I need to include a JavaScript code snippet into all HTML chunks
> for CHM/htmlhelp. This script is necessary for the MS-HTML Help
> when printing "selected heading and all subtopics". Without the
> code snippet, other scripts (via <SCRIPT SRC=...> would not be
> found by HTML Help and the look-and-feel of the print-out would
> be wrong. Bob gave me the very good hint to use the template
> user.head.content, but unfortunately the JavaScript code has to
> be below the HTML link elements, not before. I therefore made
> a patch introducing a new user.head.contentend, which fits
> perfectly for me. I use it only in (x)html/chunk-common.xsl,
> maybe it would be better to use it in (x)html/graphics.xsl and
> (x)html/titlepage.xsl as well. The patch only adds 14 lines, so
> please apply it to docbook-xsl. Feel free to use a better name
> for the template than user.head.contentend :-)
>
> Usage example:
>
> File fix.js:
>
> <script language="JavaScript" type="text/javascript"><!--
> function nul(){return}
> if(null!=document.styleSheets&&0<document.styleSheets.length)
> document.write('<'+'SCRIPT LANGUAGE="JavaScript" SRC="'+
> document.styleSheets[0].href.
> replace(new RegExp('::[\\\\/:](\\.\\.[\\\\/:])+'),'::/').
> replace(new RegExp('[^\\\\/:]+$'),'')+'other.js"><'+'/SCRIPT>');
> //--></script>
>
> In the XSL driver (thanks to Bob Stayton):
>
> <xsl:template name="user.head.contentend">
> <link rel="StyleSheet" href="style/my.css"/>
> <xsl:copy-of select="document('../my.path/fix.js',/)"/>
> </xsl:template>
>
> The patch is attached.
That would make for *three* user level templates
to generate head content (system.head.content is the
other one). How about if we just move the
call to the user.head.content template to the
end of the <head> element? Looking at the
usage in docbook.xsl, I think that was the original
intent anyway:
<head>
<xsl:call-template name="system.head.content">
<xsl:with-param name="node" select="$doc"/>
</xsl:call-template>
<xsl:call-template name="head.content">
<xsl:with-param name="node" select="$doc"/>
</xsl:call-template>
<xsl:call-template name="user.head.content">
<xsl:with-param name="node" select="$doc"/>
</xsl:call-template>
</head>
If we do this for the chunking templates, then
you would get the last word using the existing
user.head.content template.
--
Bob Stayton 400 Encinal Street
Publications Architect Santa Cruz, CA 95060
Technical Publications voice: (831) 427-7796
The SCO Group fax: (831) 429-1887
email: bobs@sco.com
To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.