From e6bc9037c2be13c4a154d4120cde19d807c47ffc Mon Sep 17 00:00:00 2001 From: Pascal Brisset Date: Sat, 29 Jul 2006 09:39:39 +0000 Subject: [PATCH] int_attrib --- sw/lib/ocaml/extXml.ml | 7 +++++++ sw/lib/ocaml/extXml.mli | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sw/lib/ocaml/extXml.ml b/sw/lib/ocaml/extXml.ml index 0816b9dcb8..73bf885a2e 100644 --- a/sw/lib/ocaml/extXml.ml +++ b/sw/lib/ocaml/extXml.ml @@ -124,3 +124,10 @@ let float_attrib = fun xml a -> with _ -> failwith (Printf.sprintf "Error: float expected in '%s'" v) +let int_attrib = fun xml a -> + let v = attrib xml a in + try + int_of_string v + with + _ -> failwith (Printf.sprintf "Error: integer expected in '%s'" v) + diff --git a/sw/lib/ocaml/extXml.mli b/sw/lib/ocaml/extXml.mli index 2cab9194a9..ed9d342906 100644 --- a/sw/lib/ocaml/extXml.mli +++ b/sw/lib/ocaml/extXml.mli @@ -38,6 +38,8 @@ val get_attrib : Xml.xml -> string -> string -> string (** [get_attrib xml path attrib_name] *) val attrib : Xml.xml -> string -> string +val int_attrib : Xml.xml -> string -> int +val float_attrib : Xml.xml -> string -> float (** [get xml attribute_name] May raise [Error] *) val tag_is : Xml.xml -> string -> bool @@ -56,5 +58,4 @@ val subst_attrib : string -> string -> Xml.xml -> Xml.xml val subst_child : string -> Xml.xml -> Xml.xml -> Xml.xml (** [subst_child child_tag new_child xml] *) -val float_attrib : Xml.xml -> string -> float