1 (******************************************************************************)
5 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
8 (* This is the parser that reads the configuration file of helm *)
10 (******************************************************************************)
14 Sys.getenv "HELM_STYLECONFIGURATION_PATH"
17 let xml = "style-configuration.xml" in
18 let tmp_xml = Configuration.tmp_dir ^ "/" ^ xml in
19 let request_xml = Configuration.getter_url ^ "getstyleconf?uri=" ^ xml in
20 ClientHTTP.get_and_save request_xml tmp_xml ;
28 print_endline ("WARNING: " ^ w) ;
29 (raise Warnings : unit)
34 let module Y = Pxp_yacc in
36 let config = {Y.default_config with Y.warner = new warner} in
37 Y.parse_document_entity config (PxpUriResolver.from_file filename) Y.default_spec
40 print_endline (Pxp_types.string_of_exn e) ;
44 exception Impossible;;
46 let styles = Hashtbl.create 13;;
47 let applies = Hashtbl.create 13;;
49 (* we trust the xml file to be valid because of the validating xml parser *)
54 match n#node_type with
55 Pxp_document.T_element "style" ->
58 match n#attribute "key" with
59 Pxp_types.Value s -> s
60 | _ -> raise Impossible
64 Hashtbl.add styles key n#data
65 | Pxp_document.T_element "apply" ->
68 match n#node_type with
69 Pxp_document.T_element "style-ref" ->
71 match n#attribute "key" with
72 Pxp_types.Value s -> s
73 | _ -> raise Impossible
75 | _ -> raise Impossible
80 match n#attribute "name" with
81 Pxp_types.Value s -> s
82 | _ -> raise Impossible
83 in Hashtbl.add applies apply_name keys
84 | _ -> raise Impossible
86 ((xml_document ())#root#sub_nodes)
89 let style_of_key key =
90 Hashtbl.find styles key
92 let key_list_of_mode_name name =
93 Hashtbl.find applies name