Subject: (dsssl) counting by element.attribute From: Mulberry Technologies List Owner<xsl-list-owner@xxxxxxxxxxxxxxxxxxxxxx> Date: Sun, 7 Oct 2001 20:23:24 -0400 |
>From: Trent Shipley <tcshipley@xxxxxxxxxxxxx> >Reply-To: tcshipley@xxxxxxxxxxxxx >To: dssslist@xxxxxxxxxxxxxxxxxxxxxx >Subject: HELP: counting by element.attribute >Date: Wed, 3 Oct 2001 16:44:19 -0700 > >---------------- >Main point! >---------------- >Problem synopsis: stylesheet counts objects that aren't displayed in printed >copy. >---------------- > >(element-number-list (list "DIV1" "NOTE")) > >As near as I can tell, this assembles (or appends to) a list of enumerations >and associates each element of the list with an associated node. It advances >an implicit counter every time it hits a DIV1 and an inner counter for NOTE. >Every time it finds the next DIV1 it resets the NOTE counter to zero. If >SCHEME had "dot" notaton for properties like C or Pascal style languages what >I would want (and don't know how to do is: > (element-number-list (list "DIV1" > (if-match-then-string(NOTE.TYPE["general"])) > ) > >(list "DIV" "NOTE") > >The analysis is as above except that DIV nests, causing the DIV counter to >flip too often. > >By happy coincidence a Chapter or Appendix level DIV is always a top level >DIV and is never without a HEAD (that is, title-for-this-div) child. > >So either this: > > (element-number-list > ((if-match-then-string(or DIV.TYPE["Chapter"] > DIV.TYPE["appendix"])) > (if-match-then-string(NOTE.TYPE["general"])) > ) > >or perhaps more elegantly this: > > (element-number-list > ((if-match-then-string > (increment when highest ancestor of element DIV changes) > (if-match-then-string(NOTE.TYPE["general"])) > ) > >Notice that in either case I only want to enumerate the sublist of NOTEs with >the TYPE "general". > >--------- >End main point. >-- >(PS. the cookbook's solution not only doesn't work, it has unspecified >DocBook dependencies.) >--- > >(list "NOTE") > >Just won't work because it doesn't nest the NOTE counter in the chapter >counter. > >=================================== >More detailed problem statement >=================================== > >Below is the bulk of the TEIL style sheet that deals with notes. > >There are various problems with the implementation. Of these the most >important is that it prints NOTEs that aren't there and counts DIVs that >don't have headers. In addition, I have to cope with the fact that DIVs can >nest. (So can notes, but a footnote type note should not contain other >footnotes although it could have a draft comment, for example.) > >TEI tends to be a "lumping" markup language. By this I mean that a there >aren't many elements but elements tend to have a lot of attribute values. > >I have overloaded the "NOTE" attribute so that it can indicate: > Endnote/footnotes > Bibliographic annotations > Draft comments > More specialized draft comments such as "double check spelling" > These need to appear in the output so I actually remember to > check the spelling > Notes that tell the processor to hide data > There are parts of primary keys used to seach the biblography > document base that should not be displayed according to the > style guide. (That I think I will take out. All TEIL items > have a "rend" attribute that I can set to "hidden") > > >------------ > >My current version is cosmetically closer to what I want. > >However it is absolutely unaware of chapters and it still enumerates all NOTE >and DIV elements without regard to whether the NOTE is of type "general" or >whether a DIV has a HEAD element that is displayed. > >Just as bad, it numbers notes sequentially for the entire TEXT element >without restarting for DIVs of type chapter. > > >==================== >Code snips follow. >==================== >===================== > >TEIL orginal > >===================== > >;; NOTE contains a note or annotation >(element NOTE (STANDARD-NOTE)) > > >;; treatment of NOTE-type elements is pretty simple at present. The current >;; Jade engine does not support the more complex page model, so there is >;; no point in trying to get notes to appear at the foot of the page, >;; chapter, etc. They are just output as a block at the end of the DIV1. > >(define (NOTE-HEADER) > (make sequence > label: 'endnotes > (make rule > orientation: 'horizontal > space-before: *para-sep* > start-indent: *left-right-margin* > end-indent: *left-right-margin* > display-alignment: 'center) > (make paragraph > use: p-style > start-indent: *body-start-indent* > space-before: *para-sep* > font-weight: 'bold > (literal "Notes:")))) > >;; STANDARD-NOTE outputs a reference to the note in the current position, and >;; places the note itself at the end of the section. (This relies on the >;; definition of STANDARD-PAGE-SEQUENCE including a mapping for the endnotes >;; label.) >(define (STANDARD-NOTE) > (make sequence > (make line-field > position-point-shift: 2pt > font-size: (- *bf-size* 2pt) > font-weight: 'bold > (literal > (string-append "[" > (format-number-list > (element-number-list > (cond > ((have-ancestor? "DIV1") (list "DIV1" "NOTE")) > ((have-ancestor? "DIV") (list "DIV" "NOTE")) > (else (list "NOTE")))) > "1" ".") "]"))) > (make sequence > label: 'endnotes >;; (car (cdr below can be replaced by (cadr once implemented. (This gets the >second number >;; in the list, i.e. the count of NOTE elements within the DIV): > (if (= (car( cdr (element-number-list (list "DIV1" "NOTE")))) 1) > (NOTE-HEADER) > (empty-sosofo))) > (make paragraph > label: 'endnotes > use: p-style > font-size: (- *bf-size* 2pt) > start-indent: *body-start-indent* > line-spacing: (- (* *bf-size* *line-spacing-factor*) 2pt) > (literal > (string-append > (format-number-list > (element-number-list > (cond > ((have-ancestor? "DIV1") (list "DIV1" "NOTE")) > ((have-ancestor? "DIV") (list "DIV" "NOTE")) > (else (list "NOTE")))) > "1" ".") ". ")) > (process-children-trim)))) > >=================================== >=================================== > >Current version > >=================================== > > >;; NOTE contains a note or annotation >(element NOTE (case (attribute-string "type") > (("hidden") (literal "")) > (("draftComment") > (make sequence > font-family-name: *mono-font-family* > (literal "[") > (literal (attribute-string "type")) > (literal ": ") > (process-children-trim) > (literal "]"))) > (("general")(STANDARD-NOTE)) > (else (make sequence > font-family-name: *mono-font-family* > (literal "[WARNING! ") > (literal (attribute-string "type")) > (process-children-trim) > (literal "]"))) > ) >) > >; and later there will be bibliographic annotations. > >===== > >;; treatment of NOTE-type elements is pretty simple at present. The current >;; Jade engine does not support the more complex page model, so there is >;; no point in trying to get notes to appear at the foot of the page, >;; chapter, etc. They are just output as a block at the end of the DIV1. > >(define (NOTE-HEADER) > (make sequence > label: 'endnotes > (make rule > orientation: 'horizontal > space-before: *para-sep* > start-indent: *left-margin* > end-indent: *right-margin* > display-alignment: 'center) > (make paragraph > use: p-style > start-indent: *body-start-indent* > space-before: *para-sep* > font-weight: 'bold > (literal "Notes:")))) > >;; STANDARD-NOTE outputs a reference to the note in the current position, and >;; places the note itself at the end of the section. (This relies on the >;; definition of STANDARD-PAGE-SEQUENCE including a mapping for the endnotes >;; label.) >(define (STANDARD-NOTE) > (make sequence > (make line-field > position-point-shift: (* *bf-size* .5) > font-size: (- *bf-size* 2pt) > font-weight: 'medium > (literal > (string-append > (format-number-list > (element-number-list > ;(cond > ; ((have-ancestor? "DIV1") (list "DIV1" "NOTE")) > ; ((have-ancestor? "DIV") (list "DIV" "NOTE")) > ; (else (list "NOTE")) > ;(list "NOTE")) > (cond > ((have-ancestor? "DIV1") > (list "DIV1" "NOTE")) > ((and (have-ancestor? "DIV") > (equal? "general" (attribute-string "type"))) > (list "NOTE")) > (else (list)))) > "1" ".") " "))) > ;(make sequence > ;label: 'endnotes >;; (car (cdr below can be replaced by (cadr once implemented. (This gets the >second number >;; in the list, i.e. the count of NOTE elements within the DIV): > ;(if (= (car( cdr (element-number-list (list "DIV1" "NOTE")))) 1) > ; (NOTE-HEADER) > ; (empty-sosofo))) > (make sequence > label: 'endnotes > use: p-style > font-size: (- *bf-size* 2pt) > start-indent: *body-start-indent* > line-spacing: (- (* *bf-size* *line-spacing-factor*) 2pt) > (literal > (string-append > (format-number-list > (element-number-list > (cond > ((have-ancestor? "DIV1") > (list "DIV1" "NOTE")) > ((and (have-ancestor? "DIV") > (equal? "general" (attribute-string "type"))) > (list "NOTE")) > (else (list)))) > "1" ".") " ")) > (process-children-trim)))) -- ====================================================================== B. Tommie Usdin mailto:btusdin@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Phone: 301/315-9631 Suite 207 Direct Line: 301/315-9634 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: (dsssl) Practical Bibliography , Markus Hoenicka | Thread | (dsssl) Double-dash sign and TeX ba, Samuel Tardieu |
Re: (dsssl) Practical Bibliography , Trent Shipley | Date | Re: (dsssl) Practical Bibliography , Trent Shipley |
Month |