This software is copyrighted by its respective authors. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files.
The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply.
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
Welcome to the start of what could be a very good reference to DSSSL's flow object classes. It is a humble beginning, but with time, and contributions, it will become a valuable resource to people using DSSSL and to people using the DSSSL flow objects with XSL.
This material is, or will be, part of the DSSSL Handbook (http://www.mulberrytech.com/dsssl/dsssldoc/handbook.html), which itself is a product of the DSSSL Documentation Project, a collaborative effort by users of DSSSL to write and disseminate documentation on all aspects of DSSSL for the purposes of introducing DSSSL to new users, education for both new and experienced users, and assistance for people using DSSSL.
The project draws on the combined experience of present users of DSSSL, principally those subscribed to the DSSSList mailing list (http://www.mulberrytech.com/dsssl/dssslist/), which also hosts the discussion between project participants.
This book currently describes a single flow object class, simple-page-sequence, but the next revision will have more.
The material is divided into reference and tutorial sections.
The reference section discusses the flow object and lists all of its characteristics, both those defined in the DSSSL standard and additional characteristics implemented in particular DSSSL engines or backends. Following the style of the dsssl-o specification, the standard characteristics and their values, defaults, and required support in dsssl-o are listed in a quick-reference table, which is followed by additional information about the characteristics. The non-standard characteristics follow a similar format, except that the dsssl-o column is unnecessary for them.
The table columns are:
Characteristic � The name of the characteristic.
Inh. � Indication whether or not the characteristic is inherited. The possible values are:
I � The characteristic is inherited.
N � The characteristic is not inherited.
Standard Values � The values that are defined for the characteristic in the full DSSSL standard.
Standard Init/Default � The initial (inherited) or default (non-inherited) value of the characteristic defined in the DSSSL standard.
dsssl-o � The level of support that can be expected from a conforming dsssl-o application such as Jade. The possible values are:
Standard � Full support as specified in the DSSSL standard.
Default � The application can, if necessary, substitute the initial or default value of the characteristic for any other legal value provided in the stylesheet.
Ignore � The characteristic may be ignored by a conforming dsssl-o application.
Partial � Some of the standard values must be supported but not all of them. The values for which support is not required are marked with an asterisk (*).
This material is available in SGML, HTML, and RTF from under the DSSSL Documentation Project page at http://www.mulberrytech.com/dsssl/dsssldoc/.
The original SGML document is marked up in accordance with the DocBook 3.0 DTD, and SGML original is processed using Jade (http://www.jclark.com/jade/) and the Modular DocBook Stylesheet (http://nwalsh.com/) to produce the HTML and RTF forms.
Contributions to this document, to the DSSSL Handbook, and to other DSSSL Documentation Project material is actively solicited. If you would like to contribute, please contact B. Tommie Usdin ([email protected]).
The simple-page-sequence flow object is the most basic page model flow object in DSSSL's repertoire of flow objects. It also happens to be the only one currently implemented in Jade, the most popular DSSSL engine.
A simple-page-sequence flow object class is formatted to produce a series of page areas. A simple-page-sequence flow object may accept any displayed flow object, but a simple-page-sequence is not allowed within any other flow object class.
It may have a single-line header and a single-line footer. The standard states that header and footer text must be constant except for a page number, which can be formatted from the page-number-sosofo procedure defined in the standard. Since the header and footer characteristics are actually specified as inline sosofos, it is possible, for example, to specify an inline external-graphic in the header or footer.
Jade supports some additional procedures that allow different header and footer content between recto and verso pages and on the first page formatted from a simple-page-sequence, as well as additional characteristics that control the appearance of the formatted page number.
A document can contain multiple simple-page-sequences. For example, each chapter can be a separate simple-page-sequence, with different header and footer text, which could include the current chapter title.
The header and footer lines are divided into three parts: left, center, and right. The standard does not state how the header or footer line is divided into these three parts, or what happens if a formatted sosofo overflows the area notionally available for it. For example, Jade's RTF backend positions the formatted header and footer sosofos at tab stops in the header and footer lines, but if the contents of the left header takes more than half the line, the contents of the center header is pushed to the next tab stop and the contents of the right header is, well, lost off the edge of the page. Other DSSSL engines or other backends may format the same sosofos differently in this situation.
The header and footer margins measure from the top and bottom of the page, respectively, to the placement path (effectively the baseline) of the header and footer text, respectively. It is not the case that the header margin measures to the top of the header text, and the footer margin, to the bottom of the footer text.
Page areas formatted from a simple-page-sequence fill from top to bottom. Although simple-page-sequence has a writing-mode characteristic, the standard states that this applies only to the writing-mode of the header and footer lines.
The following table lists information about each of the characteristics of the simple-page-sequence flow object class.
Characteristic | Inh. | Standard Values | Standard Init/Default | dsssl-o |
---|---|---|---|---|
bottom-margin | I | length | 0pt | Standard |
center-footer | N | unlabeled sosofo | empty sosofo | Standard |
center-header | N | unlabeled sosofo | empty sosofo | Standard |
footer-margin | I | length | 0pt | Standard |
header-margin | I | length | 0pt | Standard |
left-footer | N | unlabeled sosofo | empty sosofo | Standard |
left-header | N | unlabeled sosofo | empty sosofo | Standard |
left-margin | I | length | 0pt | Standard |
page-height | I | length | system-dependent | Standard |
page-width | I | length | system-dependent | Standard |
right-footer | N | unlabeled sosofo | empty sosofo | Standard |
right-header | N | unlabeled sosofo | empty sosofo | Standard |
right-margin | I | length | 0pt | Standard |
top-margin | I | length | 0pt | Standard |
writing-mode | I | left-to-right, right-to-left, top-to-bottom | left-to-right | Default |
bottom-margin |
The distance from the bottom of the page to the area container used for the content of the simple-page-sequence.
Note that the footer line is within the bottom margin.
center-footer |
Unlabeled sosofo that is centered between the left and right margins of the page in the footer line. The sosofo should only contain inline flow objects.
center-header |
Unlabeled sosofo that is centered between the left and right margins of the page in the header line. The sosofo should only contain inline flow objects.
footer-margin |
The distance from the bottom of the page to the placement path for the footer line. The left-footer, center-footer, and right-footer sosofos appear on this line.
header-margin |
The distance from the top of the page to the placement path for the header line. The left-header, center-header, and right-header sosofos appear on this line.
left-footer |
Unlabeled sosofo that is aligned with the left margin of the page in the footer line. The sosofo should only contain inline flow objects.
left-header |
Unlabeled sosofo that is aligned with the left margin of the page in the header line. The sosofo should only contain inline flow objects.
left-margin |
The distance from the left side of the page to the area container used for the content of the simple-page-sequence.
page-height |
The total height of the page.
page-width |
The total width of the page.
right-footer |
Unlabeled sosofo that is aligned with the right margin of the page in the footer line. The sosofo should only contain inline flow objects.
right-header |
Unlabeled sosofo that is aligned with the right margin of the page in the header line. The sosofo should only contain inline flow objects.
right-margin |
The distance from the right side of the page to the area container used for the content of the simple-page-sequence.
top-margin |
The distance from the top of the page to the area container used for the content of the simple-page-sequence.
Note that the header line is within the top margin.
writing-mode |
The writing mode of the header and footer lines.
Jade 1.1 supports five additional characteristics of the simple-page-sequence flow object class:
Characteristic | Inh. | Values | Init/Default |
---|---|---|---|
page-number-format | I | String | 1 |
page-number-restart? | I | #t, #f | #f |
page-n-columns | I | Integer greater than 0 | 1 |
page-column-sep | I | length | 0.5in |
page-balance-columns? | I | #t, #f | #f |
page-number-format |
A string, as for format-number procedure, that controls the format of the number used by page-number-sosofo and current-page-number-sosofo for references to pages in the simple-page-sequence.
page-number-restart? |
If true, then for the purposes of page-number-sosofo and current-page-number-sosofo, the page numbers for this simple-page-sequence will restart from 1.
page-n-columns |
The number of columns.
page-column-sep |
The separation between columns.
page-balance-columns? |
If true, the columns on the final page of the simple-page-sequence should be balanced.
The DSSSL standard defines two functions associated with simple-page-sequence:
(page-number-sosofo) |
Returns an indirect sosofo whose content is a sequence of character flow objects representing the page number of the page on which the first area resulting from the indirect flow object specified by the indirect-sosofo occurs.
This can be expected to render as the current page number.
(current-node-page-number-sosofo) |
Returns an indirect-sosofo whose content is a sequence of character flow objects representing the page number of the primary flow object of the current node.
This is intended for use in cross-references in conjunction with process-element-with-id.
Jade 1.1 supports two external procedures providing additional control over headers and footers in simple-page-sequence flow objects:
(if-first-page sosofo1 sosofo2) |
This can be used only in the specification of the value of one of the header/footer characteristics of simple-page-sequence. It returns a sosofo that will display as sosofo1 if the page is the first page of the simple-page-sequence and as sosofo2 otherwise.
(if-front-page sosofo1 sosofo2) |
This can be used only in the specification of the value of one of the header/footer characteristics of simple-page-sequence. It returns a sosofo that will display as sosofo1 if the page is a front (ie recto, odd-numbered) page and as sosofo2 if it is a back (ie verso, even-numbered) page.
Through numerous examples you'll see how to use each of the characteristics of simple-page-sequence, including a few examples of what not to do.
All of the examples use the same SGML document, sample.sgm, shown below. The structure is very simple: a book containing a title and two paragraphs.
<!DOCTYPE book [ <!ELEMENT book - - (title, para*) > <!ELEMENT title - - (#PCDATA) > <!ELEMENT para - - (#PCDATA) > ]> <book><title>Title</title> <para>This is a paragraph.</para> <para>This is a somewhat longer paragraph just so we can be sure that this paragraph is going to wrap onto another line and maybe another page when we produce formatted output.</para> </book> |
The stylesheet default.dsl contains one element construction rule, and it just uses simple-page-sequence without declaring any values for the characteristics:
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> ;; BOOK element (element BOOK (make simple-page-sequence)) |
The defaults for page-height and page-width are system-dependent and the defaults for all of the margins is 0pt. The result, when using Jade's RTF backend and viewing in Microsoft Word, is that the page height and width are Word's default, the text fills from one edge of the page to the other, and there is a minimal top margin:
pagesize.dsl includes values for page-height and page-width and declares styles for the title and para elements:
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> (define ($para$) (make paragraph quadding: 'justify font-size: 12pt font-family-name: "Arial" space-before: 12pt space-after: 12pt)) ;; BOOK element (element BOOK (make simple-page-sequence page-width: 15pi page-height: 20pi)) (element TITLE ($para$)) (element PARA ($para$)) |
The results are more reproducible, since we're not using the system-dependent defaults, but the margins are still 0pt and the text flows from one edge of the page to the other:
margins.dsl adds declarations for the top-margin, bottom-margin, left-margin, and right-margin characteristics:
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> (define-unit pi (/ 1in 6)) (define-unit pt (/ 1in 72)) (define ($para$) (make paragraph quadding: 'justify font-size: 12pt font-family-name: "Arial" space-before: 12pt space-after: 12pt)) ;; BOOK element (element BOOK (make simple-page-sequence page-width: 15pi page-height: 20pi left-margin: 1pi right-margin: 2pi top-margin: 3pi bottom-margin: 4pi)) (element TITLE ($para$)) (element PARA ($para$)) |
The margins are each a different size so you can clearly see the effect of each characteristic:
Note that you can set Word's ruler to show measurements in picas from the �General� tab of the �Options� dialog box opened from the �Options...� item in the �Tools� menu.
footer.dsl sets the top and bottom margins to 4 pica, the header margin to 3 pica, and the footer margin to 1 pica. It also defines a style which will be used in the footer. A sosofo named footer-page-number is defined within the element construction rule for the BOOK element, and that sosofo is used as the value of the right-footer characteristic:
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> (define-unit pi (/ 1in 6)) (define-unit pt (/ 1in 72)) (define ($para$) (make paragraph quadding: 'justify font-size: 12pt font-family-name: "Arial" space-before: 12pt space-after: 12pt)) (define footer-style (style font-size: 9pt font-family-name: "Arial")) ;; BOOK element (element BOOK (let ((footer-page-number (make sequence use: footer-style (literal "Page ") (page-number-sosofo)))) (make simple-page-sequence page-width: 15pi page-height: 20pi left-margin: 2pi right-margin: 2pi top-margin: 4pi bottom-margin: 4pi header-margin: 3pi footer-margin: 1pi right-footer: footer-page-number))) (element TITLE ($para$)) (element PARA ($para$)) |
The footer text appears at the bottom right of each page, and the baseline of the text is 1 pica from the bottom of the page. Since we used the page-number-sosofo function defined in the DSSSL standard, we show a page number that increments for each page:
header.dsl adds a header-title sosofo, used in the right header, that is the result of processing the book's title:
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> (define-unit pi (/ 1in 6)) (define-unit pt (/ 1in 72)) (define ($para$) (make paragraph quadding: 'justify font-size: 12pt font-family-name: "Arial" space-before: 12pt space-after: 12pt)) (define footer-style (style font-size: 9pt font-family-name: "Arial")) (mode header-title (element TITLE (process-children))) ;; BOOK element (element BOOK (let ((header-title (make sequence use: footer-style (with-mode header-title (process-matching-children "TITLE")))) (footer-page-number (make sequence use: footer-style (literal "Page ") (page-number-sosofo)))) (make simple-page-sequence page-width: 15pi page-height: 20pi left-margin: 2pi right-margin: 2pi top-margin: 4pi bottom-margin: 4pi header-margin: 3pi footer-margin: 1pi right-footer: footer-page-number right-header: header-title))) (element TITLE ($para$)) (element PARA ($para$)) |
As well as using the footer-style style, the header-title sosofo uses the header-title mode when processing the title. Without using the mode, the title would be processed in the default mode and appear as 12 point Arial text (and the paragraph flow object in the default mode's TITLE element construction rule would create problems since the header and footer should contain only in-line flow objects).
Up until now, the header and footer sosofos have been declared within the scope of a single element construction rule. This works fine when there is only one page sequence for the whole document, but it is common for complex documents to have different different headers and footers for different parts; for example, no header or footer for the title page, a different page numbering style for the Table of Contents and introductory matter, or a different style for appendices or back matter such as an index. You can �reuse� header and footer sosofos by declaring procedures for them outside of the scope of any element construction rules.
procedure.dsl is the same as header.dsl except that the header-title and footer-page-number sosofos are now implemented as procedures, and the references to them are now procedure references:
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> (define-unit pi (/ 1in 6)) (define-unit pt (/ 1in 72)) (define ($para$) (make paragraph quadding: 'justify font-size: 12pt font-family-name: "Arial" space-before: 12pt space-after: 12pt)) (define footer-style (style font-size: 9pt font-family-name: "Arial")) (define (header-title) (make sequence use: footer-style (with-mode header-title (process-matching-children "TITLE")))) (define (footer-page-number) (make sequence use: footer-style (literal "Page ") (page-number-sosofo))) (mode header-title (element TITLE (process-children))) ;; BOOK element (element BOOK (make simple-page-sequence page-width: 15pi page-height: 20pi left-margin: 2pi right-margin: 2pi top-margin: 4pi bottom-margin: 4pi header-margin: 3pi footer-margin: 1pi right-footer: (footer-page-number) right-header: (header-title))) (element TITLE ($para$)) (element PARA ($para$)) |
The output, not surprisingly, is exactly the same as that produced with header.dsl, except that if we had multiple uses for a simple-page-sequence flow object, we could reuse these procedures without having to redeclare them.
variable.dsl is similar to procedure.dsl, except that the header-title and footer-page-number are implemented as top-level variables, not as procedures:
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> (define-unit pi (/ 1in 6)) (define-unit pt (/ 1in 72)) (define ($para$) (make paragraph quadding: 'justify font-size: 12pt font-family-name: "Arial" space-before: 12pt space-after: 12pt)) (define footer-style (style font-size: 9pt font-family-name: "Arial")) (define header-title (make sequence use: footer-style (with-mode header-title (process-matching-children "TITLE")))) (define footer-page-number (make sequence use: footer-style (literal "Page ") (page-number-sosofo))) (mode header-title (element TITLE (process-children))) ;; BOOK element (element BOOK (make simple-page-sequence page-width: 15pi page-height: 20pi left-margin: 2pi right-margin: 2pi top-margin: 4pi bottom-margin: 4pi header-margin: 3pi footer-margin: 1pi right-footer: footer-page-number right-header: header-title)) (element TITLE ($para$)) (element PARA ($para$)) |
The definition of header-title, however, fails with the following error message:
jade:variable.dsl:24:5:E: attempt to use current node when there is none |
The Jade-specific if-first-page procedure can be applied to any of the header or footer characteristics.
first-page.dsl adds the declaration for the if-first-page procedure, and uses it to control the appearance of the header-title sosofo:
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> (define if-first-page (external-procedure "UNREGISTERED::James Clark//Procedure::if-first-page")) (define-unit pi (/ 1in 6)) (define-unit pt (/ 1in 72)) (define ($para$) (make paragraph quadding: 'justify font-size: 12pt font-family-name: "Arial" space-before: 12pt space-after: 12pt)) (define footer-style (style font-size: 9pt font-family-name: "Arial")) (define (header-title) (make sequence use: footer-style (with-mode header-title (process-matching-children "TITLE")))) (define (footer-page-number) (make sequence use: footer-style (literal "Page ") (page-number-sosofo))) (mode header-title (element TITLE (process-children))) ;; BOOK element (element BOOK (make simple-page-sequence page-width: 15pi page-height: 20pi left-margin: 2pi right-margin: 2pi top-margin: 4pi bottom-margin: 4pi header-margin: 3pi footer-margin: 1pi right-footer: (footer-page-number) right-header: (if-first-page (empty-sosofo) (header-title)))) (element TITLE ($para$)) (element PARA ($para$)) |
The header title does not appear on the first page:
The Jade-specific if-front-page procedure lets you use different header and footer sosofos on the front/right-hand/recto page and on the back/left-hand/verso page.
Using if-front-page, front-page.dsl swaps the placement of the header-title and footer-page-number sosofos between the recto and verso pages so they are always on the outside (furthest from the spine) edge of the page:
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> (define if-first-page (external-procedure "UNREGISTERED::James Clark//Procedure::if-first-page")) (define if-front-page (external-procedure "UNREGISTERED::James Clark//Procedure::if-front-page")) (define-unit pi (/ 1in 6)) (define-unit pt (/ 1in 72)) (define ($para$) (make paragraph quadding: 'justify font-size: 12pt font-family-name: "Arial" space-before: 12pt space-after: 12pt)) (define footer-style (style font-size: 9pt font-family-name: "Arial")) (define (header-title) (make sequence use: footer-style (with-mode header-title (process-matching-children "TITLE")))) (define (footer-page-number) (make sequence use: footer-style (literal "Page ") (page-number-sosofo))) (mode header-title (element TITLE (process-children))) ;; BOOK element (element BOOK (make simple-page-sequence page-width: 15pi page-height: 20pi left-margin: 2pi right-margin: 2pi top-margin: 4pi bottom-margin: 4pi header-margin: 3pi footer-margin: 1pi right-footer: (if-front-page (footer-page-number) (empty-sosofo)) left-footer: (if-front-page (empty-sosofo) (footer-page-number)) right-header: (if-first-page (empty-sosofo) (if-front-page (header-title) (empty-sosofo))) left-header: (if-first-page (empty-sosofo) (if-front-page (empty-sosofo) (header-title))))) (element TITLE ($para$)) (element PARA ($para$)) |
The page number appears in the right footer on recto (right-hand) pages and in the left footer on verso (left-hand pages), and, on pages other than the first, the book title similarly alternates between the right and left headers:
page.dsl separates the simple-page-sequence into a procedure called from the BOOK element construction rule. The generic-page-sequence procedure uses the keyword form of procedure declaration so that the parameters may be specified in any order in a procedure call (or omitted, since every parameter has a default). Note that this does not create a new generic-page-sequence flow object class�the procedure call merely resembles the specification of a flow object class.
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 1. External procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define if-first-page (external-procedure "UNREGISTERED::James Clark//Procedure::if-first-page")) (define if-front-page (external-procedure "UNREGISTERED::James Clark//Procedure::if-front-page")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 2. Unit definitions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-unit pi (/ 1in 6)) (define-unit pt (/ 1in 72)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 3. Page dimensions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; These setup the page size and other parameters ;; Horizontal dimension (define %page-width% 15pi) ;; Vertical dimension (define %page-height% 20pi) ;; Left margin (define %left-margin% 2pi) ;; Right Margin (define %right-margin% 2pi) ;; Space from top of page to top of body text (define %top-margin% 4pi) ;; Space from bottom of page to bottom of body text (define %bottom-margin% 4pi) ;; Space from top of page to top of header. Should be less than %top-margin% (define %header-margin% 3pi) ;; Space from bottom of page to bottom of footer. Should be less than ;; %bottom-margin% (define %footer-margin% 1pi) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 4. Common procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define ($para$) (make paragraph quadding: 'justify font-size: 12pt font-family-name: "Arial" space-before: 12pt space-after: 12pt)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 5. Styles ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define footer-style (style font-size: 9pt font-family-name: "Arial")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 6. Header and Footer procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; These procedures may be referenced as parameters to the ;; generic-page-sequence procedure that we are using to setup our ;; page. ;; footer-page-number ;; Just the page number (define (footer-page-number) (make sequence use: footer-style (page-number-sosofo))) ;; verbose-footer-page-number ;; Page number in "Page nnn" format (define (verbose-footer-page-number) (make sequence use: footer-style (literal "Page ") (page-number-sosofo))) ;; chapter-number-page-number ;; Include the chapter number in the page number, e.g. "1-1" (define (chapter-number-page-number) (make sequence use: footer-style (literal (string-append (number->string (child-number)) "\en-dash")) (page-number-sosofo))) ;; book-title ;; The book title (define (book-title) (make sequence use: footer-style (with-mode header-title (process-node-list (select-elements (children (ancestor "BOOK")) "TITLE"))))) ;; my-title ;; Just the title of the current element (define (my-title) (make sequence use: footer-style (with-mode header-title (process-matching-children "TITLE")))) ;; chapter-number-title ;; The chapter number plus the chapter title (define (chapter-number-title) (make sequence use: footer-style (literal (string-append "Chapter " (number->string (child-number)) ": ")) (with-mode header-title (process-matching-children "TITLE")))) ;; graphic ;; Just a graphic, just to prove we can (define (graphic) (make external-graphic entity-system-id: "image1.gif" display?: #f)) ;; Used when getting titles for use in headers (mode header-title ;; Hierarchy Name: TITLE ;; ;; This could be the title of the book or of a chapter (element TITLE (process-children))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 7. "generic-page-sequence" procedure definition ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; This is the procedure we are using to make our simple-page-sequence ;; flow objects. All of the element construction rules that want to ;; change the header or footer use this procedure and supply zero or ;; more of the pre-defined header and footer procedures for the ;; appropriate slots in the header and footer. If any slots aren't ;; filled, they default to (empty-sosofo). ;; ;; The advantage of this over using a simple-page-sequence in each of ;; those element construction rules is that we only do it once, and ;; this procedure takes care of swapping left and right on recto and ;; verso pages and suppressing headings on the first page of the ;; simeple-page-sequence. (define (generic-page-sequence #!key (inside-header (empty-sosofo)) (center-header (empty-sosofo)) (outside-header (empty-sosofo)) (inside-footer (empty-sosofo)) (center-footer (empty-sosofo)) (outside-footer (empty-sosofo)) (children (process-children))) (make simple-page-sequence page-width: %page-width% page-height: %page-height% left-margin: %left-margin% right-margin: %right-margin% top-margin: %top-margin% bottom-margin: %bottom-margin% header-margin: %header-margin% footer-margin: %footer-margin% left-footer: (if-front-page inside-footer outside-footer) center-footer: center-footer right-footer: (if-front-page outside-footer inside-footer) left-header: (if-first-page (empty-sosofo) (if-front-page inside-header outside-header)) center-header: (if-first-page (empty-sosofo) center-header) right-header: (if-first-page (empty-sosofo) (if-front-page outside-header inside-header)) children)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 8. Element Construction Rules ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; BOOK element (element BOOK (generic-page-sequence outside-footer: (verbose-footer-page-number) outside-header: (my-title))) ;; TITLE element (element TITLE ($para$)) ;; PARAGRAPH element (element PARA ($para$)) |
Despite all the extra options and the use of a procedure, this produces the same result as does using front-page.dsl: