Subject: Re: DOCBOOK: Producing HTML from DocBook, without HTML <head> From: Tsyshevsky Vladimir <wowa@xxxxxxxxxx> Date: Thu, 30 Sep 1999 12:07:57 +0400 |
>From: Norman Walsh <ndw@xxxxxxxxxx> > >/ Stephane Bortzmeyer <bortzmeyer@xxxxxxxxxx> was heard to say: >| But I don't wan't HTML HEAD or BODY or META. > >In your custom stylesheet, make a copy of the function (html-document) >from dbhtml.dsl and change the definition of the 'doc-sosofo' variable >to remove the HTML/HEAD/BODY tags. > >That should do it. > Cheers, Hi, here is quite different solution. I use HTML (SGML with slightly modified HTML DTD) templates to do the job. The template is prepared as usual SGML document, so you can use all the HTML nitty-gritty to make page looking as your boss likes. All places, which supposed to contain real information are marked up with special element named DATASITE (term choosed after Sapphire development system). The type of datasites defined by attribute named TYPE. The template is parsed by `sgml-parse' (see `template-root' definition below), and then `printed' by `copy-subtree' procedure. The datasite elements have special treatment: 1. The value of TYPE attribute is used to find the corresponding datasite handler (list of handler names values is provided to `copy-subtree' in `escape-list' argument. 2. If found, handler is analysed. If it is a procedure, it is executed with datasite element and current chunk element as arguments. The procedure supposed to return sosofo. If the handler is not a procedure, then it is supposed to be sosofo, and its value simply returned 3. If no handler found, and datasite element has attribute named DEFAULT, then the datasite contents is printed. The datasites can be nested, allowing the complex algorythms such as: 1. my data element may have multiple values; 2. two datasites used to deal with this data; 3. if no values found, then I want to emit the content of first datasite (for example, the message for the user or transparent GIF image to prevent empty HTML table cell "collapse"); 4. if some values found, I want to use second's datasite contents, which is the HTML table template, which has datasite for single table row somethere inside. `copy-subtree' is used again with handler for "table row" datasite, which invokes `copy-subtree' whth handlers for each column cell and so on... This approach is used in "Jetinfo online" project <http://www.jetinfo.com/>, the online version of printed magazine. Below is excerpt from style used to generate the article pages (for example, <http://www.jetinfo.com/1999/1/1/article1.1.1999.html>. The navigation pages (including frontpage) are generated on the fly, using same approach, but this time, from XML templates, prepared with `sx' utility, since reading SGML in runtime requires too much of computer resources. The SGML template used by program below can be found at <http://www.jetinfo.com/templates/>. Feel free to ask questions. Regards, Vladimir V. Tsychevski senior expert ----------------------------------------------------- Jet Infosystems Krasnoproletarskaya 6, Tel. (+7 095) 972-1182 Moscow 103006, Russia Fax (+7 095) 972-0791 ----------------------------------------------------- Any opinions or recommendations herein are those of the author and not of his computer. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define(copy-subtree nl #!optional origin(escape-list '())) (let loop((nl nl)) (map-constructor (lambda (snl) (case(node-property 'class-name snl) ((element) (let((giv(gi snl))) (if(string=? giv "DATASITE") (let((ass(member(attribute-string "TYPE" snl)escape-list))) (if ass (let((replacement(car(cdr ass)))) (cond((string? replacement) (literal replacement)) ((procedure? replacement) (replacement nl origin)) (else replacement))) (if(attribute-string "DEFAULT"snl) (loop(children snl)) (empty-sosofo)))) (let((attrs(copy-attributes snl))) (if(node-property 'must-omit-end-tag? snl) (make empty-element gi: giv attributes: attrs) (make element gi: giv attributes: attrs (loop(children snl)))))))) ((data-char) (literal(data snl))) ((sdata) (literal(data snl))))) nl))) (define(anchor snl datasite-elt) (let((template(children datasite-elt))) (if(or(node-list-empty? snl)(node-list=? snl(current-node))) (if(attribute-string "DEFAULT" (node-list-first datasite-elt)) (copy-subtree template snl) (empty-sosofo)) (make element gi: "a" attributes: `(("href" ,(href-to snl))) (if(node-list-empty? template) (element-title-sosofo snl) (copy-subtree template snl)))))) (define(server-root node) (or(pi-value node "serverroot" #t) (error "No value for 'serverroot' PI given"))) (define(template-root node) (let((sysid(string-append (server-root node) "/templates/" (or(pi-value(current-node)"template" #t) "index.html")))) (node-property 'document-element (sgml-parse sysid)))) (define (component-html-base nd) (let((ids(and %use-id-as-filename% (attribute-string (normalize "id") nd)))) (if ids (case-fold-down ids) (let((base(component-html-base (parent nd)))) (if (chunk? nd) (string-append base (number->string (all-element-number nd))) base))))) (define(chunk-no root snl) (let loop((n 0)(candidate root)) (let((dum(node-debug candidate "candidate"))) (cond((node-list-empty? candidate) (error (string-append"chunk-no: not a base"(gi root)(gi snl)))) ((node-list=? candidate snl) n) (else (loop(+ n 1)(next-chunk-element candidate))))))) (define (html-document title-sosofo body-sosofo) (let*((node(current-node)) (doc-sosofo (if(or(chunk?)(node-list=? node(sgml-root-element))) (copy-subtree (template-root node) node (list "TITLE" title-sosofo "TITLE-IMAGE" (make empty-element gi: "img" attributes: `(("border" "0") ("src" ,(or(pi-value node "title-image" #t) "/pics/menu71.gif")))) "BODY" body-sosofo "PREV" (lambda(tmpl-elt elt) (anchor(prev-chunk-element elt)tmpl-elt)) "NEXT" (lambda(tmpl-elt elt) (anchor(next-chunk-element elt)tmpl-elt)) "UP" (lambda(tmpl-elt elt) (anchor(nav-home elt)tmpl-elt)))) body-sosofo))) (if (chunk?) (make entity system-id: (html-file)doc-sosofo) doc-sosofo))) DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: DOCBOOK: Producing HTML from Do, Norman Walsh | Thread | How can I take the ID for the curre, Reyes Garcia Rosado |
SOLUTION FOR : How can I add a new , Reyes Garcia Rosado | Date | RE: SOLUTION FOR : How can I add a , Frank A. Christoph |
Month |