From 1f57dec2bf33a6c1a77edc28b6cb94a9381c171a Mon Sep 17 00:00:00 2001 From: Christian Stocker Date: Thu, 22 Aug 2002 15:02:41 +0000 Subject: [PATCH] @- Added XsltObject->dump_mem($result) for returning xslt-result directly @ into a string (morus.walter@web.de, chregu) - XsltObject->dump_file() will follow - bumped up needed libxslt version to 1.0.18 --- ext/domxml/config.m4 | 10 +++++----- ext/domxml/php_domxml.c | 41 ++++++++++++++++++++++++++++++++++++++++- ext/domxml/php_domxml.h | 1 + 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/ext/domxml/config.m4 b/ext/domxml/config.m4 index 3b5c8e88be..ce23137c8c 100644 --- a/ext/domxml/config.m4 +++ b/ext/domxml/config.m4 @@ -79,13 +79,13 @@ AC_DEFUN(PHP_DOM_XSLT_CHECK_VERSION,[ AC_MSG_CHECKING(for libxslt version) AC_EGREP_CPP(yes,[ #include -#if LIBXSLT_VERSION >= 10003 +#if LIBXSLT_VERSION >= 10018 yes #endif ],[ - AC_MSG_RESULT(>= 1.0.3) + AC_MSG_RESULT(>= 1.0.18) ],[ - AC_MSG_ERROR(libxslt version 1.0.3 or greater required.) + AC_MSG_ERROR(libxslt version 1.0.18 or greater required.) ]) CPPFLAGS=$old_CPPFLAGS ]) @@ -108,11 +108,11 @@ AC_DEFUN(PHP_DOM_EXSLT_CHECK_VERSION,[ ]) PHP_ARG_WITH(dom-xslt, for DOM XSLT support, -[ --with-dom-xslt[=DIR] Include DOM XSLT support (requires libxslt >= 1.0.3). +[ --with-dom-xslt[=DIR] Include DOM XSLT support (requires libxslt >= 1.0.18). DIR is the libxslt install directory.]) PHP_ARG_WITH(dom-exslt, for DOM EXSLT support, -[ --with-dom-exslt[=DIR] Include DOM EXSLT support (requires libxslt >= 1.0.3). +[ --with-dom-exslt[=DIR] Include DOM EXSLT support (requires libxslt >= 1.0.18). DIR is the libexslt install directory.]) if test "$PHP_DOM_XSLT" != "no"; then diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index 1ee50ff942..5af6f81db3 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -282,6 +282,7 @@ static zend_function_entry domxml_functions[] = { PHP_FE(domxml_xslt_stylesheet_doc, NULL) PHP_FE(domxml_xslt_stylesheet_file, NULL) PHP_FE(domxml_xslt_process, NULL) + PHP_FE(domxml_xslt_dump_mem, NULL) #endif PHP_FALIAS(domxml_add_root, domxml_doc_add_root, NULL) @@ -521,6 +522,7 @@ static zend_function_entry php_domxmlns_class_functions[] = { static zend_function_entry php_domxsltstylesheet_class_functions[] = { /* TODO: maybe some more methods? */ PHP_FALIAS(process, domxml_xslt_process, NULL) + PHP_FALIAS(dump_mem, domxml_xslt_dump_mem, NULL) {NULL, NULL, NULL} }; #endif @@ -4172,6 +4174,43 @@ PHP_FUNCTION(domxml_new_xmldoc) } /* }}} */ +/* {{{ proto string domxml_xslt_dump_mem(object xslstylesheet, object xmldoc) + output XSLT result to memory */ +PHP_FUNCTION(domxml_xslt_dump_mem) +{ + zval *rv, *idxsl, *idxml; + xsltStylesheetPtr xsltstp; + xmlDocPtr xmldocp; + xmlDocPtr docp; + xmlChar *doc_txt_ptr; + int doc_txt_len; + int ret; + + DOMXML_GET_THIS(idxsl); + + xsltstp = php_xsltstylesheet_get_object(idxsl, le_domxsltstylesheetp, 0 TSRMLS_CC); + if (!xsltstp) { + php_error(E_WARNING, "%s(): underlying object missing", + get_active_function_name(TSRMLS_C)); + RETURN_FALSE; + } + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &idxml) == FAILURE) { + RETURN_FALSE; + } + + DOMXML_GET_OBJ(xmldocp, idxml, le_domxmldocp); + + ret = xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, xmldocp, xsltstp); + + if (ret) { + RETURN_FALSE; + } + + RETURN_STRINGL(doc_txt_ptr, doc_txt_len, 1); +} +/* }}} */ + /* {{{ proto object domxml_parser([string buf[,string filename]]) Creates new xmlparser */ PHP_FUNCTION(domxml_parser) @@ -4902,7 +4941,7 @@ PHP_FUNCTION(xptr_eval) Get XML library version */ PHP_FUNCTION(domxml_version) { - RETURN_STRING(xmlParserVersion,1); + RETURN_STRING((char *) xmlParserVersion,1); } /* }}} */ diff --git a/ext/domxml/php_domxml.h b/ext/domxml/php_domxml.h index fe5b861893..0c799f5253 100644 --- a/ext/domxml/php_domxml.h +++ b/ext/domxml/php_domxml.h @@ -229,6 +229,7 @@ PHP_FUNCTION(domxml_xslt_stylesheet); PHP_FUNCTION(domxml_xslt_stylesheet_doc); PHP_FUNCTION(domxml_xslt_stylesheet_file); PHP_FUNCTION(domxml_xslt_process); +PHP_FUNCTION(domxml_xslt_dump_mem); PHP_FUNCTION(domxml_xslt_version); #endif typedef struct { -- 2.40.0