xmlFree(qualified_name);
}
+#if LIBXML_VERSION >= 20600
static void
_start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, int nb_defaulted, const xmlChar ** attributes)
{
xmlFree(qualified_name);
}
+#endif
static void
_namespace_handler(XML_Parser parser, xmlNsPtr nsptr)
xmlFree(qualified_name);
}
+#if LIBXML_VERSION >= 20600
static void
_end_element_handler_ns(void *user, const xmlChar *name, const xmlChar * prefix, const xmlChar *URI)
{
xmlFree(qualified_name);
}
+#endif
static void
_cdata_handler(void *user, const xmlChar *cdata, int cdata_len)
NULL, /* getParameterEntity */
_cdata_handler, /* cdataBlock */
NULL, /* externalSubset */
- 1,
+ 1
+#if LIBXML_VERSION >= 20600
+ ,
NULL,
_start_element_handler_ns,
_end_element_handler_ns,
NULL
+#endif
};
parser->parser->replaceEntities = 1;
if (sep != NULL) {
parser->use_namespace = 1;
+#if LIBXML_VERSION >= 20600
parser->parser->sax2 = 1;
+#endif
parser->_ns_seperator = xmlStrdup(sep);
}
return parser;
PHPAPI int
XML_Parse(XML_Parser parser, const XML_Char *data, int data_len, int is_final)
{
+#if LIBXML_VERSION >= 20600
int error;
error = xmlParseChunk(parser->parser, data, data_len, is_final);
if (!error) {
} else {
return 1;
}
+#else
+ return !xmlParseChunk(parser->parser, data, data_len, is_final);
+#endif
}
PHPAPI int
Create an XML parser */
PHP_FUNCTION(xml_parser_create_ns)
{
+#if defined(HAVE_LIBXML) && defined(HAVE_XML) && !defined(HAVE_LIBEXPAT) && LIBXML_VERSION < 20600
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "is broken with libxml2 %d. Please upgrade to libxml2 2.6", LIBXML_DOTTED_VERSION);
+#else
php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+#endif
}
/* }}} */