Subject: RE: Changing the value of a variable From: Oisin McGuinness <oisin@xxxxxxxx> Date: Thu, 29 Jul 99 10:47:20 -0400 |
"joseph, Gershon" <Gershon_joseph@xxxxxxxxxxxxx> asked: "How do people generally generate numbering when the numbering has to be reset when a particular element is encountered?" in the context of a situation where <table> elements nested inside various <sectXX> elements inside <chap> elements need to be numbered according to their sequence inside the chapter. Firstly, the code in the DocBook stylesheets (visit www.nwalsh.com) can do this kind of thing; see the code in common/dbcommon.dsl; but there is a lot of it; it is extremely flexible. Secondly, what you want, from a table node where you are generating a label, is to find its nearest chapter ancestor (use the ancestors function (from the DSSSL cookbook, then filter the returned node-list using a filter that looks for gi chap only, then take node-list-first), and get all the table descendants of your chap node which precede your table node, and count this. All these pieces can be written by hand; making them generic for other situations takes some effort. Here are a couple of functions you might use: (define (chap-ancestors #!optional (nd (current-node))) (let ((precursors (ancestors nd))) (node-list-filter (lambda (node) (string=? (gi node) "CHAP")) precursors))) (define (chap-ancestor #!optional (nd (current-node))) (node-list-first (chap-ancestors nd))) (define (table-number-in-chapter #!optional (nd (current-node))) (let* ((my-chap (chap-ancestor nd)) (chap-tables (select-elements (descendants my-chap) "TABLE"))) (node-list-position nd chap-tables))) where the function node-list-position returns the position (1 ... length-of-list) of nd in the given node-list, an easy to write function which I find useful. Hope this helps. Oisin McGuinness Sumitomo Bank Capital Markets 277 Park Avenue New York NY 10172 USA (212)-224-4913, email: oisin@xxxxxxxx DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Changing the value of a variabl, Brandon Ibach | Thread | Table of Contents generation, Russell Senior |
Re: substring comparison, Jany Quintard | Date | Re: How to find a procedure given a, Brandon Ibach |
Month |