|
Packit Service |
4c4772 |
;; $Id: dbqanda.dsl,v 1.1 2003/03/25 19:53:41 adicarlo Exp $
|
|
Packit Service |
4c4772 |
;;
|
|
Packit Service |
4c4772 |
;; This file is part of the Modular DocBook Stylesheet distribution.
|
|
Packit Service |
4c4772 |
;; See ../README or http://docbook.sourceforge.net/projects/dsssl/
|
|
Packit Service |
4c4772 |
;;
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
;; ============================== QANDASET ==============================
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(define (qanda-defaultlabel)
|
|
Packit Service |
4c4772 |
(normalize "number"))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(define (qanda-section-level)
|
|
Packit Service |
4c4772 |
;; FIXME: what if they nest inside each other?
|
|
Packit Service |
4c4772 |
(let* ((enclsect (ancestor-member (current-node)
|
|
Packit Service |
4c4772 |
(list (normalize "section")
|
|
Packit Service |
4c4772 |
(normalize "simplesect")
|
|
Packit Service |
4c4772 |
(normalize "sect5")
|
|
Packit Service |
4c4772 |
(normalize "sect4")
|
|
Packit Service |
4c4772 |
(normalize "sect3")
|
|
Packit Service |
4c4772 |
(normalize "sect2")
|
|
Packit Service |
4c4772 |
(normalize "sect1")
|
|
Packit Service |
4c4772 |
(normalize "refsect3")
|
|
Packit Service |
4c4772 |
(normalize "refsect2")
|
|
Packit Service |
4c4772 |
(normalize "refsect1")))))
|
|
Packit Service |
4c4772 |
(SECTLEVEL enclsect)))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(define (qandadiv-section-level)
|
|
Packit Service |
4c4772 |
(let ((depth (length (hierarchical-number-recursive
|
|
Packit Service |
4c4772 |
(normalize "qandadiv")))))
|
|
Packit Service |
4c4772 |
(+ (qanda-section-level) depth)))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element qandaset
|
|
Packit Service |
4c4772 |
(let ((title (select-elements (children (current-node))
|
|
Packit Service |
4c4772 |
(normalize "title")))
|
|
Packit Service |
4c4772 |
;; process title and rest separately so that we can put the TOC
|
|
Packit Service |
4c4772 |
;; in the rigth place...
|
|
Packit Service |
4c4772 |
(rest (node-list-filter-by-not-gi (children (current-node))
|
|
Packit Service |
4c4772 |
(list (normalize "title")))))
|
|
Packit Service |
4c4772 |
(make element gi: "DIV"
|
|
Packit Service |
4c4772 |
attributes: (list (list "CLASS" (gi)))
|
|
Packit Service |
4c4772 |
(process-node-list title)
|
|
Packit Service |
4c4772 |
(if ($generate-qandaset-toc$)
|
|
Packit Service |
4c4772 |
(process-qanda-toc)
|
|
Packit Service |
4c4772 |
(empty-sosofo))
|
|
Packit Service |
4c4772 |
(process-node-list rest))))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element (qandaset title)
|
|
Packit Service |
4c4772 |
(let* ((htmlgi (string-append "H" (number->string
|
|
Packit Service |
4c4772 |
(+ (qanda-section-level) 1)))))
|
|
Packit Service |
4c4772 |
(make element gi: htmlgi
|
|
Packit Service |
4c4772 |
attributes: (list (list "CLASS" (gi (current-node))))
|
|
Packit Service |
4c4772 |
(process-children))))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element qandadiv
|
|
Packit Service |
4c4772 |
(make element gi: "DIV"
|
|
Packit Service |
4c4772 |
attributes: (list (list "CLASS" (gi)))
|
|
Packit Service |
4c4772 |
(process-children)))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element (qandadiv title)
|
|
Packit Service |
4c4772 |
(let* ((hnr (hierarchical-number-recursive (normalize "qandadiv")
|
|
Packit Service |
4c4772 |
(current-node)))
|
|
Packit Service |
4c4772 |
(number (let loop ((numlist hnr) (number "") (sep ""))
|
|
Packit Service |
4c4772 |
(if (null? numlist)
|
|
Packit Service |
4c4772 |
number
|
|
Packit Service |
4c4772 |
(loop (cdr numlist)
|
|
Packit Service |
4c4772 |
(string-append number
|
|
Packit Service |
4c4772 |
sep
|
|
Packit Service |
4c4772 |
(number->string (car numlist)))
|
|
Packit Service |
4c4772 |
"."))))
|
|
Packit Service |
4c4772 |
(htmlgi (string-append "H" (number->string
|
|
Packit Service |
4c4772 |
(+ (qandadiv-section-level) 1)))))
|
|
Packit Service |
4c4772 |
(make element gi: htmlgi
|
|
Packit Service |
4c4772 |
(make element gi: "A"
|
|
Packit Service |
4c4772 |
attributes: (list (list "NAME" (element-id
|
|
Packit Service |
4c4772 |
(parent (current-node)))))
|
|
Packit Service |
4c4772 |
(empty-sosofo))
|
|
Packit Service |
4c4772 |
(literal number ". ")
|
|
Packit Service |
4c4772 |
(process-children))))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element qandaentry
|
|
Packit Service |
4c4772 |
(make element gi: "DIV"
|
|
Packit Service |
4c4772 |
attributes: (list (list "CLASS" (gi)))
|
|
Packit Service |
4c4772 |
(process-children)))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element question
|
|
Packit Service |
4c4772 |
(let* ((chlist (children (current-node)))
|
|
Packit Service |
4c4772 |
(firstch (node-list-first chlist))
|
|
Packit Service |
4c4772 |
(restch (node-list-rest chlist)))
|
|
Packit Service |
4c4772 |
(make element gi: "DIV"
|
|
Packit Service |
4c4772 |
attributes: (list (list "CLASS" (gi)))
|
|
Packit Service |
4c4772 |
(make element gi: "P"
|
|
Packit Service |
4c4772 |
(make element gi: "A"
|
|
Packit Service |
4c4772 |
attributes: (list (list "NAME" (element-id)))
|
|
Packit Service |
4c4772 |
(empty-sosofo))
|
|
Packit Service |
4c4772 |
(make element gi: "B"
|
|
Packit Service |
4c4772 |
(literal (question-answer-label (current-node)) " "))
|
|
Packit Service |
4c4772 |
(process-node-list (children firstch)))
|
|
Packit Service |
4c4772 |
(process-node-list restch))))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element answer
|
|
Packit Service |
4c4772 |
(let* ((inhlabel (inherited-attribute-string (normalize "defaultlabel")))
|
|
Packit Service |
4c4772 |
(deflabel (if inhlabel inhlabel (qanda-defaultlabel)))
|
|
Packit Service |
4c4772 |
(label (attribute-string (normalize "label")))
|
|
Packit Service |
4c4772 |
(chlist (children (current-node)))
|
|
Packit Service |
4c4772 |
(firstch (node-list-first chlist))
|
|
Packit Service |
4c4772 |
(restch (node-list-rest chlist)))
|
|
Packit Service |
4c4772 |
(make element gi: "DIV"
|
|
Packit Service |
4c4772 |
attributes: (list (list "CLASS" (gi)))
|
|
Packit Service |
4c4772 |
(make element gi: "P"
|
|
Packit Service |
4c4772 |
(make element gi: "B"
|
|
Packit Service |
4c4772 |
(literal (question-answer-label (current-node)) " "))
|
|
Packit Service |
4c4772 |
(process-node-list (children firstch)))
|
|
Packit Service |
4c4772 |
(process-node-list restch))))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
;; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(define (process-qanda-toc #!optional (node (current-node)))
|
|
Packit Service |
4c4772 |
(let* ((divs (node-list-filter-by-gi (children node)
|
|
Packit Service |
4c4772 |
(list (normalize "qandadiv"))))
|
|
Packit Service |
4c4772 |
(entries (node-list-filter-by-gi (children node)
|
|
Packit Service |
4c4772 |
(list (normalize "qandaentry"))))
|
|
Packit Service |
4c4772 |
(inhlabel (inherited-attribute-string (normalize "defaultlabel")))
|
|
Packit Service |
4c4772 |
(deflabel (if inhlabel inhlabel (qanda-defaultlabel))))
|
|
Packit Service |
4c4772 |
(make element gi: "DL"
|
|
Packit Service |
4c4772 |
(with-mode qandatoc
|
|
Packit Service |
4c4772 |
(process-node-list divs))
|
|
Packit Service |
4c4772 |
(with-mode qandatoc
|
|
Packit Service |
4c4772 |
(process-node-list entries)))))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(mode qandatoc
|
|
Packit Service |
4c4772 |
(element qandadiv
|
|
Packit Service |
4c4772 |
(let ((title (select-elements (children (current-node))
|
|
Packit Service |
4c4772 |
(normalize "title"))))
|
|
Packit Service |
4c4772 |
(make sequence
|
|
Packit Service |
4c4772 |
(make element gi: "DT"
|
|
Packit Service |
4c4772 |
(process-node-list title))
|
|
Packit Service |
4c4772 |
(make element gi: "DD"
|
|
Packit Service |
4c4772 |
(process-qanda-toc)))))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element (qandadiv title)
|
|
Packit Service |
4c4772 |
(let* ((hnr (hierarchical-number-recursive (normalize "qandadiv")
|
|
Packit Service |
4c4772 |
(current-node)))
|
|
Packit Service |
4c4772 |
(number (let loop ((numlist hnr) (number "") (sep ""))
|
|
Packit Service |
4c4772 |
(if (null? numlist)
|
|
Packit Service |
4c4772 |
number
|
|
Packit Service |
4c4772 |
(loop (cdr numlist)
|
|
Packit Service |
4c4772 |
(string-append number
|
|
Packit Service |
4c4772 |
sep
|
|
Packit Service |
4c4772 |
(number->string (car numlist)))
|
|
Packit Service |
4c4772 |
".")))))
|
|
Packit Service |
4c4772 |
(make sequence
|
|
Packit Service |
4c4772 |
(literal number ". ")
|
|
Packit Service |
4c4772 |
(make element gi: "A"
|
|
Packit Service |
4c4772 |
attributes: (list (list "HREF"
|
|
Packit Service |
4c4772 |
(href-to (parent (current-node)))))
|
|
Packit Service |
4c4772 |
(process-children)))))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element qandaentry
|
|
Packit Service |
4c4772 |
(process-children))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element question
|
|
Packit Service |
4c4772 |
(let* ((chlist (children (current-node)))
|
|
Packit Service |
4c4772 |
(firstch (node-list-first chlist)))
|
|
Packit Service |
4c4772 |
(make element gi: "DT"
|
|
Packit Service |
4c4772 |
(literal (question-answer-label (current-node)) " ")
|
|
Packit Service |
4c4772 |
(make element gi: "A"
|
|
Packit Service |
4c4772 |
attributes: (list (list "HREF" (href-to (current-node))))
|
|
Packit Service |
4c4772 |
(process-node-list (children firstch))))))
|
|
Packit Service |
4c4772 |
|
|
Packit Service |
4c4772 |
(element answer
|
|
Packit Service |
4c4772 |
(empty-sosofo))
|
|
Packit Service |
4c4772 |
)
|