File: dbgloss.dsl

package info (click to toggle)
docbook-stylesheets 1.49-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 7,576 kB
  • ctags: 33
  • sloc: perl: 444; xml: 115; makefile: 98; sh: 27
file content (186 lines) | stat: -rw-r--r-- 5,466 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
;; $Id: dbgloss.dsl,v 1.5 1998/12/29 20:39:14 nwalsh Exp $
;;
;; This file is part of the Modular DocBook Stylesheet distribution.
;; See ../README or http://www.berkshire.net/~norm/dsssl/
;;

;; ========================= GLOSSARY ELEMENTS ==========================

;; HACK ALERT!  There is no top-level wrapper around one or more GLOSSENTRYs,
;; so this code has to look around and output the right thing for the
;; front matter and then the GLOSSENTRYs.  Ugh.

(define ($glossary-frontmatter$)
  (let loop ((nl (children (current-node))) (headlist (empty-node-list)))
    (if (node-list-empty? nl)
	headlist
	(if (equal? (gi (node-list-first nl)) (normalize "glossentry"))
	    headlist
	    (loop (node-list-rest nl) (node-list
				       headlist
				       (node-list-first nl)))))))

(define ($glossary-glossentrys$)
  (let loop ((nl (children (current-node))) (gelist (empty-node-list)))
    (if (node-list-empty? nl)
	gelist
	(loop (node-list-rest nl)
	      (if (equal? (gi (node-list-first nl)) (normalize "glossentry"))
		  (node-list gelist (node-list-first nl))
		  gelist)))))

(define ($glossary-body$)
  (make element gi: "DIV"
	attributes: '(("CLASS" "GLOSSARY"))
	($component-title$)
	(process-node-list ($glossary-frontmatter$))
	(if (not (node-list-empty? ($glossary-glossentrys$)))
	    (make element gi: "DL"
		  (process-node-list ($glossary-glossentrys$)))
	    (empty-sosofo))))

(element glossary
  (html-document (with-mode head-title-mode 
		   (literal (element-title-string (current-node))))
		 ($glossary-body$)))

(element (glossary title) (empty-sosofo))

(element glossdiv 
  (make element gi: "DIV"
	attributes: (list 
		     (list "CLASS" (gi)))
	($section-title$)
	(process-node-list ($glossary-frontmatter$))
	(if (not (node-list-empty? ($glossary-glossentrys$)))
	    (make element gi: "DL"
		  (process-node-list ($glossary-glossentrys$)))
	    (empty-sosofo))))

(element (glossdiv title) (empty-sosofo))

(element glosslist 
  (make element gi: "DIV"
	attributes: (list 
		     (list "CLASS" (gi)))
	(make element gi: "DL"
	      (process-children))))

(element glossentry (process-children))

(element (glossentry glossterm) 
  (let ((id (attribute-string (normalize "id") (parent (current-node)))))
    (make element gi: "DT"
	  (if id
	      (make element gi: "A"
		    attributes: (list
				 (list "NAME" id))
		    (make element gi: "B"
			  (process-children)))
	      (make element gi: "B"
		    (process-children))))))

(element (glossentry acronym) (empty-sosofo))
(element (glossentry abbrev) (empty-sosofo))

(element (glossentry glossdef)
  (make element gi: "DD"
	(process-children)))

(element (glossterm revhistory)
  (empty-sosofo))

(element (glossentry glosssee)
  (make element gi: "DD"
	(if (attribute-string (normalize "otherterm"))
	    (make element gi: "P"
	      (make element gi: "EM"
		    (literal (gentext-element-name (gi))
			     (gentext-label-title-sep (gi))))
	      (make element gi: "A"
		    attributes: (list (list "HREF"
					    (link-target 
					     (attribute-string
					      (normalize "otherterm")))))
		    (with-mode otherterm
		      (process-element-with-id
		       (attribute-string (normalize "otherterm"))))))
	    (process-children))))

;; When we hit the first GLOSSSEEALSO, process all of them as a node-list
(element glossseealso
  (if (first-sibling?)
      (make element gi: "P"
	    (make sequence
	      (make element gi: "EM"
		    (literal (gentext-element-name (gi))
			     (gentext-label-title-sep (gi))))
	      (with-mode glossseealso
		(process-node-list
		 (select-elements (children (parent)) '(glossseealso))))
	      (literal ".")))
      (empty-sosofo)))

(mode glossseealso
  (element glossseealso
    (make sequence
      (if (first-sibling?)
	  (empty-sosofo)
	  (make element gi: "EM"
		(literal ", ")))
      (if (attribute-string (normalize "otherterm")) ;; but this should be required...
	  (make element gi: "A"
		attributes: (list (list "HREF"
					(link-target
					 (attribute-string
					  (normalize "otherterm")))))
		(with-mode otherterm
		  (process-element-with-id
		   (attribute-string (normalize "otherterm")))))
	  (process-children)))))

;; This is referenced within the GLOSSSEE and GLOSSSEEALSO element
;; construction expressions.  The OTHERTERM attributes on GLOSSSEE and
;; GLOSSSEEALSO (should) refer to GLOSSENTRY elements but we're only
;; interested in the text within the GLOSSTERM.  Discard the revision
;; history and the definition from the referenced term.
(mode otherterm
  (element glossterm
    (process-children))
  (element glossdef
    (empty-sosofo))
  (element revhistory
    (empty-sosofo))
  (element glosssee
    (empty-sosofo))
  (element (glossentry acronym)
    (empty-sosofo))
  (element (glossentry abbrev)
    (empty-sosofo)))

;; an inline gloss term
(element glossterm
  (let* ((linkend (attribute-string (normalize "linkend"))))
    (if linkend
	(make element gi: "A"
	      attributes: (list (list "HREF" (href-to (element-with-id 
						       linkend))))
	      ($italic-seq$))
	($italic-seq$))))

;; a first glossterm
(element firstterm
  (let* ((linkend (attribute-string (normalize "linkend")))
	 (sosofo  (if linkend
		      (make element gi: "A"
			    attributes: (list (list "HREF" 
						    (href-to 
						     (element-with-id 
						      linkend))))
			    ($italic-seq$))
		      ($italic-seq$))))
    (if firstterm-bold
	(make element gi: "B"
	      sosofo)
	sosofo)))