Re: COOKBOOK: Hierarchical numbering using specific countable elements

Subject: Re: COOKBOOK: Hierarchical numbering using specific countable elements
From: Tony Graham <tgraham@xxxxxxxxxxxxxxxx>
Date: Fri, 22 May 1998 15:39:12 -0400 (EDT)
At 22 May 1998 11:59 -0500, Glenn R. Kronschnabl wrote:
 > http://www.mulberrytech.com/dsssl/dsssldoc/cookbook/cookbook.html#AEN135
 > 
 > I am trying to use the cookbook procedure for numbering sections.  I
 > have a simple DTD/document that just uses <div><title>title</title> to
 > mark sections and they can be nested.  I have copied the procedures
 > verbatim, and I have the following local definition:
 > 
 > (define countable-elements '("div"))
 > 
 > I am trying to get numbering like:
 > 
 > 1. section 1
 > 1.1 nested section in section 1
 > 1.2 etc
 > 2. section 2
 > 
 > but in the rtf output, all I end up with is:
 > 
 > 1 section 1
 > 1 nested
 > 2 etc
 > 1 section 2
 > 
 > What do I need to change from the cookbook procedure to get what I want?  

The cookbook procedure (by Richard Light, but making that information
appear in the HTML is something I need to fix) is meant for numbering
elements in a way that cuts across the hierarchy.  What you want is to
number elements in a way that reflects the hierarchy, and for that you
can use hierarchical-number-recursive, but there isn't an example in
the Cookbook.

Try this:

(element (DIV TITLE)
	 (make paragraph
	       (literal
		(string-append
		 (let loop ((hierarchy-list
			     (hierarchical-number-recursive
			      "DIV")))
		   (if (null? hierarchy-list)
		       ""
		       (let ((item-number (car hierarchy-list)))
			 (string-append
			  (format-number item-number "1")
			  "."
			  (loop (cdr hierarchy-list))))))
		" "))
	       (process-children)))

Regards,


Tony Graham
=======================================================================
Tony Graham
Mulberry Technologies, Inc.                         Phone: 301-315-9632
17 West Jefferson Street, Suite 207                 Fax:   301-315-8285
Rockville, MD USA 20850                 email: tgraham@xxxxxxxxxxxxxxxx
=======================================================================


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread