8 #define Val_ptr(p) ((value) (p))
9 #define Val_option(p,f) ((p != NULL) ? ml_some(f(p)) : Val_unit)
10 #define Val_mDOMString(s) (copy_string((char*) (s)))
11 #define mDOMString_val(v) ((mDOMStringRef) String_val(v))
17 value ret = alloc_small(1,0);
23 ml_string_of_mDOMString(value s)
30 ml_mDOMString_of_string(value s)
37 ml_doc_load(value file_name)
41 CAMLparam1(file_name);
43 doc_ref = mdom_load(String_val(file_name), FALSE, NULL);
44 if (doc_ref == NULL) failwith("minidom: could not load document");
46 CAMLreturn((value) doc_ref);
50 ml_doc_unload(value doc)
54 mdom_unload((mDOMDocRef) doc);
66 doc_ref = mdom_doc_new(mDOMString_val(s));
67 if (doc_ref == NULL) failwith("minidom: could not create new document");
69 CAMLreturn((value) doc_ref);
74 ml_doc_get_root_node(value doc)
79 root = mdom_doc_get_root_node((mDOMDocRef) doc);
80 if (root == NULL) failwith("minidom: document has no root node!");
82 CAMLreturn((value) root);
86 ml_doc_add_entity(value doc, value name, value content)
90 CAMLparam3(doc, name, content);
91 ent = mdom_doc_add_entity((mDOMDocRef) doc, mDOMString_val(name), mDOMString_val(content));
92 if (ent == NULL) failwith("minidom: could not add entity");
94 CAMLreturn((value) ent);
98 ml_doc_get_entity(value doc, value name)
102 CAMLparam2(doc, name);
103 ent = mdom_doc_get_entity((mDOMDocRef) doc, mDOMString_val(name));
105 CAMLreturn(Val_option(ent, Val_ptr));
109 ml_doc_get_predefined_entity(value name)
114 ent = mdom_get_predefined_entity(mDOMString_val(name));
116 CAMLreturn(Val_option(ent, Val_ptr));
120 ml_entity_get_content(value ent)
123 CAMLreturn(Val_mDOMString(mdom_entity_get_content((mDOMEntityRef) ent)));
127 ml_node_is_text(value node)
130 CAMLreturn(Val_bool(mdom_node_is_text((mDOMNodeRef) node)));
134 ml_node_is_element(value node)
137 CAMLreturn(Val_bool(mdom_node_is_element((mDOMNodeRef) node)));
141 ml_node_is_blank(value node)
144 CAMLreturn(Val_bool(mdom_node_is_blank((mDOMNodeRef) node)));
148 ml_node_is_entity_ref(value node)
151 CAMLreturn(Val_bool(mdom_node_is_entity_ref((mDOMNodeRef) node)));
155 ml_node_get_type(value node)
158 CAMLreturn(Val_int(mdom_node_get_type((mDOMNodeRef) node)));
162 ml_node_get_name(value node)
165 CAMLreturn(Val_option(mdom_node_get_name((mDOMNodeRef) node), Val_mDOMString));
169 ml_node_get_content(value node)
172 CAMLreturn(Val_option(mdom_node_get_content((mDOMNodeRef) node), Val_mDOMString));
176 ml_node_get_ns_uri(value node)
179 CAMLreturn(Val_option(mdom_node_get_ns_uri((mDOMNodeRef) node), Val_mDOMString));
183 ml_node_get_attribute(value node, value name)
185 CAMLparam2(node,name);
186 CAMLreturn(Val_option(mdom_node_get_attribute((mDOMNodeRef) node, String_val(name)), Val_mDOMString));
190 ml_node_get_attribute_ns(value node, value name, value ns_uri)
192 CAMLparam2(node,name);
193 CAMLreturn(Val_option(mdom_node_get_attribute_ns((mDOMNodeRef) node,
195 String_val(ns_uri)), Val_mDOMString));
199 ml_node_get_parent(value node)
202 CAMLreturn(Val_option(mdom_node_get_parent((mDOMNodeRef) node), Val_ptr));
206 ml_node_get_prev_sibling(value node)
209 CAMLreturn(Val_option(mdom_node_get_prev_sibling((mDOMNodeRef) node), Val_ptr));
213 ml_node_get_next_sibling(value node)
216 CAMLreturn(Val_option(mdom_node_get_next_sibling((mDOMNodeRef) node), Val_ptr));
220 ml_node_get_first_child(value node)
223 CAMLreturn(Val_option(mdom_node_get_first_child((mDOMNodeRef) node), Val_ptr));
227 ml_node_get_first_attribute(value node)
230 CAMLreturn(Val_option(mdom_node_get_first_attribute((mDOMNodeRef) node), Val_ptr));
234 ml_node_is_first(value node)
237 CAMLreturn(Val_bool(mdom_node_is_first((mDOMNodeRef) node)));
241 ml_node_is_last(value node)
244 CAMLreturn(Val_bool(mdom_node_is_last((mDOMNodeRef) node)));
248 ml_attr_get_name(value attr)
251 CAMLreturn(Val_option(mdom_attr_get_name((mDOMAttrRef) attr), Val_mDOMString));
255 ml_attr_get_ns_uri(value attr)
258 CAMLreturn(Val_option(mdom_attr_get_ns_uri((mDOMAttrRef) attr), Val_mDOMString));
262 ml_attr_get_value(value attr)
265 CAMLreturn(Val_option(mdom_attr_get_value((mDOMAttrRef) attr), Val_mDOMString));
269 ml_attr_get_prev_sibling(value attr)
272 CAMLreturn(Val_option(mdom_attr_get_prev_sibling((mDOMAttrRef) attr), Val_ptr));
276 ml_attr_get_next_sibling(value attr)
279 CAMLreturn(Val_option(mdom_attr_get_next_sibling((mDOMAttrRef) attr), Val_ptr));
283 ml_attr_get_parent(value attr)
286 CAMLreturn(Val_option(mdom_attr_get_parent((mDOMAttrRef) attr), Val_ptr));