[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: Re: DOCBOOK-APPS: How to structure XSL stylesheets for chunking andnon-chunking
> From: Dan York <dyork@e-smith.com> > > Question for those of you working with XSL stylesheets.... for both > my work here at e-smith/Mitel and also some of the stuff I do with the > Linux Documentation Project, I need to generate both chunked and > non-chunked HTML files from various DocBook files and I need a > customization layer to modify certain settings in Norm's XSL stylesheets. > > With SGML/DSSSL, it seems chunking was handled by the *processor*, so > we all simply passed (open)jade the "-V nochunks" option when we did > NOT want chunking. The DSSSL customization layer could work for both. > > With XML/XSL, chunking is handled by the *stylesheet*, so there is now > a need for two stylesheets - one for chunking and one for not. However, > basically everything in the two stylesheets is the same. What is different > is whether the stylesheet calls Norm's 'html/docbook.xsl' (non-chunking) > or 'html/chunk.xsl' (chunking). > > So the question really is - how do you structure a customization layer > to sit on top of Norm's stylesheets? > > The solution I have come up with actually uses *three* stylesheets. > > I put all my customizations in an XSL stylesheet called > 'e-smith-common.xsl'. This stylesheet does NOT do an <xsl:import> to > Norm's XSL stylesheets. It just has all my customizations. > > I then have two other stylesheets. One is called simply 'e-smith.xsl' > and has the contents: > > <?xml version="1.0"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:import href="/usr/share/sgml/docbook-xsl-1.41/html/docbook.xsl"/> > <xsl:import href="e-smith-common.xsl"/> > > </xsl:stylesheet> > > The other stylesheet, 'e-smith-chunk.xsl', is the same as the above > except that it imports 'chunk.xsl' instead of 'docbook.xsl'. Both of > these essentially import the appropriate XSL file from Norm and then > import e-smith-common.xsl. FYI, I used <xsl:import> instead of > <xsl:include> in case I later decided that I wanted to override > e-smith-common.xsl in one or the other of these files. > > So to use them, I just call the appropriate stylesheet. To generate > a single page: > > $ xsltproc -o sample.html /usr/share/sgml/e-smith.xsl sample.xml > > To generate multiple pages: > > $ xsltproc /usr/share/sgml/e-smith-chunk.xsl sample.xml > > It all works fine, and there is no difference between the files generated > this way and those I generated from my single larger stylesheets before. > > So I have a system that works... why I am asking the question? > Well, does anyone have a better way to do this? Is there any way to > NOT have to have two separate stylesheets for chunking or non-chunking? > Is there a way I can have *one* call and call it differently? > > Or is the solution I have come up with the best way to do it? > > Any thoughts or suggestions are welcome. I came up with essentially the same solution once I realized you cannot do conditional imports in XSL. I'll also be curious to hear of other solutions. In the current architecture of the DocBook stylesheets, chunking itself is a customization layer. I believe it would be possible to rewrite the main stylesheets to implement the chunk/no-chunk behavior based on a global parameter and proper attention to XSL modes. Perhaps Norm can comment on why he did it as a customization layer. bobs Bob Stayton 400 Encinal Street Publications Architect Santa Cruz, CA 95060 Technical Publications voice: (831) 427-7796 Caldera International, Inc. fax: (831) 429-1887 email: bobs@caldera.com
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC