This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Better anchors for questions
- To: docbook-apps at lists dot oasis-open dot org
- Subject: DOCBOOK-APPS: Better anchors for questions
- From: Nik Clayton <nik at nothing-going-on dot demon dot co dot uk>
- Date: Sat, 28 Oct 2000 21:37:05 +0100
- Organization: Nik at home, where there's nothing going on
Hi guys,
People using Norm's DSSSL stylesheets, and marking up FAQs, might want to
put this function in their stylesheets;
<!-- Override generate-anchor. This is used to generate a unique ID for
each element that can be linked to. The element-id function calls
this one if there's no ID attribute that it can use. Normally, we
would just use the current element number. However, if it's a
a question then use the question's number, as determined by the
question-answer-label function.
This generates anchors of the form "Qx.y.", where x.y is the
question label. This will probably break if question-answer-label
is changed to generate something that might be the same for two
different questions (for example, if question numbering restarts
for each qandaset. -->
(define (generate-anchor #!optional (nd (current-node)))
(cond
((equal? (gi nd) (normalize "question"))
(string-append "Q" (question-answer-label)))
(else
(string-append "AEN" (number->string (all-element-number nd))))))
If you always add new questions to the end of your FAQ (or to the end of
existing sections in the FAQ) then this will generate HREF targets in the
HTML output that are much more stable (i.e., they don't change) than the
existing method of "use the current element number". It should also be easy
to extend to other numbered sections that you want to generate useful anchors
on.
Hope that's useful (and that it finds its way in to the official distribution
:-) ) As ever, much kudos to Norm for all his work.
N
--
Internet connection, $19.95 a month. Computer, $799.95. Modem, $149.95.
Telephone line, $24.95 a month. Software, free. USENET transmission,
hundreds if not thousands of dollars. Thinking before posting, priceless.
Somethings in life you can't buy. For everything else, there's MasterCard.
-- Graham Reed, in the Scary Devil Monastery