Index: ext/libxml/libxml.c =================================================================== RCS file: /repository/php-src/ext/libxml/libxml.c,v retrieving revision 1.35 diff -u -r1.35 libxml.c --- ext/libxml/libxml.c 26 Aug 2005 02:29:32 -0000 1.35 +++ ext/libxml/libxml.c 5 Sep 2005 13:43:07 -0000 @@ -40,6 +40,7 @@ #include #include #include +#include #ifdef LIBXML_SCHEMAS_ENABLED #include #endif @@ -65,9 +66,7 @@ PHP_LIBXML_API php_libxml_globals libxml_globals; #endif -#if LIBXML_VERSION >= 20600 zend_class_entry *libxmlerror_class_entry; -#endif /* {{{ dynamically loadable module stuff */ #ifdef COMPILE_DL_LIBXML @@ -546,9 +545,7 @@ PHP_MINIT_FUNCTION(libxml) { -#if LIBXML_VERSION >= 20600 zend_class_entry ce; -#endif php_libxml_initialize(); @@ -563,7 +560,6 @@ REGISTER_LONG_CONSTANT("LIBXML_VERSION", LIBXML_VERSION, CONST_CS | CONST_PERSISTENT); REGISTER_STRING_CONSTANT("LIBXML_DOTTED_VERSION", LIBXML_DOTTED_VERSION, CONST_CS | CONST_PERSISTENT); -#if LIBXML_VERSION >= 20600 /* For use with loading xml */ REGISTER_LONG_CONSTANT("LIBXML_NOENT", XML_PARSE_NOENT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("LIBXML_DTDLOAD", XML_PARSE_DTDLOAD, CONST_CS | CONST_PERSISTENT); @@ -576,6 +572,11 @@ REGISTER_LONG_CONSTANT("LIBXML_NSCLEAN", XML_PARSE_NSCLEAN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("LIBXML_NOCDATA", XML_PARSE_NOCDATA, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("LIBXML_NONET", XML_PARSE_NONET, CONST_CS | CONST_PERSISTENT); +#if LIBXML_VERSION >= 20621 + REGISTER_LONG_CONSTANT("LIBXML_COMPACT", XML_PARSE_COMPACT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_NOXMLDECL", XML_SAVE_NO_DECL, CONST_CS | CONST_PERSISTENT); +#endif + REGISTER_LONG_CONSTANT("LIBXML_NOEMPTYTAG", LIBXML_SAVE_NOEMPTYTAG, CONST_CS | CONST_PERSISTENT); /* Error levels */ REGISTER_LONG_CONSTANT("LIBXML_ERR_NONE", XML_ERR_NONE, CONST_CS | CONST_PERSISTENT); @@ -585,7 +586,6 @@ INIT_CLASS_ENTRY(ce, "LibXMLError", NULL); libxmlerror_class_entry = zend_register_internal_class(&ce TSRMLS_CC); -#endif return SUCCESS; } @@ -657,7 +657,6 @@ Disable libxml errors and allow user to fetch error information as needed */ PHP_FUNCTION(libxml_use_internal_errors) { -#if LIBXML_VERSION >= 20600 xmlStructuredErrorFunc current_handler; int use_errors=0, retval; @@ -691,16 +690,12 @@ } } RETURN_BOOL(retval); -#else - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Libxml 2.6 or higher is required"); -#endif } /* {{{ proto object libxml_get_last_error() Retrieve last error from libxml */ PHP_FUNCTION(libxml_get_last_error) { -#if LIBXML_VERSION >= 20600 xmlErrorPtr error; error = xmlGetLastError(); @@ -724,9 +719,6 @@ } else { RETURN_FALSE; } -#else - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Libxml 2.6 or higher is required"); -#endif } /* }}} */ @@ -734,7 +726,6 @@ Retrieve array of errors */ PHP_FUNCTION(libxml_get_errors) { -#if LIBXML_VERSION >= 20600 xmlErrorPtr error; @@ -770,9 +761,6 @@ error = zend_llist_get_next(LIBXML(error_list)); } } -#else - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Libxml 2.6 or higher is required"); -#endif } /* }}} */ @@ -780,14 +768,10 @@ Clear last error from libxml */ PHP_FUNCTION(libxml_clear_errors) { -#if LIBXML_VERSION >= 20600 xmlResetLastError(); if (LIBXML(error_list)) { zend_llist_clean(LIBXML(error_list)); } -#else - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Libxml 2.6 or higher is required"); -#endif } /* }}} */ Index: ext/libxml/php_libxml.h =================================================================== RCS file: /repository/php-src/ext/libxml/php_libxml.h,v retrieving revision 1.15 diff -u -r1.15 php_libxml.h --- ext/libxml/php_libxml.h 3 Aug 2005 14:07:23 -0000 1.15 +++ ext/libxml/php_libxml.h 5 Sep 2005 12:39:49 -0000 @@ -35,6 +35,8 @@ #include "ext/standard/php_smart_str.h" #include +#define LIBXML_SAVE_NOEMPTYTAG 1<<2 + typedef struct { zval *stream_context; smart_str error_buffer; Index: ext/dom/document.c =================================================================== RCS file: /repository/php-src/ext/dom/document.c,v retrieving revision 1.70 diff -u -r1.70 document.c --- ext/dom/document.c 15 Aug 2005 17:13:15 -0000 1.70 +++ ext/dom/document.c 5 Sep 2005 12:59:44 -0000 @@ -1624,12 +1624,13 @@ { zval *id; xmlDoc *docp; - int file_len = 0, bytes, format; + int file_len = 0, bytes, format, saveempty; dom_object *intern; dom_doc_props *doc_props; char *file; + long options = 0; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, U_CLASS_ENTRY(dom_document_class_entry), &file, &file_len) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &id, U_CLASS_ENTRY(dom_document_class_entry), &file, &file_len, &options) == FAILURE) { return; } @@ -1644,8 +1645,14 @@ doc_props = dom_get_doc_props(intern->document); format = doc_props->formatoutput; + if (options & LIBXML_SAVE_NOEMPTYTAG) { + saveempty = xmlSaveNoEmptyTags; + xmlSaveNoEmptyTags = 1; + } bytes = xmlSaveFormatFileEnc(file, docp, NULL, format); - + if (options & LIBXML_SAVE_NOEMPTYTAG) { + xmlSaveNoEmptyTags = saveempty; + } if (bytes == -1) { RETURN_FALSE; } @@ -1666,9 +1673,10 @@ xmlChar *mem; dom_object *intern, *nodeobj; dom_doc_props *doc_props; - int size, format; + int size, format, saveempty; + long options = 0; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|O", &id, U_CLASS_ENTRY(dom_document_class_entry), &nodep, U_CLASS_ENTRY(dom_node_class_entry)) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|O!l", &id, U_CLASS_ENTRY(dom_document_class_entry), &nodep, U_CLASS_ENTRY(dom_node_class_entry), &options) == FAILURE) { return; } @@ -1677,6 +1685,11 @@ doc_props = dom_get_doc_props(intern->document); format = doc_props->formatoutput; + if (options & LIBXML_SAVE_NOEMPTYTAG) { + saveempty = xmlSaveNoEmptyTags; + xmlSaveNoEmptyTags = 1; + } + if (nodep != NULL) { /* Dump contents of Node */ DOM_GET_OBJ(node, nodep, xmlNodePtr, nodeobj); @@ -1691,6 +1704,9 @@ } xmlNodeDump(buf, docp, node, 0, format); + if (options & LIBXML_SAVE_NOEMPTYTAG) { + xmlSaveNoEmptyTags = saveempty; + } mem = (xmlChar*) xmlBufferContent(buf); if (!mem) { xmlBufferFree(buf); @@ -1701,6 +1717,9 @@ } else { /* Encoding is handled from the encoding property set on the document */ xmlDocDumpFormatMemory(docp, &mem, &size, format); + if (options & LIBXML_SAVE_NOEMPTYTAG) { + xmlSaveNoEmptyTags = saveempty; + } if (!size) { RETURN_FALSE; }