source: project/release/5/sxml-transforms/trunk/chicken/sxml-transforms.scm @ 35717

Last change on this file since 35717 was 35717, checked in by felix, 12 months ago

svnwiki-sxml 0.2.12 for C5

File size: 3.0 KB
Line 
1;; $Revision: 1.2 $ $Date: 2005/07/11 23:36:16 $
2
3(module sxml-transforms
4 (
5  ;; SXML-tree-trans.scm -- This does not depend on anything else
6  SRV:send-reply pre-post-order post-order pre-post-order-splice
7  foldts replace-range
8 
9  ;; SXML-to-HTML.scm -- needs make-char-quotator
10  SXML->HTML entag enattr string->goodHTML
11 
12  ;; SXML-to-HTML-ext.scm
13  universal-conversion-rules
14  universal-protected-rules
15  alist-conv-rules
16
17  ;; util.scm
18  make-char-quotator
19
20  ;; chicken/xhtml.scm
21  entag-xhtml
22  entag-html
23
24  ;; Alternatives to work around apply limit
25  pre-post-order* pre-post-order-splice*
26  universal-conversion-rules*
27  universal-protected-rules*
28  alist-conv-rules*
29  )
30
31(import (chicken base) scheme)
32(import (chicken file posix))
33(import (srfi-13))
34 
35(define inc add1)
36(define dec sub1)
37(define nl (string #\newline))  ;; for SXML->HTML
38
39; like cout << arguments << args
40; where argument can be any Scheme object. If it's a procedure
41; (without args) it's executed rather than printed (like newline)
42(define (cout . args)
43  (for-each (lambda (x)
44              (if (procedure? x) (x) (display x)))
45            args))
46
47(define (cerr . args)
48  (for-each (lambda (x)
49              (if (procedure? x) (x (current-error-port)) (display x (current-error-port))))
50            args))
51
52;;; Includes
53
54(include "SSAX/lib/util.scm") ;; for make-char-quotator only
55(include "SSAX/lib/SXML-tree-trans.scm")
56(include "SSAX/lib/lookup-def.scm")
57(include "SSAX/lib/SXML-to-HTML.scm")      ;; Warning: this needs nl at runtime (unless macro)
58
59;; Override the entag in SXML-to-HTML-ext's universal-conversion-rules
60;; to use entag-xhtml, as well as the user's view of entag.
61(define entag-html entag)
62(include "chicken/xhtml.scm")              ;; for entag-xhtml
63(define entag entag-xhtml)
64
65(define OS:file-length file-size)
66(include "SSAX/lib/SXML-to-HTML-ext.scm")  ;; Not trimmed, but non-exported code
67                                           ;; will not be compiled in.
68
69;; Chicken allows a limited number of arguments to procedures using APPLY.
70;; The following file attempts to fix a few of those problems.
71(include "chicken/apply-limit-fixes.scm")
72
73;;; Tack rules on to the universal conversion rules.
74(let* ((handler (lambda (tag elts)
75                  (map (lambda (elt)
76                         (string-append "&" elt ";"))
77                       elts)))
78       ;; (& STR1 ...) : Quotes character references given by strings STR1 ...
79       ;; Conforms to HTMLprag's syntax.  Example:
80       ;; (& "ndash" "quot" ...) => ("&ndash;" "&quot;" ...)
81       (extra-rules*
82        `((& . ,handler)))
83       (extra-rules
84        `((& . ,(lambda (tag . elts) (handler tag elts))))))
85
86  (set! universal-conversion-rules*
87        (append universal-conversion-rules* extra-rules*))
88  (set! universal-protected-rules*
89        (append universal-protected-rules* extra-rules*))
90  (set! universal-conversion-rules
91        (append universal-conversion-rules extra-rules))
92  (set! universal-protected-rules
93        (append universal-protected-rules extra-rules)))
94
95)
Note: See TracBrowser for help on using the repository browser.