[PHP-CVS] cvs: php4 /ext/domxml php_domxml.c php_domxml.h
steinm Tue Mar 20 07:01:14 2001 EDT Modified files: /php4/ext/domxmlphp_domxml.c php_domxml.h Log: - complete rewrite of domxml module. It is now mostly conform to DOM Level 2 though some classes and methods are still missing Index: php4/ext/domxml/php_domxml.c diff -u php4/ext/domxml/php_domxml.c:1.28 php4/ext/domxml/php_domxml.c:1.29 --- php4/ext/domxml/php_domxml.c:1.28 Sun Feb 25 22:06:53 2001 +++ php4/ext/domxml/php_domxml.cTue Mar 20 07:01:13 2001 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_domxml.c,v 1.28 2001/02/26 06:06:53 andi Exp $ */ +/* $Id: php_domxml.c,v 1.29 2001/03/20 15:01:13 steinm Exp $ */ #include "php.h" @@ -24,33 +24,46 @@ #if HAVE_DOMXML #include "ext/standard/info.h" -/*#define newcode*/ #define PHP_XPATH 1 #define PHP_XPTR 2 static int le_domxmldocp; +static int le_domxmldoctypep; static int le_domxmldtdp; static int le_domxmlnodep; +static int le_domxmlelementp; static int le_domxmlattrp; -/* static int le_domxmlnsp; */ +static int le_domxmlcdatap; +static int le_domxmltextp; +static int le_domxmlpip; +static int le_domxmlcommentp; +static int le_domxmlentityp; +static int le_domxmlnsp; #if defined(LIBXML_XPATH_ENABLED) static int le_xpathctxp; static int le_xpathobjectp; -static zend_class_entry *xpathctx_class_entry_ptr; -static zend_class_entry *xpathobject_class_entry_ptr; #endif -static zend_class_entry *domxmldoc_class_entry_ptr; -static zend_class_entry *domxmldtd_class_entry_ptr; -static zend_class_entry *domxmlnode_class_entry_ptr; -static zend_class_entry *domxmlattr_class_entry_ptr; -static zend_class_entry *domxmlns_class_entry_ptr; - -#ifdef newcode -static zend_class_entry *domxmltestnode_class_entry_ptr; +zend_class_entry *domxmldoc_class_entry; +zend_class_entry *domxmldoctype_class_entry; +zend_class_entry *domxmlelement_class_entry; +zend_class_entry *domxmldtd_class_entry; +zend_class_entry *domxmlnode_class_entry; +zend_class_entry *domxmlattr_class_entry; +zend_class_entry *domxmlcdata_class_entry; +zend_class_entry *domxmltext_class_entry; +zend_class_entry *domxmlpi_class_entry; +zend_class_entry *domxmlcomment_class_entry; +zend_class_entry *domxmlnotation_class_entry; +zend_class_entry *domxmlentity_class_entry; +zend_class_entry *domxmlns_class_entry; +#if defined(LIBXML_XPATH_ENABLED) +zend_class_entry *xpathctx_class_entry; +zend_class_entry *xpathobject_class_entry; #endif + static int node_attributes(zval **attributes, xmlNode *nodep); static int node_children(zval **children, xmlNode *nodep); @@ -58,19 +71,26 @@ PHP_FE(xmldoc, NULL) PHP_FE(xmldocfile, NULL) PHP_FE(xmltree, NULL) - PHP_FE(domxml_root, NULL) + PHP_FALIAS(domxml_root, domxml_doc_document_element, NULL) PHP_FE(domxml_add_root, NULL) PHP_FE(domxml_dumpmem, NULL) - PHP_FE(domxml_attributes, NULL) - PHP_FE(domxml_get_attribute,NULL) - PHP_FALIAS(domxml_getattr, domxml_get_attribute, NULL) - PHP_FE(domxml_set_attribute,NULL) - PHP_FALIAS(domxml_setattr, domxml_set_attribute, NULL) - PHP_FE(domxml_children, NULL) - PHP_FE(domxml_new_child,NULL) + PHP_FE(domxml_node_attributes, NULL) + PHP_FALIAS(domxml_attributes, domxml_node_attributes, NULL) + PHP_FE(domxml_elem_get_attribute, NULL) + PHP_FALIAS(domxml_get_attribute,domxml_elem_get_attribute, NULL) + PHP_FALIAS(domxml_getattr, domxml_elem_get_attribute, NULL) + PHP_FE(domxml_elem_set_attribute, NULL) + PHP_FALIAS(domxml_set_attribute,domxml_elem_set_attribute, NULL) + PHP_FALIAS(domxml_setattr, domxml_elem_set_attribute, NULL) + PHP_FE(domxml_node_children,NULL) + PHP_FALIAS(domxml_children, domxml_node_children, NULL) + PHP_FE(domxml_node_new_child, NULL) + PHP_FALIAS(domxml_new_child,domxml_node_new_child, NULL) PHP_FE(domxml_node, NULL) - PHP_FE(domxml_unlink_node, NULL) - PHP_FE(domxml_set_content, NULL) + PHP_FE(domxml_node_unlink_node, NULL) + PHP_FALIAS(domxml_unlink_node, domxml_node_unlink_node, NULL) + PHP_FE(domxml_node_set_content, NULL) + PHP_FALIAS(set_content, domxml_node_set_content,NULL) PHP_FE(domxml_new_xmldoc, NULL) PHP_FALIAS(new_xmldoc, domxml_new_xmldoc, NULL) #if defined(LIBXML_XPATH_ENABLED) @@ -86,41 +106,151 @@ }; -static zend_function_entry php_domxmldoc_class_functions[] = { - PHP_FALIAS(root,domxml_root,NULL) - PHP_FALIAS(children,domxml_children,NULL) +static function_entry php_domxmldoc_class_functions[] = { +// PHP_FALIAS(domdocument, xmldoc, NULL) + {"domdocument", PHP_FN(xmldoc), NULL}, + PHP_FALIAS(doctype, domxml_doc_doctype,
[PHP-CVS] cvs: php4 /ext/domxml php_domxml.c php_domxml.h
steinm Tue Mar 20 21:45:41 2001 EDT Modified files: /php4/ext/domxmlphp_domxml.c php_domxml.h Log: - added EntityReference and Notation class - fixed handling of PI nodes - implemented more class functions Index: php4/ext/domxml/php_domxml.c diff -u php4/ext/domxml/php_domxml.c:1.31 php4/ext/domxml/php_domxml.c:1.32 --- php4/ext/domxml/php_domxml.c:1.31 Tue Mar 20 09:04:45 2001 +++ php4/ext/domxml/php_domxml.cTue Mar 20 21:45:40 2001 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_domxml.c,v 1.31 2001/03/20 17:04:45 sbergmann Exp $ */ +/* $Id: php_domxml.c,v 1.32 2001/03/21 05:45:40 steinm Exp $ */ #include "php.h" @@ -37,7 +37,9 @@ static int le_domxmltextp; static int le_domxmlpip; static int le_domxmlcommentp; +static int le_domxmlnotationp; static int le_domxmlentityp; +static int le_domxmlentityrefp; static int le_domxmlnsp; #if defined(LIBXML_XPATH_ENABLED) @@ -57,6 +59,7 @@ zend_class_entry *domxmlcomment_class_entry; zend_class_entry *domxmlnotation_class_entry; zend_class_entry *domxmlentity_class_entry; +zend_class_entry *domxmlentityref_class_entry; zend_class_entry *domxmlns_class_entry; #if defined(LIBXML_XPATH_ENABLED) zend_class_entry *xpathctx_class_entry; @@ -126,6 +129,8 @@ PHP_FALIAS(create_processing_instruction, domxml_doc_create_processing_instruction, NULL) PHP_FALIAS(children,domxml_node_children, NULL) PHP_FALIAS(add_root,domxml_add_root,NULL) + PHP_FALIAS(importednode,domxml_doc_imported_node, NULL) + PHP_FALIAS(imported_node, domxml_doc_imported_node, NULL) PHP_FALIAS(dtd, domxml_intdtd, NULL) PHP_FALIAS(dumpmem, domxml_dumpmem, NULL) /* PHP_FALIAS(createcdatasection, domxml_create_cdata_section,NULL) @@ -228,11 +233,15 @@ }; static zend_function_entry php_domxmlnotation_class_functions[] = { -/* PHP_FALIAS(publicid,domxml_notation_public_id, NULL) + PHP_FALIAS(publicid,domxml_notation_public_id, NULL) PHP_FALIAS(public_id, domxml_notation_public_id, NULL) PHP_FALIAS(systemid,domxml_notation_system_id, NULL) PHP_FALIAS(system_id, domxml_notation_system_id, NULL) -*/ {NULL, NULL, NULL} + {NULL, NULL, NULL} +}; + +static zend_function_entry php_domxmlentityref_class_functions[] = { + {NULL, NULL, NULL} }; static zend_function_entry php_domxmlentity_class_functions[] = { @@ -480,9 +489,9 @@ } obj = zend_list_find(Z_LVAL_PP(handle), type); // The following test should be replaced with search in all parents -// if (!obj || ((type != rsrc_type1) (type != rsrc_type2))) { -// php_error(E_ERROR, "Underlying object missing or of invalid type"); -// } + if (!obj) { // || ((type != rsrc_type1) (type != rsrc_type2))) { + php_error(E_ERROR, "Underlying object missing or of invalid type"); + } return obj; } @@ -567,7 +576,26 @@ add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1); break; } - case XML_ENTITY_REF_NODE: + case XML_PI_NODE: { + xmlNodePtr nodep = obj; + object_init_ex(wrapper, domxmlpi_class_entry); + rsrc_type = le_domxmlpip; + content = xmlNodeGetContent(nodep); + add_property_stringl(wrapper, "target", (char *) nodep-name, +strlen(nodep-name), 1); + if(content) + add_property_stringl(wrapper, "data", (char *) +content, strlen(content), 1); + break; + } + case XML_ENTITY_REF_NODE: { + xmlNodePtr nodep = obj; + object_init_ex(wrapper, domxmlentityref_class_entry); + rsrc_type = le_domxmlentityrefp; + content = xmlNodeGetContent(nodep); + add_property_stringl(wrapper, "name", (char *) nodep-name, +strlen(nodep-name), 1); + if(content) + add_property_stringl(wrapper, "content", (char *) +content, strlen(content), 1); + break; + } case XML_ENTITY_DECL: case XML_ELEMENT_DECL: { xmlNodePtr nodep = obj; @@ -634,67 +662,6 @@ return(wrapper); } -/* The following has been taken form the gnome gdome module */ -/* This is a separate implementation that avoids the roundtrip entity - encoding/decoding of the current (2000-01-06) gnome-xml - implementation, largely because that depends on node != NULL, which -
[PHP-CVS] cvs: php4 /ext/domxml php_domxml.c php_domxml.h
steinm Thu Feb 8 07:12:16 2001 EDT Modified files: /php4/ext/domxmlphp_domxml.c php_domxml.h Log: - add domxml_unlink_node(), not tested Index: php4/ext/domxml/php_domxml.c diff -u php4/ext/domxml/php_domxml.c:1.26 php4/ext/domxml/php_domxml.c:1.27 --- php4/ext/domxml/php_domxml.c:1.26 Fri Jan 26 00:15:57 2001 +++ php4/ext/domxml/php_domxml.cThu Feb 8 07:12:16 2001 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_domxml.c,v 1.26 2001/01/26 08:15:57 steinm Exp $ */ +/* $Id: php_domxml.c,v 1.27 2001/02/08 15:12:16 steinm Exp $ */ #include "php.h" @@ -69,6 +69,7 @@ PHP_FE(domxml_children, NULL) PHP_FE(domxml_new_child,NULL) PHP_FE(domxml_node, NULL) + PHP_FE(domxml_unlink_node, NULL) PHP_FE(domxml_set_content, NULL) PHP_FE(domxml_new_xmldoc, NULL) PHP_FALIAS(new_xmldoc, domxml_new_xmldoc, NULL) @@ -115,12 +116,15 @@ PHP_FALIAS(set_attribute, domxml_set_attribute, NULL) PHP_FALIAS(attributes, domxml_attributes, NULL) PHP_FALIAS(node,domxml_node,NULL) + PHP_FALIAS(unlink, domxml_unlink_node, NULL) PHP_FALIAS(set_content, domxml_set_content, NULL) {NULL, NULL, NULL} }; #if defined(LIBXML_XPATH_ENABLED) static zend_function_entry php_xpathctx_class_functions[] = { + PHP_FALIAS(xpath_eval, xpath_eval, NULL) + PHP_FALIAS(xpath_eval_expression, xpath_eval_expression, NULL) {NULL, NULL, NULL} }; @@ -699,6 +703,40 @@ zend_hash_next_index_insert(return_value-value.ht, child, sizeof(zval *), NULL); last = last-next; } +} +/* }}} */ + +/* {{{ proto object domxml_unlink_node([int node]) + Deletes node */ +PHP_FUNCTION(domxml_unlink_node) +{ + zval *id, **tmp; + xmlNode *nodep, *last; + int ret; + + if (ZEND_NUM_ARGS() == 0) { + id = getThis(); + if (id) { + if (zend_hash_find(id-value.obj.properties, "node", +sizeof("node"), (void **)tmp) == FAILURE) { + php_error(E_WARNING, "unable to find my handle +property"); + RETURN_FALSE; + } + ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", +le_domxmlnodep) + } else { + RETURN_FALSE; + } + } else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, id) == FAILURE) { + WRONG_PARAM_COUNT; + } else { + if (zend_hash_find(id-value.obj.properties, "node", sizeof("node"), +(void **)tmp) == FAILURE) { + php_error(E_WARNING, "unable to find my handle property"); + RETURN_FALSE; + } + ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep) + } + + xmlUnlinkNode(nodep); + RETURN_TRUE; } /* }}} */ Index: php4/ext/domxml/php_domxml.h diff -u php4/ext/domxml/php_domxml.h:1.20 php4/ext/domxml/php_domxml.h:1.21 --- php4/ext/domxml/php_domxml.h:1.20 Fri Jan 26 00:15:57 2001 +++ php4/ext/domxml/php_domxml.hThu Feb 8 07:12:16 2001 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_domxml.h,v 1.20 2001/01/26 08:15:57 steinm Exp $ */ +/* $Id: php_domxml.h,v 1.21 2001/02/08 15:12:16 steinm Exp $ */ #ifndef PHP_DOMXML_H #define PHP_DOMXML_H @@ -55,6 +55,7 @@ PHP_FUNCTION(domxml_last_child); PHP_FUNCTION(domxml_parent); PHP_FUNCTION(domxml_node); +PHP_FUNCTION(domxml_unlink_node); PHP_FUNCTION(domxml_new_child); PHP_FUNCTION(domxml_set_content); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]