docbook-apps

  • 1.  dynamic chunk.section.depth

    Posted 04-16-2010 19:04
    Hi,
    I suppose it is impossible to set the chunk.section.depth dynamically, but maybe some of you will have an idea about how to solve my problem.

    For the most part we want our documents chunked to a depth of 2. Some sections however are very mathematically dense and/or long, which can lead to some very heavy HTML pages. For these dense sections we'd like to chunk to a depth of 3.

    My first guess is that I will customize the chunk template which determines what is or is not a chunk, maybe adding a parameter to that template to tell the section depth, but I'm not sure how to vary that within the document.

    any ideas?

    thanks,
    --Tim Arnold





  • 2.  RE: [docbook-apps] dynamic chunk.section.depth

    Posted 04-16-2010 19:47
    Hi Tim,
    You might be able to make use of the stop-chunking PI or at least be
    inspired by it:
    http://docbook.sourceforge.net/release/xsl/current/doc/pi/dbhtml_stop-ch
    unking.html

    For your situation, you would set the depth to 3 and add the PI to any
    2nd level sections when you don't want deeper chunking.

    If you choose to customize, you can at least grep for "stop-chunking"
    for inspiration. There are several things to change in order to get the
    Next and Prev links to come out right.

    Good luck,
    David

    >


  • 3.  RE: [docbook-apps] dynamic chunk.section.depth

    Posted 04-16-2010 20:29
    Hi David,
    That's exactly what I did. In my processing from LaTeX to DocBook, I set a remark with role=toc2 or role=toc3 depending on the tag the writer used. Then, using lxml I do this in python postprocessing of the xml:
    ----------------------------------------------------------
    def set_chunklevel(self, tree):
    for section in tree.xpath('/d:chapter/d:section/d:section',namespaces=xns):
    stop_chunking = etree.ProcessingInstruction('dbhtml', text='stop-chunking')
    remark = section.xpath('child::d:para/d:remark',namespaces=xns)
    if not remark:
    section.insert(0,stop_chunking)
    elif remark[0].get('role') == 'toc2':
    section.insert(0,stop_chunking)
    ----------------------------------------------------------

    so if there is no remark in the 2nd level section I stop chunking.
    if there is a remark and it has role=toc2, I stop chunking.
    otherwise (there's a remark and it has role=toc3 and so I let it chunk to chunker.section.depth

    I was pretty worried about the navigation going haywire, but for my one test of today it looks fine.
    I'll google more about it on Monday to see if I'm just getting lucky on this one chapter's navigation.

    thanks!
    --Tim



    >


  • 4.  Re: [docbook-apps] dynamic chunk.section.depth

    Posted 04-16-2010 20:35
    Hi,

    On 4/16/10, David Cramer <dcramer@motive.com> wrote:
    > You might be able to make use of the stop-chunking PI or at least be
    > inspired by it:
    > http://docbook.sourceforge.net/release/xsl/current/doc/pi/dbhtml_stop-ch
    > unking.html

    this PI seems to be screaming for a matching PI:



    --
    Sam Steingold <http://sds.podval.org>



  • 5.  Re: [docbook-apps] dynamic chunk.section.depth

    Posted 04-17-2010 05:03
    On Fri, 16 Apr 2010 15:04:15 -0400
    Tim Arnold <Tim.Arnold@sas.com> wrote:

    > Hi,
    > I suppose it is impossible to set the chunk.section.depth
    > dynamically, but maybe some of you will have an idea about how to
    > solve my problem.
    >
    > For the most part we want our documents chunked to a depth of 2. Some
    > sections however are very mathematically dense and/or long, which can
    > lead to some very heavy HTML pages. For these dense sections we'd
    > like to chunk to a depth of 3.


    What is meant by 'dense'? More depth?
    You could use xsl:choose then set the param depending on depth
    (count of section depth)


    HTH


    --

    regards

    --
    Dave Pawson
    XSLT XSL-FO FAQ.
    http://www.dpawson.co.uk



  • 6.  RE: [docbook-apps] dynamic chunk.section.depth

    Posted 04-17-2010 13:02
    > _______________________________________
    > From: Dave Pawson [davep@dpawson.co.uk]
    > Sent: Saturday, April 17, 2010 1:02 AM
    > To: Tim Arnold
    > Cc: docbook-apps@lists.oasis-open.org
    > Subject: Re: [docbook-apps] dynamic chunk.section.depth
    >
    > On Fri, 16 Apr 2010 15:04:15 -0400
    > Tim Arnold <Tim.Arnold@sas.com> wrote:
    >
    > > Hi,
    > > I suppose it is impossible to set the chunk.section.depth
    > > dynamically, but maybe some of you will have an idea about how to
    > > solve my problem.
    > >
    > > For the most part we want our documents chunked to a depth of 2. Some
    > > sections however are very mathematically dense and/or long, which can
    > > lead to some very heavy HTML pages. For these dense sections we'd
    > > like to chunk to a depth of 3.
    >
    >
    > What is meant by 'dense'? More depth?
    > You could use xsl:choose then set the param depending on depth
    > (count of section depth)
    >
    >
    > HTH
    > regards
    >
    > --
    > Dave Pawson
    > XSLT XSL-FO FAQ.
    > http://www.dpawson.co.uk

    Hi Dave, by 'dense' I just mean a subsection has a lot of math (so it contains lots of graphics) and the section is long (so you have to scroll).
    Not that it has a lot of deeply nested sub-sub-etc-sections. Your answer makes me think the chunk.section.depth parameter can be set differently depending on the situation. My current process puts a <remark role="toc2" /> or <remark role="toc3"/> under every subsection as a flag showing how deep the chunks should go for that subsection. It's a kludge I guess, but I haven't figured out anything better yet.

    Are you saying I could write a template to match on remark[@role="toc2"] or remark[@role="toc3"] to change the chunk.section.depth during processing?
    That's exactly what I'd like to do, but I didn't think it could be done.

    thanks,
    --Tim





  • 7.  Re: [docbook-apps] dynamic chunk.section.depth

    Posted 04-17-2010 14:13
    On Sat, 17 Apr 2010 09:02:23 -0400
    Tim Arnold <Tim.Arnold@sas.com> wrote:

    > Hi Dave, by 'dense' I just mean a subsection has a lot of math (so it
    > contains lots of graphics) and the section is long (so you have to
    > scroll). Not that it has a lot of deeply nested sub-sub-etc-sections.
    > Your answer makes me think the chunk.section.depth parameter can be
    > set differently depending on the situation. My current process puts a
    > <remark role="toc2" /> or <remark role="toc3"/> under every
    > subsection as a flag showing how deep the chunks should go for that
    > subsection. It's a kludge I guess, but I haven't figured out anything
    > better yet.
    >
    > Are you saying I could write a template to match on
    > remark[@role="toc2"] or remark[@role="toc3"] to change the
    > chunk.section.depth during processing? That's exactly what I'd like
    > to do, but I didn't think it could be done.

    Other way round.
    In your specialization layer, set a variable to 'measure' whatever
    you want, then set the parameter from that?

    <xsl:variable name ='density'>
    <xsl:choose>



    <xsl:param name='chunk.section.depth' select='$density'/>


    I'm not sure if you can replace variable with param, worth
    a try though.

    HTH


    --

    regards

    --
    Dave Pawson
    XSLT XSL-FO FAQ.
    http://www.dpawson.co.uk



  • 8.  RE: [docbook-apps] dynamic chunk.section.depth

    Posted 04-19-2010 15:21
    >


  • 9.  Re: [docbook-apps] dynamic chunk.section.depth

    Posted 04-19-2010 01:08
    Hi Tim,
    I messed about with something related a couple of years ago.
    What I implemented was a negative number on the chunk.section.depth to say
    chunk to within that "section height" of the node tree leaves.
    I think there was a little bit of freedom because you could
    add the odd "simplesect" leaf, which were terminal non-chunking nodes anyway.
    Of course you need to pay very close attention to your document structure
    if you tried this - I was transforming a highly structured ontology, so
    it worked adequately for me.

    I think calculating the number of section children was a bit intensive though,
    specially for TOC generation. The logic was embedded in the tabular-toc
    contrib module, somewhere ...
    http://docbook.svn.sourceforge.net/viewvc/docbook/trunk/contrib/xsl/tabular-
    toc/

    cheers
    doug


    On Sat, 17 Apr 2010, Tim Arnold wrote:
    > Hi,
    > I suppose it is impossible to set the chunk.section.depth dynamically, but
    > maybe some of you will have an idea about how to solve my problem.
    >
    > For the most part we want our documents chunked to a depth of 2. Some
    > sections however are very mathematically dense and/or long, which can lead
    > to some very heavy HTML pages. For these dense sections we'd like to chunk
    > to a depth of 3.
    >
    > My first guess is that I will customize the chunk template which determines
    > what is or is not a chunk, maybe adding a parameter to that template to
    > tell the section depth, but I'm not sure how to vary that within the
    > document.
    >
    > any ideas?
    >
    > thanks,
    > --Tim Arnold
    >
    >
    >
    > ---------------------------------------------------------------------
    > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org





  • 10.  RE: [docbook-apps] dynamic chunk.section.depth

    Posted 04-19-2010 15:22
    Hi Doug,
    Thanks for the link. I looked at the code, but I'm still pretty new to xsl, so for now I think the modifications I need are beyond my reach.

    thanks,
    --Tim

    >