2 exception Minidom_exception of string;;
4 let option_to_exception v e =
10 class o_mDOMString (str: Minidom.mDOMString) =
12 method get_dom_string = str
13 method get_string = Minidom.string_of_mDOMString str
16 let o_mDOMString_of_string str =
17 new o_mDOMString (Minidom.mDOMString_of_string str)
19 class o_mDOMDoc (doc : Minidom.mDOMDoc) =
21 method get_dom_doc = doc
23 method get_root_node = Minidom.doc_get_root_node doc
24 method add_entity (name : o_mDOMString) =
25 Minidom.doc_add_entity doc (name#get_dom_string)
26 method get_entity (name : o_mDOMString) =
27 Minidom.doc_get_entity doc (name#get_dom_string)
28 method get_predefined_entity (name : o_mDOMString) =
29 Minidom.doc_get_predefined_entity doc (name#get_dom_string)
32 class o_mDOMNode (node : Minidom.mDOMNode) =
34 method get_dom_node = node
36 method is_text = Minidom.node_is_text node
37 method is_element = Minidom.node_is_element node
38 method is_blank = Minidom.node_is_blank node
39 method is_entity_ref = Minidom.node_is_entity_ref node
41 method get_type = Minidom.node_get_type node
44 (option_to_exception (Minidom.node_get_name node) (Minidom_exception "node has no name"))
47 (option_to_exception (Minidom.node_get_ns_uri node) (Minidom_exception "node has no associated namepsace"))
48 method get_attribute (name : o_mDOMString) =
51 (Minidom.node_get_attribute node (name#get_dom_string))
52 (Minidom_exception "attribute not set for this node")
54 method get_attribute_ns (name : o_mDOMString) (uri : o_mDOMString) =
57 (Minidom.node_get_attribute_ns node (name#get_dom_string) (uri#get_dom_string))
58 (Minidom_exception "attribute not set for this node")
62 (option_to_exception (Minidom.node_get_content node) (Minidom_exception "node has no content"))
65 (option_to_exception (Minidom.node_get_parent node) (Minidom_exception "node has no parent"))
66 method get_prev_sibling =
68 (option_to_exception (Minidom.node_get_prev_sibling node) (Minidom_exception "node has no previous sibling"))
69 method get_next_sibling =
71 (option_to_exception (Minidom.node_get_next_sibling node) (Minidom_exception "node has no next sibling"))
72 method get_first_child =
74 (option_to_exception (Minidom.node_get_first_child node) (Minidom_exception "node has no children"))
75 method get_first_attribute =
77 (option_to_exception (Minidom.node_get_first_attribute node) (Minidom_exception "node has no attributes"))
78 method is_first = Minidom.node_is_first node
79 method is_last = Minidom.node_is_last node
81 method get_children = List.map (function x -> new o_mDOMNode x) (Minidom.node_get_children node)
82 method get_attributes = List.map (function x -> new o_mDOMAttr x) (Minidom.node_get_attributes node)
84 and o_mDOMAttr (attr : Minidom.mDOMAttr) =
86 method get_dom_attr = attr
90 (option_to_exception (Minidom.attr_get_name attr) (Minidom_exception "attribute has no name"))
93 (option_to_exception (Minidom.attr_get_ns_uri attr) (Minidom_exception "attribute has no associated namespace"))
96 (option_to_exception (Minidom.attr_get_value attr) (Minidom_exception "attribute has no value"))
98 method get_prev_sibling =
100 (option_to_exception (Minidom.attr_get_prev_sibling attr) (Minidom_exception "attribute has no previous sibling"))
101 method get_next_sibling =
103 (option_to_exception (Minidom.attr_get_next_sibling attr) (Minidom_exception "attribute has no next sibling"))
106 (option_to_exception (Minidom.attr_get_parent attr) (Minidom_exception "attribute has no parent"))