docbook-apps

  • 1.  chunking or splitting for non-html files

    Posted 07-21-2010 17:41
    Hello:

    Sorry if this topic has already been discussed, but I did not come up with anything searching through the archives.

    Is there a style sheet which will allow one to split or chunk the XML into smaller XML files?
    Similar to the html/chunk style sheets but leaving the document in docbook xml.

    Specifically I am looking to break out a larger document into smaller XML docs at specific sections.
    Sort of modularize a book. Break out say every sect2 as its own self contained XML file.
    Or split each sect1 into a series of articles?

    Is there a style sheet in the docbook distro that would do this?


    Thanks,
    Gregorio









  • 2.  Re: [docbook-apps] chunking or splitting for non-html files

    Posted 07-21-2010 20:38
    gpevaco@aol.com wrote:

    > Is there a style sheet which will allow one to split or chunk the XML into smaller XML files?
    > Similar to the html/chunk style sheets but leaving the document in docbook xml.
    >
    > Specifically I am looking to break out a larger document into smaller XML docs at specific sections.
    > Sort of modularize a book. Break out say every sect2 as its own self contained XML file.
    > Or split each sect1 into a series of articles?
    >
    > Is there a style sheet in the docbook distro that would do this?

    There is no such existing stylesheet, but it is quite easy to create
    your own. For example to put each chapter in separate file, you could
    use something like:


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

    <xsl:template match="node()|@*">
    <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
    </xsl:template>

    <xsl:template match="chapter">
    <xsl:variable name="filename">
    <xsl:number count="chapter"/>
    </xsl:variable>
    <xi:include href="{$filename}.xml"
    xmlns:xi="http://www.w3.org/2001/XInclude"/>
    <xsl:result-document href="{$filename}.xml">
    <xsl:next-match/>
    </xsl:result-docuement>
    </xsl:template>

    </xsl:stylesheet>

    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML consulting and training services
    DocBook customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
    ------------------------------------------------------------------