Here is how to do it: Create a brand xhtml.xsl: <?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0' xmlns="http://www.w3.org/TR/xhtml1/transitional" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="#default"> <!-- Import the Docbook stylesheets --> <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/> <xsl:import href="../../../xsl/html-single.xsl"/> <!-- Now inject our javascript into the head --> <!-- through the user.header.content parameter --> <xsl:template name="user.header.content"> <xsl:variable name="codefile" select="document('Common_Content/mycode.html',/)"/> <xsl:copy-of select="$codefile/htmlcode/node()"/> </xsl:template> --------------------------------- And then put a file into the en-US directory (and others of course) of the brand, called "mycode.html" with this content: <htmlcode> <script type="text/javascript" src="myjavascript.js"/> </htmlcode> --------------------- Put myjavascript.js in the Common_Content of the brand, and it will be included.
From here: http://www.sagehill.net/docbookxsl/InsertExtHtml.html
Actually, I could only get it to work through html.xsl and html-single.xsl. Additionally, I put the script inline in the xsl, rather than loading it from an external file. Here's the relevant portion of html-single.xsl: <!-- inject our javascript into the head --> <!-- http://www.sagehill.net/docbookxsl/InsertExtHtml.html --> <xsl:template name="user.head.content"> <script type="text/javascript" src="Common_Content/skynet-book.js"/> </xsl:template> <!-- set the onload of the page --> <!-- http://www.sagehill.net/docbookxsl/BodyAtts.html --> <xsl:template name="body.attributes"> <xsl:attribute name="onLoad">skynetBookLoad()</xsl:attribute> </xsl:template> ------------------------------------- It looks like arbitrary files in the Common_Content directory are not included in the brand. Looking for a way to get the javascript in. Current workaround is to use a URL.
You can put the javascript file into either css or images and it will be included. It won't work in Common_Content itself, because publican will only accept .xml files there, and tries to validate them as xml.
This site: http://friendlybit.com/js/lazy-loading-asyncronous-javascript/ Shows how to do lazy asynchronous loading of javascript via a small function in the <head> element. This might be the way to go. So we would inject this into the <head>: <script type="text/javascript"> (function() { function async_load(){ var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = u'css/skynetbook.js'; var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); } if (window.attachEvent) window.attachEvent('onload', async_load); else window.addEventListener('load', async_load, false); })();</script>
Broken in Publican 3 atm...
Fixed in Publican 3.1 and rocking hard!