docbook-apps

Re: [docbook-apps] choice of xsl modes in customization layer

  • 1.  Re: [docbook-apps] choice of xsl modes in customization layer

    Posted 12-15-2010 17:40
    Hi,
    This can be accomplished using a customization similar to the html/onechunk.xsl
    variant, which is described here:

    http://www.sagehill.net/docbookxsl/OneChunk.html

    onechunk.xsl employs the chunking mechanism, but creates a single chunk. The
    customization just makes everything in onechunk.xsl conditional on the name of the
    root element. So you are not switching between chunking and non-chunking, just how
    big the chunks are. Here is the customization, which you can tweak as needed:


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

    <xsl:import href="../docbook-xsl-1.76.1/html/chunk.xsl"/>

    <xsl:param name="base.dir">htmlout/</xsl:param>

    <xsl:param name="use.id.as.filename" select="1"/>

    <xsl:param name="onechunk">
    <xsl:choose>
    <xsl:when test="local-name(/*[1]) = 'book'">0</xsl:when>
    <xsl:otherwise>1</xsl:otherwise>
    </xsl:choose>
    </xsl:param>

    <xsl:param name="root.filename">
    <xsl:choose>
    <xsl:when test="$onechunk != 0"></xsl:when>
    <xsl:otherwise>index</xsl:otherwise>
    </xsl:choose>
    </xsl:param>

    <xsl:param name="suppress.navigation">
    <xsl:choose>
    <xsl:when test="$onechunk != 0">1</xsl:when>
    <xsl:otherwise>0</xsl:otherwise>
    </xsl:choose>
    </xsl:param>

    <xsl:template name="href.target.uri">
    <xsl:param name="object" select="."/>

    <xsl:choose>
    <xsl:when test="$onechunk != 0">
    <xsl:text>#</xsl:text>
    <xsl:call-template name="object.id">
    <xsl:with-param name="object" select="$object"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:variable name="ischunk">
    <xsl:call-template name="chunk">
    <xsl:with-param name="node" select="$object"/>
    </xsl:call-template>
    </xsl:variable>

    <xsl:apply-templates mode="chunk-filename" select="$object"/>

    <xsl:if test="$ischunk='0'">
    <xsl:text>#</xsl:text>
    <xsl:call-template name="object.id">
    <xsl:with-param name="object" select="$object"/>
    </xsl:call-template>
    </xsl:if>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    </xsl:stylesheet>

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net