This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Chunking question


Janning Vygen wrote:
Isnt this the same as "chunk all sections"?? this is easier to achieve by setting parameters chunk look at the parameters for chunking: http://docbook.sourceforge.net/release/xsl/snapshot/doc/html/rn18.html
<xsl:param name="chunk.section.depth" select="1000">
<xsl:param name="chunk.first.sections" select="1"/>
these parameters should chunk every sectx or section in your doc
They do chunk every section, but I don't want the last section in an hierarchy to be chunked. Eg.

<sect1>
<sect2>
<sect3>
<para>Text1</para>
</sect3>
<sect3>
<para>Text2</para>
</sect3>
</sect2>
<sect2>
<sect3>
<sect4>
<para>Text3</para>
</sect4>
<sect4>
<para>Text4</para>
</sect4>
</sect3>
<sect3>
<para>Text5</para>
</sect3>
<sect3>
<para>Text6</para>
</sect3>
</sect2>
</sect1>

Should be chunked like this:
page_sect1 -> empty (maybe links to page_sect2_1 & page_sect2_2)
page_sect2_1 -> contains Text1 and Text2
page_sect2_2 -> contains Text5 and Text6 (maybe link to page_sect3_2)
page_sect3_2 -> contains Text3 and Text4


So Text1 & Text2 are on one page, Text3 & Text4 are on one page, Text5 & Text6 are on one page. With chunk.section.depth set to a very high value, they would be chunked to separate pages, like this:

page_sect1
page_sect2_1
page_sect3_1 -> contains Text1
page_sect3_2 -> contains Text2
page_sect2_2
page_sect3_3
page_sect4_1 -> contains Text3
page_sect4_2 -> contains Text4
page_sect3_3 -> contains Text5
page_sect3_4 -> contains Text6

Sorry if I bored anyone, but writing this down has actually helped me to clear my mind on what I really wanted :) Back to trying to implement it now...


cheers,

roel


kind regards janning



cheers,

roel

Janning Vygen wrote:

Am Montag, 13. Januar 2003 23:09 schrieb Bob Stayton:

On Mon, Jan 13, 2003 at 02:13:24PM -0500, Jeff Beal wrote:

Customizing the chunking to the extent you appear to want is
quite difficult, especially if you want to maintain reasonable
previous/next/up links in the output.
[...]


There was another message that suggested the use of PIs
in the document, but I don't think it was ever implemented.

http://lists.oasis-open.org/archives/docbook-apps/200209/msg00007
.h tml
It was implemented.

The file is attached to this mail. It was quite easy but it is
not very well tested because the need for manual chunking via PI
didn't arrise in the project it was made for.

It just overrides the template name="chunk"

you can use PIs like this to chunk a section. Just put it inside
the section as a child of the section element.

<?dbhtml chunk-childs="1" chunk-first-sections="0"?>

I dont know if this file works with the newest docbook-xsl
release. and it works only with chunkfast.xsl i think.

I just hope it gives you a hint how easy it is to implement
chunking with PIs. I hope this file can be of any help.

kind regards
janning



-----------------------------------------------------------------
-------

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

<!--
     2002, written by vygen@planwerk6.de,
     1) you can decide via Processing Instruction
     if you want to chunk the childs of the parent node of the
PI 2) you can override the value of chunk.first.sections via PI

    Put PIs like this into your chapter or sections

    <?dbhtml chunk-childs="1" chunk-first-sections="0"?>

    chunk-first-sections is inherited by all subsequent childs
if not changed again by another PI

    chunk-childs affects only the childs of the parnet node of
the PI (put your PI _into_ a chapter to chunk the sections inside
this chapter

    you can only decide to
    - chunk all childs but not the first
    - chunk all child including the first
    - chunk no childs

    NO WARRENTY, most of the code is copyright by xsl guru norm
walsh -->

<xsl:include href="chunkfast.xsl"/>

<xsl:template name="dbhtml-chunk-childs">
 <xsl:param name="pis"
select="./processing-instruction('dbhtml')"/> <xsl:call-template
name="dbhtml-attribute">
   <xsl:with-param name="pis" select="$pis"/>
   <xsl:with-param
name="attribute">chunk-childs</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template name="dbhtml-chunk-first-sections">
 <xsl:param name="pis"
select="./processing-instruction('dbhtml')"/> <xsl:call-template
name="dbhtml-attribute">
   <xsl:with-param name="pis" select="$pis"/>
   <xsl:with-param
name="attribute">chunk-first-sections</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template name="chunk">
 <xsl:param name="node" select="."/>
 <!-- returns 1 if $node is a chunk -->

 <xsl:variable name="dbhtml-chunk-childs">
   <xsl:call-template name="dbhtml-chunk-childs">
     <xsl:with-param name="pis"
select="$node/parent::*/processing-instruction('dbhtml')"/>
</xsl:call-template>
 </xsl:variable>

 <xsl:variable name="dbhtml-chunk-first-sections">
   <xsl:call-template name="dbhtml-chunk-first-sections">
   <xsl:with-param name="pis"
select="$node/ancestor::*[contains(./processing-instruction('dbht
ml'),'chunk-first-sections=')][1]/processing-instruction('dbhtml')
"/> </xsl:call-template>
 </xsl:variable>

 <xsl:choose>
   <xsl:when test="not($node/parent::*)">1</xsl:when>

   <xsl:when test="local-name($node) = 'sect1'
                   and (  $dbhtml-chunk-childs = 1 or
($chunk.section.depth &gt;= 1 and $dbhtml-chunk-childs = '') )
and ( ($dbhtml-chunk-first-sections = 1 or ($chunk.first.sections
 != 0 and $dbhtml-chunk-first-sections = '') ) or
count($node/preceding-sibling::sect1) &gt; 0)">
<xsl:text>1</xsl:text>
   </xsl:when>
   <xsl:when test="local-name($node) = 'sect2'
                   and (  $dbhtml-chunk-childs = 1 or
($chunk.section.depth &gt;= 2 and $dbhtml-chunk-childs = '') )
and ( ($dbhtml-chunk-first-sections = 1 or ($chunk.first.sections
 != 0 and $dbhtml-chunk-first-sections = '') ) or
count($node/preceding-sibling::sect2) &gt; 0)">
<xsl:call-template name="chunk">
       <xsl:with-param name="node" select="$node/parent::*"/>
     </xsl:call-template>
   </xsl:when>
   <xsl:when test="local-name($node) = 'sect3'
                   and (  $dbhtml-chunk-childs = 1 or
($chunk.section.depth &gt;= 3 and $dbhtml-chunk-childs = '') )
and ( ($dbhtml-chunk-first-sections = 1 or ($chunk.first.sections
 != 0 and $dbhtml-chunk-first-sections = '') ) or
count($node/preceding-sibling::sect3) &gt; 0)">
<xsl:call-template name="chunk">
       <xsl:with-param name="node" select="$node/parent::*"/>
     </xsl:call-template>
   </xsl:when>
   <xsl:when test="local-name($node) = 'sect4'
                   and (  $dbhtml-chunk-childs = 1 or
($chunk.section.depth &gt;= 4 and $dbhtml-chunk-childs = '') )
and ( ($dbhtml-chunk-first-sections = 1 or ($chunk.first.sections
 != 0 and $dbhtml-chunk-first-sections = '') ) or
count($node/preceding-sibling::sect4) &gt; 0)">
<xsl:call-template name="chunk">
       <xsl:with-param name="node" select="$node/parent::*"/>
     </xsl:call-template>
   </xsl:when>
   <xsl:when test="local-name($node) = 'sect5'
                   and (  $dbhtml-chunk-childs = 1 or
($chunk.section.depth &gt;= 5 and $dbhtml-chunk-childs = '') )
and ( ($dbhtml-chunk-first-sections = 1 or ($chunk.first.sections
 != 0 and $dbhtml-chunk-first-sections = '') ) or
count($node/preceding-sibling::sect5) &gt; 0)">
<xsl:call-template name="chunk">
       <xsl:with-param name="node" select="$node/parent::*"/>
     </xsl:call-template>
   </xsl:when>
   <xsl:when test="local-name($node) = 'section'
                   and (  $dbhtml-chunk-childs = 1 or
($chunk.section.depth &gt;= count($node/ancestor::section)+1 and
$dbhtml-chunk-childs = '') ) and ( ($dbhtml-chunk-first-sections
= 1 or ($chunk.first.sections   != 0 and
$dbhtml-chunk-first-sections = '') ) or
count($node/preceding-sibling::section) &gt; 0)">
<xsl:call-template name="chunk">
       <xsl:with-param name="node" select="$node/parent::*"/>
     </xsl:call-template>
   </xsl:when>

   <xsl:when test="name($node)='preface'">1</xsl:when>
   <xsl:when test="name($node)='chapter'">1</xsl:when>
   <xsl:when test="name($node)='appendix'">1</xsl:when>
   <xsl:when test="name($node)='article'">1</xsl:when>
   <xsl:when test="name($node)='part'">1</xsl:when>
   <xsl:when test="name($node)='reference'">1</xsl:when>
   <xsl:when test="name($node)='refentry'">1</xsl:when>
   <xsl:when test="name($node)='index'
                   and (name($node/parent::*) = 'article'
                        or name($node/parent::*) =
'book')">1</xsl:when> <xsl:when test="name($node)='bibliography'
                   and (name($node/parent::*) = 'article'
                        or name($node/parent::*) =
'book')">1</xsl:when> <xsl:when test="name($node)='glossary'
                   and (name($node/parent::*) = 'article'
                        or name($node/parent::*) =
'book')">1</xsl:when> <xsl:when
test="name($node)='colophon'">1</xsl:when> <xsl:when
test="name($node)='book'">1</xsl:when>
   <xsl:when test="name($node)='set'">1</xsl:when>
   <xsl:when test="name($node)='setindex'">1</xsl:when>
   <xsl:otherwise>0</xsl:otherwise>
 </xsl:choose>
</xsl:template>

</xsl:stylesheet>







Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]