File: dbpi.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 (61 lines) | stat: -rw-r--r-- 1,970 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
;; $Id: dbpi.dsl,v 1.1 1999/03/06 21:32:04 nwalsh Exp $
;;
;; This file is part of the Modular DocBook Stylesheet distribution.
;; See ../README or http://nwalsh.com/docbook/dsssl/
;;

(define (pi-value component piname)
  ;; Returns the value of the (?piname value) PI (if one exists)
  ;; as a child of component, otherwise returns #f
  ;;
  (let loop ((nl (select-by-class (children component) 'pi)))
    (if (node-list-empty? nl)
	#f
	(let ((pidata (node-property 'system-data (node-list-first nl))))
	  (if (and (> (string-length pidata) (string-length piname))
		   (equal? piname
			   (substring pidata 0 (string-length piname))))
	      (substring pidata
			 (+ (string-length piname) 1)
			 (string-length pidata))
	      (loop (node-list-rest nl)))))))

(define (inherited-pi-value component piname)
  (let loop ((value #f) (nd component))
    (if (or value (node-list-empty? nd))
	value
	(loop (pi-value nd piname) (parent nd)))))

(define (dbhtml-findvalue pi-field-list name)
  ;; pi-field-list is '(pitarget name1 value1 name2 value2 ...)
  (let loop ((slist (cdr pi-field-list)))
    (if (null? slist)
	#f
	(if (string=? (car slist) name)
	    (car (cdr slist))
	    (loop (cdr (cdr slist)))))))

(define (dbhtml-value component name)
  ;; Returns the value of "name='value'" in the <?dbhtml ...> PI
  (let loop ((nl (select-by-class (children component) 'pi)))
    (if (node-list-empty? nl)
	#f
	(let* ((pidata (node-property 'system-data (node-list-first nl)))
	       (pilist (if (and (> (string-length pidata) 7)
				(string=? (substring pidata 0 7) "dbhtml "))
			   (parse-starttag-pi pidata)
			   '()))
	       (value  (if (null? pilist) #f (dbhtml-findvalue pilist name))))
	  (if value
	      value
	      (loop (node-list-rest nl)))))))

(define (inherited-dbhtml-value component name)
  (let loop ((value #f) (nd component))
    (if (or value (node-list-empty? nd))
	value
	(loop (dbhtml-value nd name) (parent nd)))))

;; EOF dbpi.dsl