General DSSSL stylesheet Questions

1. DSSSL external references
2. jade:entities/iso-amsr.ent:7:18:E: "X224D" is not a function name
3. SGML character entities
4. Where is Open Jade hosted?
5. DSSSL stylesheet parameter explanations
6. How do I customize the default stylesheets?
7. How do I include images?
8. How do I center images in print output?
9. Which tools are best for converting graphic files to other formats?
10. How do I generate an index?
11. Can I include sect1 titles in a print header
12. Can I put the filename in the footer
13. Appendices and bibliographies on seperate page
14. Styling html output from DSSSL
15. Float images
16. Change justified text
17. Remove bold on figure titles
18. SGML character entities (xxxx not a function error)
19. SDATA entities don't work in XML document
20. How to put images in document header elements
21. DSSSL text justification for html output
22. legalnotice style change, dsssl.
23. Using RTF stylenames
24. Numbering sect1 sections
25. footnote formatting in DSSSL
26. Two sided output in dsssl
27. Specify utf-8 encoding on html output
28. Including PHP in HTML output
29. Including special characters in DSSSL
30. Sort a node list
1.

DSSSL external references

Dave ??

Check this lists archives, but also try: Mulberrytech.com, uwaterlool.ca and cs.uni.magdeburg.de

2.

jade:entities/iso-amsr.ent:7:18:E: "X224D" is not a function name

DaveP

One of the features of jade is that it handles SGML as well as XML. In order to do that it has two features which help.

Firstly, it can handle multiple XML files, second it can manage a seperate declaration, which means that it will treat certain features (including the problem mentioned above) by the inclusion, prior to your main xml file, of a special file called xml.dcl, which is included in either jade or openjade distribution. You don't need to know what it does, simply that including it as well, and prior to, your xml file will resolve such issues as this. Find the file and include it, as per the example below, changing paths as necessary for your installation. The standard distribution puts it in dtds/decls/xml.dc, wherever you installed that.


jade /path/to/xml.dcl yourfile.xml .... etc

Thats all it takes to remove these errors.

Below is the line I use in a script to process my DocBook.xml files. All on one line of course

jade -t rtf -d d:\XML\sgml\stylesheets\db173\print\docbook.dsl 
d:\XML\openjade-1.3\pubtext\xml.dcl %1

And, if the tools are calling Jade you will have to add the SGML entities files to a catalog file.

Incidentally, the docbook-utils package (redhat) spots which decl file to use automatically, based on whether the input has an xml pi.

3.

SGML character entities

Matt Gruenke

I recently discovered that I ought to be using the SGML character entities, if I'm using DSSSL (yup, the 'ol "X00E1" is not a function name error). Once I discovered that I needed these entities, I reviewed all the documents I knew of, which describe installing DocBook, and couldn't find any pointer to the SGML ISO character entities.

To fix the above error, all I had to do was install the entity definition files, which take the form 'iso-*.gml', (though the ones I found are potentially stale, which is why I'm asking) and create a catalog file that maps each PUBLIC identifier for one of these files to the SGML version. Then, I placed the path to this file in my SGML_CATALOG_FILES environment variable, *before* the docbook.cat that was included with the XML DTD. I don't know whether the first PUBLIC -> SYSTEM identifier mapping is supposed to take precedence over any following ones, but it seems to work this way with OpenJade 1.3.

(I just thought I'd write up the above paragraph, as I had surprising difficulty finding this information in the mailing list archives, though maybe I was just unlucky in which of my search hits I chose to read, first.)

Oasis Cover pages provides the iso entity sets.

4.

Where is Open Jade hosted?

Didier PH Martin

For more info about Open Jade, see http://www.netfolder.com/DSSSL/

5.

DSSSL stylesheet parameter explanations

Robert McIlvride

The print and HTML stylesheet parameters are documented here, for print and here, for html

6.

How do I customize the default stylesheets?

In chapter 4 of DocBook; TDG you'll find a section covering this topic.

In short: write your own driver file, e.g.:



<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
<!ENTITY html-ss
  PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA dsssl>
<!ENTITY print-ss
  PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA dsssl>
]>

<style-sheet>
<style-specification id="print" use="print-stylesheet">
<style-specification-body> 

;; customize the print stylesheet

</style-specification-body>
</style-specification>
<style-specification id="html" use="html-stylesheet">
<style-specification-body> 

;; customize the html stylesheet

</style-specification-body>
</style-specification>
<external-specification id="print-stylesheet" document="print-ss">
<external-specification id="html-stylesheet" document="html-ss">
</style-sheet>

and use this stylesheet file for processing your source file with (open)jade (providing the stylesheet pathname as a command line option like -d ./mystyle.dsl). Choose the corresponding part for HTML or print output by setting the variable print or html using the command line option -i (e.g. -i print).

7.

How do I include images?

tbd.

8.

How do I center images in print output?

Add the following to your customization stylesheet:

(element imagedata
  (if (have-ancestor? (normalize "mediaobject"))
    ($img$ (current-node) #t)                 
    ($img$ (current-node) #f)))

(This is a bug in the default stylesheets which will be resolved in the near future)

9.

Which tools are best for converting graphic files to other formats?

There are for sure many possible solutions, but most people would like to try convert from the ImageMagick package.

10.

How do I generate an index?

Very short description:

  • Mark your entries for the index using the DocBook tags <indexterm>, <primary>, etc.

  • Generate an empty index file using collateindex.pl -N.

  • Generate the raw index data using (open)jade with the option -V html-index.

  • Process the raw index data usaing a command like collateindex.pl -o index.sgml HTML.index.

  • Include this generated index file in your SGML source file, e.g. using an external entity:

    
    <!DOCTYPE article ....
     <!entity index SYSTEM "index.sgml">
    ]>
    

    and put the following line at the place you want the index to appear in your document:

    &index;
  • Generate the desired output format as usual.

11.

Can I include sect1 titles in a print header

Norm Walsh


| I can't figure out how place sect1 titles in the
| headers/footers.  I can retrieve the first sect1 title that appears in a
| chapter, but I don't see how to get at the nearest sect1 title to the
| current page.

You can't. DSSSL only allows the headers and footers to be established once for each simple-page-sequence (in this case, for each chapter). Using multiple s-p-s's would introduce page breaks that you probably don't want.

12.

Can I put the filename in the footer

Norm Walsh


| I want to put The company name in the header and 
| the filename and author in  the footer.

The filename isn't available to Jade, so I don't think you can easily do that. But to change headers and footers in general, see dbcompon.dsl.

13.

Appendices and bibliographies on seperate page

Yann Dirson


> >| I'd like to be able to output appendices and bibliographies on
> >| seperate pages, using the DSSSL print stylesheet. I've looked at
> >| dbparam.dsl, and at some of the other files, but it's a bit beyond me
> >| at present. Is there any relatively easy way to do this?
> >
> >Are these appendixes and bibliographies in a book, or somewhere else?


> They're in an <article>.

I have done that for appendices. It requires modifying the handling of article, and the handling of appendices. This sample code may help you - I hope it's OK when out of context - the full file will be released at https://savannah.gnu.org/projects/alcovebook/

Indeed what this does is providing an %article-section-starts-new-page% flag, which controls that for all section-level elements, including glossary and such.

There are also many features in that, some of which maybe not optimally implemented - hopefully all changed code should be tagged as such. The reference code was 1.72, I did not upgrade it yet.


;;; Modified code from docbook-dsssl 1.72
;;;

;; emulate 1.72 behaviour using new features

(define %article-section-starts-new-page% #f)
(define %endnotes-on-own-page% #f)
(define ($endnotes-left-footer$) ($left-footer$))
(define ($endnotes-right-footer$) ($right-footer$))
(define ($endnotes-center-footer$) ($center-footer$))

(define (%titlepage-left-header%) (empty-sosofo))
(define (%titlepage-right-header%) (empty-sosofo))
(define (%titlepage-center-header%) (empty-sosofo))

(define (%titlepage-left-footer%) (empty-sosofo))
(define (%titlepage-right-footer%) (empty-sosofo))
(define (%titlepage-center-footer%) (empty-sosofo))


;; the code

(element article
  (let* ((info (node-list-filter-by-gi (children (current-node))
  (list (normalize "artheader")
  (normalize "articleinfo"))))
           (nl   (titlepage-info-elements (current-node) info))
            (article-titlepage 
              (if %generate-article-titlepage-on-separate-page%
                  (make sequence
                      (if (article-titlepage-content? nl 'recto)
                        (make simple-page-sequence
                           page-n-columns: %page-n-columns%
                           use: default-text-style
                           quadding: %default-quadding%
;; BEGIN ADDITION
center-header: (%titlepage-center-header%)
left-header: (%titlepage-left-header%)
right-header: (%titlepage-right-header%)
center-footer: (%titlepage-center-footer%)
left-footer: (%titlepage-left-footer%)
right-footer: (%titlepage-right-footer%)
;; END ADDITION
                   (article-titlepage nl 'recto))
                   (empty-sosofo))
                   (if (article-titlepage-content? nl 'verso)
                       (make simple-page-sequence
                        page-n-columns: %page-n-columns%
                          use: default-text-style
                     quadding: %default-quadding%
;; BEGIN ADDITION
     center-header: (%titlepage-center-header%)
left-header: (%titlepage-left-header%)
right-header: (%titlepage-right-header%)
center-footer: (%titlepage-center-footer%)
left-footer: (%titlepage-left-footer%)
right-footer: (%titlepage-right-footer%)
;; END ADDITION
(article-titlepage nl 'verso))
                                (empty-sosofo)))
                                (make sequence
                                  (article-titlepage nl 'recto)
                                  (article-titlepage nl 'verso)))))
    (make sequence
      (if (and %generate-article-titlepage% 
               %generate-article-titlepage-on-separate-page%)
          article-titlepage
          (empty-sosofo))

      (if (and %generate-article-toc% 
               (not %generate-article-toc-on-titlepage%)
               %generate-article-titlepage-on-separate-page%
               (generate-toc-in-front))
          (make simple-page-sequence
            page-n-columns: %page-n-columns%
            page-number-restart?: %article-page-number-restart%
            page-number-format: ($page-number-format$ (normalize "toc"))
            left-header:   ($left-header$ (normalize "toc"))
            center-header: ($center-header$ (normalize "toc"))
            right-header:  ($right-header$ (normalize "toc"))
            left-footer:   ($left-footer$ (normalize "toc"))
            center-footer: ($center-footer$ (normalize "toc"))
            right-footer:  ($right-footer$ (normalize "toc"))
            input-whitespace-treatment: 'collapse
            use: default-text-style
            quadding: %default-quadding%
            (build-toc (current-node)
                       (toc-depth (current-node))))
          (empty-sosofo))

;; BEGIN ADDITION          
      (if %article-section-starts-new-page%
  (make sequence
    (process-children)
    (make-endnotes))
;;; END ADDITION

  (make simple-page-sequence
;; BEGIN ADDITION          
    ;; WARNING: all this is copied in "element section" below
;;; END ADDITION
    page-n-columns: %page-n-columns%
    page-number-restart?: (or %article-page-number-restart% 
      (book-start?))
    page-number-format: ($page-number-format$)
    use: default-text-style
    left-header:   ($left-header$)
    center-header: ($center-header$)
    right-header:  ($right-header$)
    left-footer:   ($left-footer$)
    center-footer: ($center-footer$)
    right-footer:  ($right-footer$)
    start-indent: %body-start-indent%
    input-whitespace-treatment: 'collapse
    quadding: %default-quadding%

    (if (and %generate-article-titlepage% 
     (not %generate-article-titlepage-on-separate-page%))
article-titlepage
(empty-sosofo))

    (if (and %generate-article-toc% 
     (generate-toc-in-front)
     (not %generate-article-toc-on-titlepage%)
     (not %generate-article-titlepage-on-separate-page%))
(make display-group
  space-after: (* (HSIZE 3) %head-after-factor%)
  (build-toc (current-node)
     (toc-depth (current-node))))
(empty-sosofo))

    (process-children)

;;; BEGIN ADDITION
    (if %endnotes-on-own-page%
(empty-sosofo)
;;; END ADDITION
(make-endnotes))

    (if (and %generate-article-toc% 
     (not (generate-toc-in-front))
     (not %generate-article-toc-on-titlepage%)
     (not %generate-article-titlepage-on-separate-page%))
(make display-group
  space-after: (* (HSIZE 3) %head-after-factor%)
  (build-toc (current-node)
     (toc-depth (current-node))))
(empty-sosofo))))

;;; BEGIN ADDITION
      (if %endnotes-on-own-page%

  (make simple-page-sequence
    page-n-columns: %page-n-columns%
    page-number-restart?: (or %article-page-number-restart% 
      (book-start?))
    page-number-format: ($page-number-format$)
    use: default-text-style
    left-header:   ($left-header$)
    center-header: ($center-header$)
    right-header:  ($right-header$)
    left-footer:   ($endnotes-left-footer$)
    center-footer: ($endnotes-center-footer$)
    right-footer:  ($endnotes-right-footer$)
    start-indent: %body-start-indent%
    input-whitespace-treatment: 'collapse
    quadding: %default-quadding%

    (make-endnotes))
  (empty-sosofo))
;;; END ADDITION

      (if (and %generate-article-toc% 
               (not %generate-article-toc-on-titlepage%)
               %generate-article-titlepage-on-separate-page%
               (not (generate-toc-in-front)))
          (make simple-page-sequence
            page-n-columns: %page-n-columns%
            use: default-text-style
            quadding: %default-quadding%
            (build-toc (current-node)
                       (toc-depth (current-node))))
          (empty-sosofo)))))

(element section ($maybe-paged-section$))
(element (article appendix) ($maybe-paged-section$))
(element (article glossary) ($maybe-paged-section$))

(define ($maybe-paged-section$)
  (if (and %article-section-starts-new-page%
   (not (is-section-level-element (parent (current-node)))))
      (make simple-page-sequence
;; WARNING: all this is copied from the page-seq above
page-n-columns: %page-n-columns%
page-number-restart?: (or %article-page-number-restart% 
  (book-start?))
page-number-format: ($page-number-format$)
use: default-text-style
left-header:   ($left-header$)
center-header: ($center-header$)
right-header:  ($right-header$)
left-footer:   ($left-footer$)
center-footer: ($center-footer$)
right-footer:  ($right-footer$)
start-indent: %body-start-indent%
input-whitespace-treatment: 'collapse
quadding: %default-quadding%

($section$))
      ($section$)))

14.

Styling html output from DSSSL

Tammy



On Thu, Feb 07, 2002 at 01:55:03PM -0800, Ben Schepens wrote:
> Is it possible to properly mark up source code in a docbook file so that
> meinproc will produce html with the source code in a 'greybar' or colored
> background?

You can do this if you put the source code inside <screen> tags and add the following to your custom stylesheet

(element tgroup
  (let* ((wrapper   (parent (current-node)))
	 (frameattr (attribute-string (normalize "frame") wrapper))
	 (pgwide    (attribute-string (normalize "pgwide") wrapper))
	 (footnotes (select-elements (descendants (current-node)) 
				     (normalize "footnote")))
	 (border (if (equal? frameattr (normalize "none"))
		     '(("BORDER" "0"))
		     '(("BORDER" "1"))))
	 (bgcolor '(("BGCOLOR" "#E0E0E0")))
	 (width (if (equal? pgwide "1")
		    (list (list "WIDTH" ($table-width$)))
		    '()))
	 (head (select-elements (children (current-node)) (normalize "thead")))
	 (body (select-elements (children (current-node)) (normalize "tbody")))
	 (feet (select-elements (children (current-node)) (normalize "tfoot"))))
    (make element gi: "TABLE"
	  attributes: (append
		       border
		       width
		       bgcolor
		       '(("CELLSPACING" "0"))
		       '(("CELLPADDING" "4"))
		       (if %cals-table-class%
			   (list (list "CLASS" %cals-table-class%))
			   '()))
	  (process-node-list head)
	  (process-node-list body)
	  (process-node-list feet)
	  (make-table-endnotes))))


;;Should verbatim items be 'shaded' with a table?
(define %shade-verbatim% 
 #t)

;;Define shade-verbatim attributes
(define ($shade-verbatim-attr$)
 (list
  (list "BORDER" "0")
  (list "BGCOLOR" "#E0E0E0")
  (list "WIDTH" ($table-width$))))
15.

Float images

Juan R. Migoya


> We're rather fond of tabulating various GUI items and including a small
> image of the item in the table. This looks great in HTML, but we're finding
> that our RTF output (from SGML DocBook 3.1 via jade and DSSSL) is erratic
> in this regard. The images wind up next to the table, and so have to be
> laboriously replaced in the table from which they sprang.
>
> Is this a well-known problem? If not, I'll update my stylesheets, etc. But
> before I did that I just wanted to find out how unique we are in this regard.

Yes, it's a very well known problem I'm afraid. Using tables doesn't work neither with rtf nor tex. So it has been said that "FLOAT IMAGES ARE NOT SUPPORTED".

Anyway, the folks of Mandrake have made a customization of Jadetex and the DSSSL to allow text wrap along one side of an image. See: mandrake

16.

Change justified text

Steffen Maier



> I'm writing a doc in docbook. Using the command 
> "db2html -u -d ~/ldp.dsl file.sgml", I get some spaces between words
> on some lines (I think you call it justify). I don't want these spaces.
> What can I do to omit them?

In your customization driver file (see dssslgeneral.html#custom for further details) add the follwing:

(define %default-quadding% 'start)

See also dssslpdf.html#justified. One last thing: I'm not sure how to chain the customization drivers as you already seem to use the one from the LDP. A wild guess would be to make your own and let it point to ldp.dsl. OTOH, if ldp.dsl is located in your home dir you might as well insert/replace the necessary line right there.

17.

Remove bold on figure titles

Norm Walsh



| Using DSSSL, how can I remove the bold'ness of <figure> titles or
| labels? I'd like the "Figure N. " part to still be in bold, however.

In HTML, I think this will work. Something roughly isomorphic should do the trick in print.

(define ($formal-object$ #!optional (rule-before? #f) (rule-after? #f))
  (let* ((nsep  (gentext-label-title-sep (gi)))
         (id    (element-id))
         (title-inline-sosofo 
                (make sequence
                  (make element gi: "B"
                    (if (member (gi) (named-formal-objects))
                         (make sequence
                           (literal (gentext-element-name (gi)))
                          (if (string=? (element-label) "")
                              (literal nsep)
                              (literal " " (element-label) nsep)))
                        (empty-sosofo)))
                  (with-mode title-mode
                    (process-node-list 
                     (select-elements (children (current-node))
                                      (normalize "title"))))))
         (title-sosofo (make element gi: "P"
                                   title-inline-sosofo)))
         (object-sosofo (process-children)))
    (make element gi: "DIV" 
          attributes: (list
                       (list "CLASS" (gi)))

          (if rule-before?
              (make empty-element gi: "HR")
              (empty-sosofo))

          (if id
              (make empty-element gi: "A"
                    attributes: (list 
                                 (list "NAME" id)))
              (empty-sosofo))
          
          (if (object-title-after)
              (make sequence
                object-sosofo
                title-sosofo)
              (make sequence
                title-sosofo
                object-sosofo))

          (if rule-after?
              (make empty-element gi: "HR")
              (empty-sosofo)))))
18.

SGML character entities (xxxx not a function error)

Matt Gruenke

I recently discovered that I ought to be using the SGML character entities, if I'm using DSSSL (yup, the 'ol "X00E1" is not a function name error). Once I discovered that I needed these entities, I reviewed all the documents I knew of, which describe installing DocBook, and couldn't find any pointer to the SGML ISO character entities.

BTW, To fix the above error, all I had to do was install the entity definition files, which take the form 'iso-*.gml', (though the ones I found are potentially stale, which is why I'm asking) and create a catalog file that maps each PUBLIC identifier for one of these files to the SGML version. Then, I placed the path to this file in my SGML_CATALOG_FILES environment variable, *before* the docbook.cat that was included with the XML DTD. I don't know whether the first PUBLIC -> SYSTEM identifier mapping is supposed to take precedence over any following ones, but it seems to work this way with OpenJade 1.3.

19.

SDATA entities don't work in XML document

David (Cramer or Carlisle)

Just define the entities to be the unicode equivalents (&#160; in the case of nbsp)

You'll find XML versions of the standard entity sets in lots of places (some of them even agree on the unicode mappings:-)

The mathml spec comes with some: http://www.w3.org/TR/MathML2/DTD-MathML-20010221.zip for example, as does docbook, I believe.

20.

How to put images in document header elements

Juan R. Migoya

Try this:

(define (page-inner-header gi)
  (cond
   ((equal? (normalize gi) (normalize "dedication")) (empty-sosofo))
   ((equal? (normalize gi) (normalize "lot")) (empty-sosofo))
   ((equal? (normalize gi) (normalize "part")) (empty-sosofo))
   ((equal? (normalize gi) (normalize "toc")) (empty-sosofo))
   (else 
	(make sequence
		font-size: 2.54cm
     	 (make external-graphic
		display?: #f
		entity-system-id: "C:/logos/mylogo.pdf"
		max-width: 2.54cm
		max-height: 2.54cm
		)))))
21.

DSSSL text justification for html output

Unknown

%default-quadding% (for the html stylesheets) specifies the value of the "ALIGN" attribute of the <P> tag in the HTML. i.e it is not a DSSSL attribute!

It defaults to "#f" which means "don't generate an align tag at all"

otherwise it can be

"left", "center", "right", "justify".

So you should have

   (define %default-quadding% "left")

which will cause the paragraph to be generated with <P ALIGN="left">

Of course, you should, nowadays, use CSS to set an appropriate attribute with a stylesheet:

(define %stylesheet%
  ;; Name of the stylesheet to use
  "style.css")

(define %css-decoration%
  ;; Enable CSS decoration of elements
  #t)

and leave %default-quadding% as #f.

22.

legalnotice style change, dsssl.

Peter Eisentraut



> I am trying to modify how a legalnotice is printed in pdf. Basically I
> would like the citetitle markup centered on the page followed by the
> remaining paragraphs of the legalnotice. I have tried the following code
> below but the citetitle element gets printed before all paragraphs.... Does
> anyone have an idea on what I should change with the code to get my desired
> output.
>
> The following is a summary of the structure of my legalnotice in docbook xml.
> <legalnotice>
> <para>
> <citetitle>Copyright, Confidentiality and Disclaimer</citetitle>
> </para>

I think you want to use

<legalnotice>
<title>Copyright ...</title>
<para>
...
</para>
<para>
...
</para>
...
</legalnotice>

and leave the stylesheet alone.

If all you want is to center the title, override the form

(mode formal-object-title-mode (element title ...))

seen in file dbblock.dsl.

23.

Using RTF stylenames

Tony Graham

There's the heading-level characteristic described at: jclark.com And it works for PDF too (TeX backend). With it you can have the bookmarks.

24.

Numbering sect1 sections

Juan R. Migoya


> When I generate PDF or HTML output from my DocBook book files the "sect1"
> sections aren't numbered. Therefore the table of contents looks like this:
>
>   Table of contents
>
>   Abstract
>   1. Introduction
>        Background
>        Method
>   2. Simulation
>
> I want the "Background" and "Method" sections to be numbered "1.1" and
> "1.2" respectively, but I have no idea of how to fix that. Could it be a
> bug or is there a setting I have to change?

From dbpara.dsl


(define %section-autolabel%
  ;; REFENTRY section-autolabel
  ;; PURP Are sections enumerated?
  ;; DESC
  ;; If true, unlabeled sections will be enumerated.
  ;; /DESC
  ;; AUTHOR N/A
  ;; /REFENTRY
  #f)

Change it to #t

25.

footnote formatting in DSSSL

Togan Muftuoglu


>I need to have the bop-footnotes formatted as follows:
>
>1. two lines before the rule, one line after;
>2. the rule should extend from the left margin to the right one;
>3. numbers reset on each page;
>4. the font size should be 10pt, the number should be superscript.
>
>I searched the whole /usr/share/sgml directory of my Debian system with
>no results.

Well I searched my SuSE system and and found the following part (just kidding I do not know where I found this sowehere on the web ) This is for the footer rule

(define ($custom-header-footer$)
  (let ((component (ancestor-member (current-node)
                                    (append (division-element-list)
                                            (component-element-list)))))
    (make sequence
      font-weight: 'bold
      font-posture: 'upright
      (make rule
	orientation: 'horizontal
	length: %text-width%
	line-thickness: 1pt
	start-indent: 0pt
	space-before: (/ %block-sep% 4))
      (literal "For internal use only"))))

(define (page-inner-footer gi)
  (empty-sosofo))

(define (page-center-footer gi)
  (cond
   ((equal? (normalize gi) (normalize "dedication")) (empty-sosofo))
   ((equal? (normalize gi) (normalize "lot")) (empty-sosofo))
   ((equal? (normalize gi) (normalize "part")) (empty-sosofo))
   ((equal? (normalize gi) (normalize "toc")) (empty-sosofo))
   (else ($custom-header-footer$))))
26.

Two sided output in dsssl

??


> - how to make openjade when producing two-sided
>   output, to put the chapter to the next available
>   page (not to next even (right side)?

If you are using reasonably recent DSSSL modular stylesheets, openjade and jadetex then you can use the characteristic two-page-start-on-right?

which can either be true of false (#t or #f).

Probably putting the following in your driver file is the easiest way to do it:


(declare-characteristic two-side-start-on-right?
   "UNREGISTERED::OpenJade//Characteristic::two-side-start-on-right?"
#f)
27.

Specify utf-8 encoding on html output

Jirka Kosek



> But, my problem is that my audience may not be savvy enough to figure out
> to change their browser's encoding to UTF-8. So, they will see the
> unexpected character.

You can include following code into your customization layer:

(define %html-header-tags% 
  '(("META" ("HTTP-EQUIV" "Content-Type") ("CONTENT" "text/html;
charset=utf-8"))))

This will insert meta tag with encoding information into each generated HTML file. Most browsers take encoding information from this place (but you must be careful when serving pages from web-server, encoding information served in HTTP headers has higher priority) and will change encoding automatically.

28.

Including PHP in HTML output

Brandon Ibach


> It turns out I had the driver file all along, and had tried it, but with no
> luck. I actually run:

>      "make html"

> which seems to run:

>      "openjade -i wdoclinks -V woutdoclinks=ignore -d 'laszlo.dsl#html' -t
> xml index.sgml"

> laszlo.dsl being the driver file. Is this the same thing?

Right. The driver file here is laszlo.dsl. However, a specific portion of that file is being singled out with the "#html" part of the argument to the -d option. You should find a line something like:

	<style-specification id="html" use="docbook">

in laszlo.dsl. The code inside this tag is the stylesheet being used. Any customizations you provide need to go inside of it.

> What I'm trying to output is not HTML tags, but PHP code, surrounded by
> "<?php" and "?>". Only don't think of it as tags. Just thing of it as a bit
> of text that has to go at the top/bottom of each page, IN PLACE OF the usual
> "<html><head><title......<body>" and "</body></html>".

The designers of PHP were smart. The construct that is used to embed PHP code in an HTML page is an XML "processing-instruction", which looks like: <?target blah,blah?> The "target" is an XML-ism to provide a little more structure to PIs than SGML had. XML also adds the question mark at the end (just before the ">" sign), where SGML did not have this. Because your "make html" command is invoking the XML backend of OpenJade (the "-t xml" option), you can use the following to produce PHP code:

	(make processing-instruction data: "php ...")

You will need to take care with your PHP code (inserted in place of the ..., above), as certain characters, mainly <, > and &, can cause problems, depending upon how your stylesheet is structured, but I think you touched on that already with a CDATA section. As for what code to override, you'll probably want to redefine the html-document function from dbhtml.dsl (about 60 lines down in the file, in my copy of Norm's stylesheets). There's some kind of complex stuff going on in this function with chunking (breaking the output into multiple files), header generation, etc, so be careful. ;)

Ian Castle adds

You want a "processing-instruction"

for example:

<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style
Sheet//EN">

<style-sheet>
<style-specification>
<style-specification-body>

(declare-flow-object-class processing-instruction
  "UNREGISTERED::James Clark//Flow Object
Class::processing-instruction")

(element book
	(make processing-instruction data: "php myphpstatement")
)

</style-specification-body>
</style-specification>
</style-sheet>

Would generate

<?php myphpstatement?>
29.

Including special characters in DSSSL

Brandon Ibach


> In C language, when I want to represent a null caracter
> I use "\0". When I want to represent a tab, I use "\t".

> And in DSSSL? There are representations to tab and null caracters?
> And others represantations?

There are several ways to represent any given character. For just a single character (not a string), a la '\t' in C, you would use the #\U-0009 syntax. In a string, a la "This \t is a tab" in C, you would use "This \U-0009; is a tab". The word after the slash in either case can be either the ISO 10646 name in lower-case with hyphens between words (for some characters, anyway), or U-XXXX, where XXXX is the 16-bit Unicode value in four upper-case hexadecimal digits, such as 0000 for null or 0009 for tab.

I can imagine a variety of reasons for wanting a tab character in your DSSSL script, but I can't imagine a need for the null character, unless you're somehow reading or writing non-SGML data... I hope this helps. If not, some more information on what you're looking to accomplish would help.

> For example:

> (element para
> (make paragraph
>  (literal "X")
>  (process-children)))

> If I insert tag <para> , in my text will appear the X caracter in the
> start of my paragraph, right?

That's right.


> If i want to insert a paragraph
> and I don't want to use a definition "first-line-start-indent: 1cm",
> for example.

> If I want to use an code like U-0009 to ident my para, is it possible?
> Is it wrong?
> Where I insert the U-0009 code, and how?
>

Honestly, I don't know offhand what effect this would have in formatted output. How would the formatter (such as TeX) know how much to indent the paragraph when it sees the tab character? If you really don't want to use "first-line-start-indent", how about a line-field object?

     (element para
       (make paragraph
         (make line-field field-width: 1cm)
         (process-children)))

>  If I want to insert an hidden caracter in my paragraph
> for example. Do I use U-0000 code?
> In my example, Do I substitute (literal "X") for ?(hidden)? (literal), or
> I need to use the U-0000 code?

> And now, why am I trying to insert an hidden caracter in my DSSSL
> document?
> Because, If I can do this:

> (element para
> (make paragraph
>   (make simple-page-sequence
>   (literal "X") ;; HERE I WANT TO INSERT AN HIDDEN CARACTER
>       break-before: 'page)
>       (process-children)))))

> If I can do this,
> I can insert blank pages in my DSSSL documents 

Yes, I agree with your approach, however, why not just:

     (element simpara
       (if (string=? "" (data (current-node)))
           (make paragraph
             break-before: 'page
             (literal " "))
           (make paragraph
             (process-children))))

How is the "hidden character" that you had in mind different from a character that makes no mark upon the page, like a space? Playing with control characters (such as the null, or 0) that are outside of the normal range dealt with in SGML is likely to cause problems.

30.

Sort a node list

Jean-Marie Kubek


> I am looking in the spec and the archive (general archive is broken?) to
> find a way to sort a node list.
> Does anyone know a simple way to do it?

Yes, take a 'basic' quicksort procedure on lists, abstract it in order to create a generic factory procedure for 'quicksorting' collections and call this generic procedure using the basic functions on node-lists. You'll find an example at the end of this message :)

But I found the node-list-sort procedure defined below rather inefficient (because of the constructor node-list ?) and preferred to do the following :

        (define (node-list-sort nl)
           (list->node-list
               (list-sort 
                  (node-list->list nl))))

; 1- quicksort-maker : a generic quicksort procedure factory on abstract collections :

(define (quicksort-maker cons null? car cdr  append empty)
  ; cons --> add an element to a collection
  ; null? --> empty collection predicate
  ; car --> head of the collection
  ; cdr --> rest of the collection
  ; append --> concat two collections
  ; empty --> the empty collection
  (letrec
    ((collect
       (lambda (pivot ls lgroup rgroup less?)
         (if (null? ls)
             (append (quicksort lgroup less?) 
		     (cons pivot (quicksort rgroup less?)))
             (if (less? pivot (car ls))
                 (collect pivot (cdr ls) lgroup (cons (car ls) rgroup) less?)
                 (collect pivot (cdr ls) (cons (car ls) lgroup) rgroup less?)))))
     (quicksort
      (lambda (ls less?)
	(if (or (null? ls) (null? (cdr ls)))
	    ls
	    (collect (car ls) (cdr ls)  empty empty less?)))))
    quicksort))

; 2- a list sorting procedure :

   (define list-sort (quicksort-maker cons 
				   null? 
				   car 
				   cdr 
				   append 
				   '()))

; 3- a node-list sorting procedure :

   (define node-list-sort (quicksort-maker node-list
					node-list-empty? 
					node-list-first 
					node-list-rest
					node-list 
					(empty-node-list)))