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]

Re: Components, book-start? and page-number-restart?


Norman Walsh wrote:
> 

[snip]

> | Anyway, I can't see a particularly good reason for keeping in the call
> | to "book-start?". Is there one?
> 
> You can't simply remove it, because of the case you already mentioned,
> books consisting of references, parts, or articles. However, if you want
> to replace book-start with appropriately defined (first-reference?,
> (first-part?, and (first-article? calls, I'd be happy to apply that
> patch :-)
>

[Sound of gauntlet being picked up ;-)]

OK, from the style sheet point of view we have "divisions" and
"components". Divisions being optional meta things like "<part>" and
"<set>". Components being block-of-pages type things like "chapter",
"preface", "reference" etc.

First thing I notice is that (now there is support for roman numerals in
jadetex!) that page-number-format is only manipulated at the component
layer. This means that at the "division" layer the page format is left
as it was set by the previous component. So, if I have <part>s 
containing chapters and the first part following the ToC then the <part>
title page will be labeled (in the TOC - even if page numbers aren't
produced for the actual page) with a roman numeral. A quick look at a
random selection of real books shows that this isn't "correct". 

So, we need to put the following in dbdivis.dsl - this is in the
"element part" definition....

    (make sequence
      (if %generate-part-titlepage%
          (make simple-page-sequence
            page-n-columns: %titlepage-n-columns%
;; Make sure that page number format is correct.
            page-number-format: ($page-number-format$)
            input-whitespace-treatment: 'collapse
            use: default-text-style
            (part-titlepage nl 'recto)

Once that is done, the next problem is that page numbers are not
restarted. Forgetting "%page-number-restart%" for the moment (I'm not
really sure what that should do!)..... We get the same kind of logic as
we have for setting the page number of the chapter - in that we want to
restart the pages IFF the part is the first part in the book.

So we adapt dbdivis.dsl to be:

    (make sequence
      (if %generate-part-titlepage%
          (make simple-page-sequence
            page-n-columns: %titlepage-n-columns%
;; Make sure that page number format is correct.
            page-number-format: ($page-number-format$)
;; Make sure that the page number is set to 1 if this is the first part
in the book
            page-number-restart?: (first-part?)
            input-whitespace-treatment: 'collapse
            use: default-text-style

And then we need to define "first-part?". I've based this on
"first-chapter?" - it's laid out so that I can make sense of all the
parentheses.... (this would be in common/dbcommon.dsl)


(define (first-part?)
  (let*
      (
        (book
            (ancestor
                (normalize "book")
            )
        )
        (nd
            (ancestor-member
                (current-node)
                (append
                    (component-element-list)
                    (division-element-list)
                )
            )
        )
        (bookch
            (children book)
        )
     )
     (let loop ((nl bookch))
      (if (node-list-empty? nl)
          #f
          (if (equal? (gi (node-list-first nl)) (normalize "part"))
              (if (node-list=? (node-list-first nl) nd)
                  #t
                  #f)
              (loop (node-list-rest nl)))))))


This seems to work quite nicely when the part is stuffed with
"[partintro] chapter... "

However, the first-chapter? function is now returning true if it is the
first chapter in the book - so we end up with "part I" starting at page
1, and chapter 1 starting at page 1.... not good.

So, the logic for "first-chapter?" needs to be adjusted. It only wants
to return true if the first chapter isn't within a part. Here is an
adjusted "first-chapter?" which does that - it now says "if one of my
ancestors is a "part" then return false else carry on as before" (again,
I've changed the layout to make it easier for me to read...).

(define (first-chapter?)
  ;; Returns #t if the current-node is in the first chapter of a book
  (if
    (has-ancestor-member? (current-node) (division-element-list))
  #f
  (let* ((book (ancestor (normalize "book")))
         (nd   (ancestor-member
                (current-node)
                (append (component-element-list)
(division-element-list))))
         (bookch (children book))
         (bookcomp (expand-children bookch (list (normalize "part")))))
    (let loop ((nl bookcomp))
      (if (node-list-empty? nl)
          #f
          (if (equal? (gi (node-list-first nl)) (normalize "chapter"))
              (if (node-list=? (node-list-first nl) nd)
                  #t
                  #f)
              (loop (node-list-rest nl)))))
  )
  )
)


Now this seems quite nice for

<book>
<part>
<partintro>...</partintro>
<chapter>....</chapter>
<chapter>....</chapter>
...
</part>
<part>....


</book>

And also for sets of books. Which is nice.


But now for a pathological case....

I think of a book as being...

title page(s)
tables of contents, tables, figures, examples,
prefactory material (forward, preface etc).

part
chapters
part
chapters
appendices
gloss, bib
indices

But the docbook DTD allows a <preface> to be within a <part>.... Of
course, things go crazy stylesheet-wise as the page numbers are rendered
in roman numerals...

... It seems a real burden to have to code round this in the stylesheet
- I suppose you could see if you had a part as an ancestor... but my
main issue is why can parts have prefaces in them?... I can't think of
anything in the real world that does - anything that goes between the
title page and the first chapter is covered by <partintro>. So should
the DTD be changed?

Of course, this is all very well, but with the existing definition of
book-start?, I still haven't got my <preface> not resetting the page
number to 1 in a nice general way... Onward, ever onward.


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