Subject: Re: Preceding list function From: Brandon Ibach <bibach@xxxxxxxxxxxxxx> Date: Fri, 4 Aug 2000 18:18:38 -0500 |
Quoting Norman Walsh <ndw@xxxxxxxxxx>: > I just found a bug in the DocBook stylesheets and I don't see an easy > way to fix it. But the structure of the error is such that I feel > there ought to be an easy way. Can anyone see what I'm missing? > Well, here's a possible solution (untested, mind you). I know I don't have your most recent stylesheets, so I'll just quote the relevant function from the ones I have, with the parts that I changed commented. (define (orderedlist-listitem-number listitem) ;; return the number of listitem, taking continuation into account (let* ((orderedlist (parent listitem)) (listitems (select-elements (children orderedlist) (normalize "listitem"))) (continue? (equal? (attribute-string (normalize "continuation") orderedlist) (normalize "continues"))) ;; only look at lists in the same component (preclist (if continue? (let* ((lists (select-elements (descendants (ancestor-member ;;;; orderedlist (parent orderedlist) ;;;; (component-element-list))) (append (list (normalize "orderedlist")) (component-element-list)))) (normalize "orderedlist")))) (let loop ((nl lists) (prev (empty-node-list))) (if (node-list-empty? nl) (empty-node-list) (if (node-list=? (node-list-first nl) (parent listitem)) prev (loop (node-list-rest nl) ;;;; (node-list-first nl)))))) (let ((nd (node-list-first nl)) (np (ancestor (normalize "orderedlist") nd))) (if (or (node-list-empty? np) (not (node-list-contains? lists np))) nd prev))))))) (empty-node-list))) (precitem (node-list-last (children preclist))) (precitem-number (if continue? (orderedlist-listitem-number precitem) 0))) (+ precitem-number (child-number listitem)))) Now... the changes. By adding orderedlist to the list of gis to match in the call to ancestor-member, we can narrow our search to only the other lists within the parent orderedlist, if there is one. Of course, we need to start with the parent of the current list, to avoid matching the list we're in. The only other trick is to make sure the list we find is at the same depth as the current list. By keeping the search inside the parent list (if there is one), we know that the current list will be at the "top level" of the lists we're looking at, so we just need to ensure that any list we consider does not have an ancestor list which is also in the "list of lists" that we're traversing. If I haven't made this clear enough (likely, I suppose... it's been a long day :P ), or if it doesn't actually work, let me know. -Brandon :) DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Preceding list function, Norman Walsh | Thread | Re: Preceding list function, Norman Walsh |
Re: Preceding list function, Oisin McGuinness | Date | Re: Preceding list function, Norman Walsh |
Month |