| 1 |
include "xhtml-strict.cd";; |
include "xhtml-strict.cd";; |
| 2 |
include "xhtml-categ.cd";; |
include "xhtml-categ.cd";; |
| 3 |
|
|
| 4 |
|
type Site = <site>[ <page {|input=String; output=String|}>[]* ];; |
| 5 |
|
|
| 6 |
type Page = <page>[ |
type Page = <page>[ |
| 7 |
<title>String |
<title>String |
| 8 |
<banner>[InlineText*] |
<banner>[InlineText*] |
| 100 |
] |
] |
| 101 |
];; |
];; |
| 102 |
|
|
| 103 |
let page : Page = match load_xml "site.xml" with |
let fun do_page((String,String) -> []) |
| 104 |
|
(inf,outf) -> |
| 105 |
|
let _ = print [ 'Loading ' !inf '... ' ] in |
| 106 |
|
let page = match load_xml inf with |
| 107 |
| Page & p -> p |
| Page & p -> p |
| 108 |
| _ -> raise "Invalid input document";; |
| _ -> raise ("Invalid input document" @ inf) in |
| 109 |
|
let _ = print [ 'Generating html ... ' ] in |
| 110 |
let out : String = |
let html : String = |
| 111 |
[ '<?xml version="1.0" encoding="iso-8859-1"?>' |
[ '<?xml version="1.0" encoding="iso-8859-1"?>' |
| 112 |
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' |
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' |
| 113 |
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' |
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' |
| 114 |
!(print_xml (page2html page)) ];; |
!(print_xml (page2html page)) ] in |
| 115 |
|
let _ = print [ 'Saving to ' !outf '...\n' ] in |
| 116 |
|
dump_to_file outf html;; |
| 117 |
|
|
| 118 |
|
|
| 119 |
dump_to_file "index.html" out;; |
let site = |
| 120 |
|
let _ = print [ 'Loading site.xml ...\n' ] in |
| 121 |
|
match load_xml "site.xml" with |
| 122 |
|
| Site & <site>s -> |
| 123 |
|
(transform s with <page input=inf; output=outf>[] -> |
| 124 |
|
do_page(inf,outf)) |
| 125 |
|
| _ -> raise "Invalid site.xml";; |