xslbench2.cd 1.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
type Play = <PLAY>[
		Title
		Header
		Personae
		<SCNDESCR>String
		<PLAYSUBT>String
		Act+]
type Title = <TITLE> String
type Header = <FM>[(<P>String)*]
type Personae =<PERSONAE>[Title (Persona | Pgroup)+]
type Pgroup = <PGROUP>[Persona Persona+ <GRPDESCR>String]
type Persona = <PERSONA>String
type Act = <ACT>[ Title Scene+ ]
type Scene = <SCENE> [Title (Stagedir | Speech)+]
type Speech = <SPEECH>[<SPEAKER> String (Line |Stagedir)+]
type Stagedir = <STAGEDIR> String
type Line = <LINE> [(Char |Stagedir)+];;

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
include "../../web/xhtml-strict.cd" ;;


let fun xslbench4 (Play -> Xhtml) 
<PLAY>[<TITLE>title; rest] -> 
<html>[
  <head>[<title>title]
  <body>[
     <h1> title
     !transform rest with
         | <FM> x -> [<p>[<i>(transform x with <P> y -> y)]]
         | <PERSONAE>[<TITLE> t ;r] ->
		[
                  <h2>("Parts - "@t)
                 !(transform r with
34
 			| <PERSONA> p -> [<p>[<b>[<i>p]]]
35
			| <PGROUP> x -> transform x with
36
37
38
39
40
41
 			      <PERSONA> p -> [<p>[<b>[<i>p]]])
		]
         | <ACT>[<TITLE> t; rest] -> 
		[
                  <h3>t
                 !(transform rest with
42
 		    <SCENE>[<TITLE> t (spches::Speech|_)+] -> 
43
			[<h3>t 
44
			 !(transform spches with
45
46
47
48
			     <SPEECH>[<SPEAKER>s (lines::<LINE>_|_)*] -> 
                                    [<p>[<b> s 
					 <br>[] 
                                         !transform lines with 
49
50
                                            <LINE>[(str::Char |_ )+] -> 
                          	                     [!str <br>[]]]
51
52
53
				    ]
			  )
			]
54
55
56
57
		 )
                ]
  ]
]
58
59
60


match load_xml "testcases/xslbenchdream.xml" with
61
  | x & Play -> dump_to_file "xslbench2.htm" (print_xml(xslbench4 x))
62
63
64
  | _ -> raise "Ma che c%$#^# di file mi hai passato?";;