Commit 665ee09d authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-02-05 19:02:10 by cvscast] Added a new example on publishing a book

Original author: cvscast
Date: 2003-02-05 19:02:10+00:00
parent e880230b
(* An approximation of HTML *)
type Flow = Char | Block | Inline | Misc;;
type Block = P | Heading | Div | Lists | Table | Blocktext;;
type Lists = Ul;;
type Blocktext = Pre | Hr | Blockquote | Address;;
type Inline = Char | A | Special | Fontstyle | Phrase;;
type Fontstyle = Tt | I | B | Big | Small;;
type Phrase = Em | Strong | Code;;
type Special = Br;;
type Misc = Empty;;
type Html = <html>[ Head Body ];;
type Head = <head>[ Title ];;
type Title = <title>[ PCDATA ];;
type Body = <body bgcolor=String>[ Block* ];;
type Div = <div>[ Flow* ];;
type P = <p>[ Inline* ];;
type Heading = <(`h1 | `h2)>[ Inline* ];;
type Ul = <ul>[Li+];;
type Li = <li>[ Flow* ];;
type Address = <address>[ Inline* ];;
type Hr = <hr>[];;
type Pre = <pre>[ (PCDATA | A | Fontstyle | Phrase | Br)* ];;
type Blockquote = <blockquote>[ Block* ];;
type A = <a ({ name = String } | { href = String })>[ (Inline \ A)* ];;
type Br = <br>[];;
type Em = <em>[ Inline* ];;
type Code = <code>[ Inline* ];;
type Strong = <strong>[ Inline* ];;
type Tt = <tt>[ Inline* ];;
type I = <i>[ Inline* ];;
type B = <b>[ Inline* ];;
type Big = <big>[ Inline* ];;
type Small = <small>[ Inline* ];;
type Table = <table border=?String; bgcolor=String; width=String>
[ <tr>[ <td>[ Flow* ]+ ]+ ];;
(* The type of the documents *)
type Book = <book>[ Title Author Chapter+ ];;
type Title = <title>String;;
type Author = <author>[ Name Address Salary ];;
type Name = <name> String;;
type Address = <address> String;;
type Salary = <name> Int;;
type Chapter = <chapter title=String>[Section+];;
type Section = <section title=String>[(Content | Subsection)+];;
type Content = Char | Image | Formula | Outline;;
type Image = <img src=String; style=String; size=String >[ ];;
type Formula = <math>[ Expr* ];;
type Expr = <mi>String
| <mo>String
| <mfrac>[Expr Expr];;
type Subsection = <subs title=String>[Content+];;
type Outline = <outline>[(Char | Formula)+];;
let src =
match [ (load_xml "livre.xml") ] with
| XML & x -> x
| _ -> raise ("Invalid input ...");;
let out : String =
[ '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" [
<!ENTITY mathml "http://www.w3.org/1998/Math/MathML">
]>']
@
(transform convert src with
x -> print_xml x);;
dump_to_file "index.xml" out;;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment