+++ /dev/null
-
-exception Minidom_exception of string;;
-
-let option_to_exception v e =
- match (v) with
- Some x -> x
- | None -> raise e
-;;
-
-class o_mDOMString (str: Minidom.mDOMString) =
- object
- method get_dom_string = str
- method get_string = Minidom.string_of_mDOMString str
- end;;
-
-let o_mDOMString_of_string str =
- new o_mDOMString (Minidom.mDOMString_of_string str)
-
-class o_mDOMDoc (doc : Minidom.mDOMDoc) =
- object
- method get_dom_doc = doc
-
- method get_root_node = Minidom.doc_get_root_node doc
- method add_entity (name : o_mDOMString) =
- Minidom.doc_add_entity doc (name#get_dom_string)
- method get_entity (name : o_mDOMString) =
- Minidom.doc_get_entity doc (name#get_dom_string)
- method get_predefined_entity (name : o_mDOMString) =
- Minidom.doc_get_predefined_entity doc (name#get_dom_string)
- end;;
-
-class o_mDOMNode (node : Minidom.mDOMNode) =
- object
- method get_dom_node = node
-
- method is_text = Minidom.node_is_text node
- method is_element = Minidom.node_is_element node
- method is_blank = Minidom.node_is_blank node
- method is_entity_ref = Minidom.node_is_entity_ref node
-
- method get_type = Minidom.node_get_type node
- method get_name =
- new o_mDOMString
- (option_to_exception (Minidom.node_get_name node) (Minidom_exception "node has no name"))
- method get_ns_uri =
- new o_mDOMString
- (option_to_exception (Minidom.node_get_ns_uri node) (Minidom_exception "node has no associated namepsace"))
- method get_attribute (name : o_mDOMString) =
- new o_mDOMString
- (option_to_exception
- (Minidom.node_get_attribute node (name#get_dom_string))
- (Minidom_exception "attribute not set for this node")
- )
- method get_attribute_ns (name : o_mDOMString) (uri : o_mDOMString) =
- new o_mDOMString
- (option_to_exception
- (Minidom.node_get_attribute_ns node (name#get_dom_string) (uri#get_dom_string))
- (Minidom_exception "attribute not set for this node")
- )
- method get_content =
- new o_mDOMString
- (option_to_exception (Minidom.node_get_content node) (Minidom_exception "node has no content"))
- method get_parent =
- new o_mDOMNode
- (option_to_exception (Minidom.node_get_parent node) (Minidom_exception "node has no parent"))
- method get_prev_sibling =
- new o_mDOMNode
- (option_to_exception (Minidom.node_get_prev_sibling node) (Minidom_exception "node has no previous sibling"))
- method get_next_sibling =
- new o_mDOMNode
- (option_to_exception (Minidom.node_get_next_sibling node) (Minidom_exception "node has no next sibling"))
- method get_first_child =
- new o_mDOMNode
- (option_to_exception (Minidom.node_get_first_child node) (Minidom_exception "node has no children"))
- method get_first_attribute =
- new o_mDOMAttr
- (option_to_exception (Minidom.node_get_first_attribute node) (Minidom_exception "node has no attributes"))
- method is_first = Minidom.node_is_first node
- method is_last = Minidom.node_is_last node
-
- method get_children = List.map (function x -> new o_mDOMNode x) (Minidom.node_get_children node)
- method get_attributes = List.map (function x -> new o_mDOMAttr x) (Minidom.node_get_attributes node)
- end
-and o_mDOMAttr (attr : Minidom.mDOMAttr) =
- object
- method get_dom_attr = attr
-
- method get_name =
- new o_mDOMString
- (option_to_exception (Minidom.attr_get_name attr) (Minidom_exception "attribute has no name"))
- method get_ns_uri =
- new o_mDOMString
- (option_to_exception (Minidom.attr_get_ns_uri attr) (Minidom_exception "attribute has no associated namespace"))
- method get_value =
- new o_mDOMString
- (option_to_exception (Minidom.attr_get_value attr) (Minidom_exception "attribute has no value"))
-
- method get_prev_sibling =
- new o_mDOMAttr
- (option_to_exception (Minidom.attr_get_prev_sibling attr) (Minidom_exception "attribute has no previous sibling"))
- method get_next_sibling =
- new o_mDOMAttr
- (option_to_exception (Minidom.attr_get_next_sibling attr) (Minidom_exception "attribute has no next sibling"))
- method get_parent =
- new o_mDOMNode
- (option_to_exception (Minidom.attr_get_parent attr) (Minidom_exception "attribute has no parent"))
- end
-;;
-