; A simple example of XSLT-like 'apply-templates' form. ; For more advanced and real-life examples, see Kirill Lisovsky's STX. ; ; IMPORT ; The following is a Bigloo-specific module declaration. ; Other Scheme systems have something similar. ; (module apply-templates-simple ; (include "myenv-bigloo.scm") ; (include "srfi-13-local.scm") ; or import from SRFI-13 if available ; (include "char-encoding.scm") ; (include "util.scm") ; (include "look-for-str.scm") ; (include "input-parse.scm") ; (include "SSAX-code.scm") ; (include "SXML-tree-trans.scm") ; (include "SXML-to-HTML.scm") ; (include "SXPath-old.scm") ; ) ; ; $Id: apply-templates.scm,v 1.3 2003/04/09 21:27:52 oleg Exp $ ; Running examples: SXML data structures (define tree1 '(html (head (title "Slides")) (body (p (@ (align "center")) (table (@ (style "font-size: x-large")) (tr (td (@ (align "right")) "Talks ") (td (@ (align "center")) " = ") (td " slides + transition")) (tr (td) (td (@ (align "center")) " = ") (td " data + control")) (tr (td) (td (@ (align "center")) " = ") (td " programs")))) (ul (li (a (@ (href "slides/slide0001.gif")) "Introduction")) (li (a (@ (href "slides/slide0010.gif")) "Summary"))) ))) (define tree2 '(Forecasts (@ (TStamp "958082142")) (TAF (@ (TStamp "958066200") (LatLon "36.583, -121.850") (BId "724915") (SName "KMRY, MONTEREY PENINSULA")) (VALID (@ (TRange "958068000, 958154400")) "111730Z 111818") (PERIOD (@ (TRange "958068000, 958078800")) (PREVAILING "31010KT P6SM FEW030")) (PERIOD (@ (TRange "958078800, 958104000") (Title "FM2100")) (PREVAILING "29016KT P6SM FEW040")) (PERIOD (@ (TRange "958104000, 958154400") (Title "FM0400")) (PREVAILING "29010KT P6SM SCT200") (VAR (@ (Title "BECMG 0708") (TRange "958114800, 958118400")) "VRB05KT")) ))) ; Pre-order traversal of a tree and creation of a new tree: ; apply-templates:: tree x -> ; where ; ::= (