It does the following:
1) Includes all the correct libxml2 schema header files. 2) Determines whether schema support is available. 3) Avoids refreeing the parser. 4) Inverts valid / invalid logic to work correctly.
Please apply.
-adam
PS: Let me know if I generated the patch incorrectly.
-- adam trachtenberg [EMAIL PROTECTED]
Index: php_simplexml.h
===================================================================
RCS file: /repository/php-src/ext/simplexml/php_simplexml.h,v
retrieving revision 1.6
diff -u -u -r1.6 php_simplexml.h
--- php_simplexml.h 14 Jun 2003 18:15:50 -0000 1.6
+++ php_simplexml.h 4 Oct 2003 21:01:10 -0000
@@ -44,6 +44,7 @@
#include <libxml/xpathInternals.h>
#include <libxml/xpointer.h>
#include <libxml/xmlschemas.h>
+#include <libxml/schemasInternals.h>
PHP_MINIT_FUNCTION(simplexml);
PHP_MSHUTDOWN_FUNCTION(simplexml);
Index: simplexml.c
===================================================================
RCS file: /repository/php-src/ext/simplexml/simplexml.c,v
retrieving revision 1.60
diff -u -u -r1.60 simplexml.c
--- simplexml.c 2 Oct 2003 19:45:05 -0000 1.60
+++ simplexml.c 4 Oct 2003 21:01:10 -0000
@@ -573,7 +573,7 @@
#define SCHEMA_BLOB 1
#define SCHEMA_OBJECT 2
-#ifdef xmlSchemaParserCtxtPtr
+#ifdef LIBXML_SCHEMAS_ENABLED
/* {{{ simplexml_ce_schema_validate_file()
*/
@@ -585,7 +585,7 @@
xmlSchemaParserCtxtPtr parser;
xmlSchemaPtr sptr;
xmlSchemaValidCtxtPtr vptr;
- int is_valid;
+ int is_invalid;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &source) == FAILURE)
{
return;
@@ -598,26 +598,24 @@
convert_to_string_ex(&source);
parser = xmlSchemaNewParserCtxt(Z_STRVAL_P(source));
sptr = xmlSchemaParse(parser);
- xmlSchemaFreeParserCtxt(parser);
break;
case SCHEMA_BLOB:
convert_to_string_ex(&source);
parser = xmlSchemaNewMemParserCtxt(Z_STRVAL_P(source),
Z_STRLEN_P(source));
sptr = xmlSchemaParse(parser);
- xmlSchemaFreeParserCtxt(parser);
break;
}
vptr = xmlSchemaNewValidCtxt(sptr);
- is_valid = xmlSchemaValidateDoc(vptr, (xmlDocPtr) sxe->document->ptr);
+ is_invalid = xmlSchemaValidateDoc(vptr, (xmlDocPtr) sxe->document->ptr);
xmlSchemaFree(sptr);
xmlSchemaFreeValidCtxt(vptr);
xmlSchemaFreeParserCtxt(parser);
- if (is_valid) {
- RETURN_TRUE;
- } else {
+ if (is_invalid) {
RETURN_FALSE;
+ } else {
+ RETURN_TRUE;
}
}
/* }}} */
@@ -695,7 +693,7 @@
{
if (!strcmp(method, "xsearch")) {
simplexml_ce_xpath_search(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-#ifdef xmlSchemaParserCtxtPtr
+#ifdef LIBXML_SCHEMAS_ENABLED
} else if (!strcmp(method, "validate_schema_file")) {
simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU,
SCHEMA_FILE);
} else if (!strcmp(method, "validate_schema_buffer")) {-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
