docbook-apps

  • 1.  Re: [docbook] automated keywords and chunking

    Posted 09-23-2009 16:11
    [moving this over to docbook-apps mailing list where stylesheet issues are
    discussed]

    By keywords I presume you mean generating in the HEAD
    element of each chunks? If so, then you don't have to mess with the
    chunking machinery, you can use the placeholder template named
    'user.head.content' that is available for inserting custom content. See:

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

    That template is called with the node being chunked as the context node, so
    you should be able to select descendant::indexterm/primary elements and
    process them into the value of the meta element.

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net


    ----- Original Message -----
    From: "Tim Arnold"


  • 2.  RE: [docbook-apps] Re: [docbook] automated keywords and chunking

    Posted 09-23-2009 17:39
    Tim may have to worry about chunking and the chunking settings,
    depending on his situation. Say you chunk everything. If you have a
    chapter with several subsections, then the first chunk contains the
    chapter's toc and any content before the first section. You probably
    don't want that chunk's html page to have all of the indexterms in the
    all of the child sections. Or if you stop chunking at a certain depth,
    you DO want the section at which you stop chunking to contain keywords
    for the indexterms of all its child sections. If he uses stop-chunking?> to stop chunking at arbitrary places, then that would
    have to be addressed too.

    I wanted to do something similar to what Tim is asking for, but didn't
    go to the trouble of addressing all those because it made my head hurt.

    If I recall correctly, the following tries to assemble a keywordset
    unless there already is a keywordset and gets all the indexterms in the
    chapter or section but not get any from any child sections. It also
    removes duplicate index entries.

    Anyway, perhaps the following can be a starting point or source of
    inspiration.

    David

    <xsl:template name="user.head.content">
    <xsl:call-template name="keywordset"/>
    </xsl:template>

    <xsl:template name="keywordset">
    <xsl:if test="not(self::book) and not(self::part) and
    not(./*/keywordset) and (./*[not(starts-with(local-name(.),'sect')) and
    not(self::chapter)]//indexterm or ./indexterm)">
    <xsl:variable name="indexterms">

    <xsl:copy-of
    select="./*[not(self::section)]//indexterm/*|./indexterm/*"/>
    </xsl:variable>
    <xsl:variable name="indexterms-unique">
    <xsl:for-each
    select="exslt:node-set($indexterms)/*[not(. = preceding-sibling::*)]">
    <xsl:value-of select="normalize-space(.)"/><xsl:if
    test="not(position() = last())">, </xsl:if>
    </xsl:for-each>
    </xsl:variable>
    <xsl:if test="not($indexterms-unique = '')">

    <xsl:attribute name="content">
    <xsl:value-of select="$indexterms-unique"/>
    </xsl:attribute>

    </xsl:if>
    </xsl:if>
    </xsl:template>

    > -----Original Message-----
    > From: Bob Stayton [mailto:bobs@sagehill.net]
    > Sent: Wednesday, September 23, 2009 11:11 AM
    > To: DocBook Apps; Tim Arnold
    > Subject: [docbook-apps] Re: [docbook] automated keywords and chunking
    >
    > [moving this over to docbook-apps mailing list where
    > stylesheet issues are discussed]
    >
    > By keywords I presume you mean generating > name="keywords"> in the HEAD element of each chunks? If so,
    > then you don't have to mess with the chunking machinery, you
    > can use the placeholder template named 'user.head.content'
    > that is available for inserting custom content. See:
    >
    > http://www.sagehill.net/docbookxsl/HtmlHead.html
    >
    > That template is called with the node being chunked as the
    > context node, so you should be able to select
    > descendant::indexterm/primary elements and process them into
    > the value of the meta element.
    >
    > Bob Stayton
    > Sagehill Enterprises
    > bobs@sagehill.net
    >
    >
    > ----- Original Message -----
    > From: "Tim Arnold"