atom feed7 messages in org.oasis-open.lists.docbook-appsRE: DOCBOOK-APPS: How to structure XS...
FromSent OnAttachments
Dan YorkJul 30, 2001 1:02 pm 
Dave Brooks, BCS SystemsJul 30, 2001 2:31 pm 
Jack CushmanJul 30, 2001 2:32 pm 
Jirka KosekJul 30, 2001 2:32 pm 
Bob StaytonJul 30, 2001 4:20 pm 
Bob StaytonJul 30, 2001 4:40 pm 
Norman WalshAug 4, 2001 3:52 pm 
Subject:RE: DOCBOOK-APPS: How to structure XSL stylesheets for chunkingandnon-chunking
From:Jack Cushman (jcus@avatartechnology.com)
Date:Jul 30, 2001 2:32:07 pm
List:org.oasis-open.lists.docbook-apps

I'm new to XSL, but I'll give this a shot. How about setting chunking as a param. For example:

<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:param name="chunk" select="'no'"/> <xsl:choose> <xsl:when test="$chunk = 'yes'"> <xsl:import href="/usr/share/sgml/docbook-xsl-1.41/html/chunk.xsl"/> </xsl:when> <xsl:otherwise> <xsl:import href="/usr/share/sgml/docbook-xsl-1.41/html/docbook.xsl"/> </xsl:otherwise> </xsl:choose>

... your customizations ...

</xsl:stylesheet>

you could then call the file as:

$ xsltproc -o sample.html /usr/share/sgml/e-smith.xsl sample.xml

Or to generate multiple pages:

$ xsltproc --param chunk yes /usr/share/sgml/e-smith.xsl sample.xml

Hope this helps. (Heck, hope this even compiles, I haven't tried it...)

-----Original Message----- From: Dan York [mailto:dyo@e-smith.com] Sent: Monday, July 30, 2001 3:43 PM To: docb@lists.oasis-open.org Subject: DOCBOOK-APPS: How to structure XSL stylesheets for chunking andnon-chunking

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.