7 #include "ml_minidom.h"
13 value ret = alloc_small(1,0);
19 ml_string_of_mDOMString(value s)
26 ml_mDOMString_of_string(value s)
33 ml_doc_load(value file_name)
37 CAMLparam1(file_name);
39 doc_ref = mdom_load(String_val(file_name), FALSE, NULL);
40 if (doc_ref == NULL) failwith("minidom: could not load document");
42 CAMLreturn((value) doc_ref);
46 ml_doc_unload(value doc)
50 mdom_unload((mDOMDocRef) doc);
62 doc_ref = mdom_doc_new(mDOMString_val(s));
63 if (doc_ref == NULL) failwith("minidom: could not create new document");
65 CAMLreturn((value) doc_ref);
70 ml_doc_get_root_node(value doc)
75 root = mdom_doc_get_root_node((mDOMDocRef) doc);
76 if (root == NULL) failwith("minidom: document has no root node!");
78 CAMLreturn((value) root);
82 ml_doc_add_entity(value doc, value name, value content)
86 CAMLparam3(doc, name, content);
87 ent = mdom_doc_add_entity((mDOMDocRef) doc, mDOMString_val(name), mDOMString_val(content));
88 if (ent == NULL) failwith("minidom: could not add entity");
90 CAMLreturn((value) ent);
94 ml_doc_get_entity(value doc, value name)
98 CAMLparam2(doc, name);
99 ent = mdom_doc_get_entity((mDOMDocRef) doc, mDOMString_val(name));
101 CAMLreturn(Val_option(ent, Val_ptr));
105 ml_doc_get_predefined_entity(value name)
110 ent = mdom_get_predefined_entity(mDOMString_val(name));
112 CAMLreturn(Val_option(ent, Val_ptr));
116 ml_entity_get_content(value ent)
119 CAMLreturn(Val_mDOMString(mdom_entity_get_content((mDOMEntityRef) ent)));
123 ml_node_is_text(value node)
126 CAMLreturn(Val_bool(mdom_node_is_text((mDOMNodeRef) node)));
130 ml_node_is_element(value node)
133 CAMLreturn(Val_bool(mdom_node_is_element((mDOMNodeRef) node)));
137 ml_node_is_blank(value node)
140 CAMLreturn(Val_bool(mdom_node_is_blank((mDOMNodeRef) node)));
144 ml_node_is_entity_ref(value node)
147 CAMLreturn(Val_bool(mdom_node_is_entity_ref((mDOMNodeRef) node)));
151 ml_node_get_type(value node)
154 CAMLreturn(Val_int(mdom_node_get_type((mDOMNodeRef) node)));
158 ml_node_get_name(value node)
161 CAMLreturn(Val_option(mdom_node_get_name((mDOMNodeRef) node), Val_mDOMString));
165 ml_node_get_ns_uri(value node)
168 CAMLreturn(Val_option(mdom_node_get_ns_uri((mDOMNodeRef) node), Val_mDOMString));
172 ml_node_get_attribute(value node, value name)
174 CAMLparam2(node,name);
175 CAMLreturn(Val_option(mdom_node_get_attribute((mDOMNodeRef) node, String_val(name)), Val_mDOMString));
179 ml_node_get_attribute_ns(value node, value name, value ns_uri)
181 CAMLparam2(node,name);
182 CAMLreturn(Val_option(mdom_node_get_attribute_ns((mDOMNodeRef) node,
184 String_val(ns_uri)), Val_mDOMString));
188 ml_node_get_parent(value node)
191 CAMLreturn(Val_option(mdom_node_get_parent((mDOMNodeRef) node), Val_ptr));
195 ml_node_get_prev_sibling(value node)
198 CAMLreturn(Val_option(mdom_node_get_prev_sibling((mDOMNodeRef) node), Val_ptr));
202 ml_node_get_next_sibling(value node)
205 CAMLreturn(Val_option(mdom_node_get_next_sibling((mDOMNodeRef) node), Val_ptr));
209 ml_node_get_first_child(value node)
212 CAMLreturn(Val_option(mdom_node_get_first_child((mDOMNodeRef) node), Val_ptr));
216 ml_node_get_first_attribute(value node)
219 CAMLreturn(Val_option(mdom_node_get_first_attribute((mDOMNodeRef) node), Val_ptr));
223 ml_node_is_first(value node)
226 CAMLreturn(Val_bool(mdom_node_is_first((mDOMNodeRef) node)));
230 ml_node_is_last(value node)
233 CAMLreturn(Val_bool(mdom_node_is_last((mDOMNodeRef) node)));
237 ml_attr_get_name(value attr)
240 CAMLreturn(Val_option(mdom_attr_get_name((mDOMAttrRef) attr), Val_mDOMString));
244 ml_attr_get_ns_uri(value attr)
247 CAMLreturn(Val_option(mdom_attr_get_ns_uri((mDOMAttrRef) attr), Val_mDOMString));
251 ml_attr_get_value(value attr)
254 CAMLreturn(Val_option(mdom_attr_get_value((mDOMAttrRef) attr), Val_mDOMString));
258 ml_attr_get_prev_sibling(value attr)
261 CAMLreturn(Val_option(mdom_attr_get_prev_sibling((mDOMAttrRef) attr), Val_ptr));
265 ml_attr_get_next_sibling(value attr)
268 CAMLreturn(Val_option(mdom_attr_get_next_sibling((mDOMAttrRef) attr), Val_ptr));
272 ml_attr_get_parent(value attr)
275 CAMLreturn(Val_option(mdom_attr_get_parent((mDOMAttrRef) attr), Val_ptr));