From: Stefano Zacchiroli Date: Wed, 15 Jan 2003 13:22:55 +0000 (+0000) Subject: - added support for default properties X-Git-Tag: v0_3_99~32 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=de8b8a901f012fb57268e71758e3e36aaee919c8;p=helm.git - added support for default properties - actually the only default property is 'method="xml"' --- diff --git a/helm/uwobo/src/ocaml/uwobo_engine.ml b/helm/uwobo/src/ocaml/uwobo_engine.ml index 0bc5afcba..9d5b4670e 100644 --- a/helm/uwobo/src/ocaml/uwobo_engine.ml +++ b/helm/uwobo/src/ocaml/uwobo_engine.ml @@ -37,9 +37,22 @@ let xslNS = Gdome.domString "http://www.w3.org/1999/XSL/Transform" let outputS = Gdome.domString "output" let q_outputS = Gdome.domString "xsl:output" +let default_properties = [ "method", "xml" ] + + (** apply an output property to an xslt stylesheet *) +let apply_property logger (element: Gdome.element) (name, value) = + if Uwobo_common.is_supported_property name then begin + logger#log `Debug (sprintf "Setting property: %s = %s" name value); + element#setAttribute (Gdome.domString name) (Gdome.domString value) + end + else + raise (Unsupported_property name) + (** set a list of output properties in an xslt stylesheet, return a copy of the given stylesheet modified as needed, given stylesheet wont be changed by - this operation *) + this operation. + Before applying "props" properties applies a set of default properties as + defined in "default_properties" *) let apply_properties logger last_stylesheet props = let last_stylesheet = new Gdome.document_of_node (last_stylesheet#cloneNode ~deep:true) @@ -55,17 +68,9 @@ let apply_properties logger last_stylesheet props = elt | Some node -> new Gdome.element_of_node node) in - let apply_property (name, value) = - if Uwobo_common.is_supported_property name then begin - logger#log `Debug (sprintf "Setting property: %s = %s" name value); - output_element#setAttribute - (Gdome.domString name) - (Gdome.domString value) - end - else - raise (Unsupported_property name) - in - List.iter apply_property props; + List.iter + (apply_property logger (output_element :> Gdome.element)) + (default_properties @ props); last_stylesheet (** given a Gdome.document representing an XSLT stylesheet and an output