[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Re: How to include a JavaScript snippet into htmlhelp files?
On Wed, Oct 29, 2003 at 07:40:54PM +0100, W. Borgert wrote: > [sorry, if this mail is duplicated - the reqest/subscribe > address on the oasis-open web page is wrong, so I'm not sure > whether my posting has been dropped] > > Hello, > > I'm using docbook-xsl successfully to generate HTML and CHM. > Because of problems with the MS help viewer, I had to include > a JavaScript snippet into every single HTML file that is > generated. Referencing the JavaScript does not work, because > the problem has to do with paths (finding external files). > > It was not hard to just patch html/chunk-common.xsl (see below) > to include the JavaScript stuff, but now I have to re-patch > every new version of docbook-xsl. So I would like to have a > variable at that place and just assign the complete script to > that variable. > > Two questions: > > 1. What would be the correct way and syntax to include the > script via a variable instead of patching > html/chunk-common.xsl? As you discovered, patching the stylesheets is a maintenance headache. The stylesheets are designed to be customized using a customization layer that leaves the stock stylesheets intact. This is described in: http://www.sagehill.net/docbookxsl/CustomMethods.html#CustomizationLayer You can customize the template named 'user.head.content', which is designed for including extra stuff in each HTML <head> element. It is defined as empty in the distribution, and it is called when each <head> element is generated. So you can customize it as follows: <xsl:template name="user.head.content"> <xsl:copy-of select="document('myscriptfile.js',/)"/> </xsl:template> This uses the document() function to open the file named myscriptfile.js, and then copy it to the output. The file must be well-formed xml, which just means it must all be enclosed in one element, such as <script>. You can also make the filename argument to the document() function a parameter value and pass the parameter on the command line. > 2. What do I have to do, so that the solution (1.) makes it > into the official docbook-xsl distribution? It isn't necessary if you use this customization. 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
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]