X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Fmlminidom%2Ftest.ml;fp=helm%2FDEVEL%2Fmlminidom%2Ftest.ml;h=0000000000000000000000000000000000000000;hb=c7514aaa249a96c5fdd39b1123fbdb38d92f20b6;hp=a906c05527c39dceffd42702e57ce960b570c2a5;hpb=1c7fb836e2af4f2f3d18afd0396701f2094265ff;p=helm.git diff --git a/helm/DEVEL/mlminidom/test.ml b/helm/DEVEL/mlminidom/test.ml deleted file mode 100644 index a906c0552..000000000 --- a/helm/DEVEL/mlminidom/test.ml +++ /dev/null @@ -1,106 +0,0 @@ -(* Copyright (C) 2000, Luca Padovani . - * - * This file is part of mlminidom, the Ocaml binding for minidom. - * - * mlminidom is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * mlminidom is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with mlminidom; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * For details, send a mail to the author. - *) - -let doc = Minidom.doc_load "test.xml" - -let root = Minidom.doc_get_root_node doc - -let check_attribute_ns attr = - Printf.printf "\n\n"; - let ns_uri = Minidom.attr_get_ns_uri attr - and attr_name = Minidom.attr_get_name attr - and attr_value = Minidom.attr_get_value attr - and parent = Minidom.attr_get_parent attr - in - match parent,ns_uri,attr_name,attr_value with - Some parent_node,Some uri,Some attribute_name,Some attribute_value -> - let attr_info = - (Minidom.node_get_attribute_ns parent_node attribute_name uri, - Minidom.node_has_attribute_ns parent_node attribute_name uri) - in begin - match attr_info with - Some attr1, true -> - Printf.printf "found the attribute with ns %s (was %s)\n" - (Minidom.string_of_mDOMString attr1) (Minidom.string_of_mDOMString attribute_value) - | None, false -> - Printf.printf "attribute not found (uri was %s)!!!!\n" (Minidom.string_of_mDOMString uri) - | _,_ -> assert false - end - | _ -> - Printf.printf "parent_node == NULL || uri == NULL || attribute_name == NULL || attribute_value == NULL\n" -;; - -let print_attribute attr = - check_attribute_ns attr; - let ns_uri = Minidom.attr_get_ns_uri attr - in - begin - match ns_uri with - Some uri -> Printf.printf " %s:" (Minidom.string_of_mDOMString uri); - | None -> () - end; - match ((Minidom.attr_get_name attr), (Minidom.attr_get_value attr)) with - (Some attr_name, Some attr_value) -> - Printf.printf " %s=\"%s\"" (Minidom.string_of_mDOMString attr_name) (Minidom.string_of_mDOMString attr_value) - | (Some attr_name, _) -> - Printf.printf " ??? attribute %s has no value !!!" (Minidom.string_of_mDOMString attr_name) - | (_,_) -> - Printf.printf " ??? very strange attribute !!!" -;; - -let rec print_node n node = - if Minidom.node_is_blank node then () - else if Minidom.node_is_element node then begin - match Minidom.node_get_name node with - Some node_name -> - begin - let children = Minidom.node_get_children node - and attributes = Minidom.node_get_attributes node - and ns_uri = Minidom.node_get_ns_uri node - and is_first,is_last = (Minidom.node_is_first node), (Minidom.node_is_last node) - in - for i = 1 to n do print_char ' ' done; - Printf.printf "<"; - begin - match ns_uri with - Some uri -> Printf.printf "%s:" (Minidom.string_of_mDOMString uri) - | None -> () - end; - Printf.printf "%s" (Minidom.string_of_mDOMString node_name); - List.iter print_attribute attributes; - Printf.printf ">\n"; - List.iter (print_node (n + 2)) children; - for i = 1 to n do print_char ' ' done; - Printf.printf "\n" (Minidom.string_of_mDOMString node_name) - end - | None -> Printf.printf "??? this node has no name !!!\n" - end else if Minidom.node_is_text node then begin - match Minidom.node_get_content node with - Some node_content -> - for i = 1 to n do print_char ' ' done; - Printf.printf "%s\n" (Minidom.string_of_mDOMString node_content) - | None -> Printf.printf "??? this node has no content !!!\n" - end else begin - Printf.printf "don't know how to manage a node with type %d\n" (Minidom.node_get_type node) - end -;; - -print_node 0 root;;