if (!retnodep) {
RETURN_FALSE;
}
+
}
DOM_RET_OBJ(rv, (xmlNodePtr) retnodep, &ret, intern);
/* {{{ */
-static xmlDocPtr dom_document_parser(zval *id, int mode, char *source TSRMLS_DC) {
+static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int options TSRMLS_DC) {
xmlDocPtr ret;
xmlParserCtxtPtr ctxt = NULL;
dom_doc_props *doc_props;
xmlInitParser();
+#if LIBXML_VERSION < 20600
keep_blanks = xmlKeepBlanksDefault(keep_blanks);
+#endif
if (mode == DOM_LOAD_FILE) {
char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC);
ctxt = xmlCreateDocParserCtxt(source);
}
+#if LIBXML_VERSION < 20600
xmlKeepBlanksDefault(keep_blanks);
/* xmlIndentTreeOutput default is changed in xmlKeepBlanksDefault
reset back to 1 which is default value */
xmlIndentTreeOutput = 1;
+#endif
if (ctxt == NULL) {
return(NULL);
}
}
- ctxt->recovery = recover;
- ctxt->validate = validate;
- ctxt->loadsubset = (resolve_externals * XML_COMPLETE_ATTRS);
- ctxt->replaceEntities = substitute_ent;
-
ctxt->vctxt.error = php_libxml_ctx_error;
ctxt->vctxt.warning = php_libxml_ctx_warning;
ctxt->sax->error = php_libxml_ctx_error;
ctxt->sax->warning = php_libxml_ctx_warning;
}
+
+#if LIBXML_VERSION >= 20600
+ if (validate && ! (options & XML_PARSE_DTDVALID)) {
+ options |= XML_PARSE_DTDVALID;
+ }
+ if (resolve_externals && ! (options & XML_PARSE_DTDATTR)) {
+ options |= XML_PARSE_DTDATTR;
+ }
+ if (substitute_ent && ! (options & XML_PARSE_NOENT)) {
+ options |= XML_PARSE_NOENT;
+ }
+ if (keep_blanks == 0 && ! (options & XML_PARSE_NOBLANKS)) {
+ options |= XML_PARSE_NOBLANKS;
+ }
+ if (options > 0) {
+ xmlCtxtUseOptions(ctxt, options);
+ }
+#else
+ ctxt->validate = validate;
+ ctxt->loadsubset = (resolve_externals * XML_COMPLETE_ATTRS);
+ ctxt->replaceEntities = substitute_ent;
+#endif
+
+ ctxt->recovery = recover;
if (recover) {
old_error_reporting = EG(error_reporting);
EG(error_reporting) = old_error_reporting | E_WARNING;
}
+
xmlParseDocument(ctxt);
if (ctxt->wellFormed || recover) {
ret = ctxt->myDoc;
- if (recover) {
+ if (ctxt->recovery) {
EG(error_reporting) = old_error_reporting;
}
/* If loading from memory, set the base reference uri for the document */
dom_doc_props *doc_prop;
dom_object *intern;
char *source;
- int source_len, refcount, ret;
+ int source_len, refcount, ret, options = 0;
id = getThis();
if (id != NULL && ! instanceof_function(Z_OBJCE_P(id), dom_document_class_entry TSRMLS_CC)) {
id = NULL;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) {
return;
}
RETURN_FALSE;
}
- newdoc = dom_document_parser(id, mode, source TSRMLS_CC);
+ newdoc = dom_document_parser(id, mode, source, options TSRMLS_CC);
if (!newdoc)
RETURN_FALSE;
}
/* }}} end dom_parser_document */
-/* {{{ proto DOMNode dom_document_load(string source);
+/* {{{ proto DOMNode dom_document_load(string source [, int options]);
URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-load
Since: DOM Level 3
*/
}
/* }}} end dom_document_load */
-/* {{{ proto DOMNode dom_document_loadxml(string source);
+/* {{{ proto DOMNode dom_document_loadxml(string source [, int options]);
URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-loadXML
Since: DOM Level 3
*/
}
/* }}} */
-/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string class_name])
+/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string class_name [, int options]])
Load a filename and return a simplexml_element object to allow for processing */
PHP_FUNCTION(simplexml_load_file)
{
int filename_len;
xmlDocPtr docp;
char *classname = "";
- int classname_len = 0;
+ int classname_len = 0, options=0;
zend_class_entry *ce= sxe_class_entry;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &filename, &filename_len, &classname, &classname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sl", &filename, &filename_len, &classname, &classname_len, &options) == FAILURE) {
return;
}
+#if LIBXML_VERSION >= 20600
+ docp = xmlReadFile(filename, NULL, options);
+#else
docp = xmlParseFile(filename);
+#endif
+
if (! docp) {
RETURN_FALSE;
}
}
/* }}} */
-/* {{{ proto simplemxml_element simplexml_load_string(string data [, string class_name])
+/* {{{ proto simplemxml_element simplexml_load_string(string data [, string class_name [, int options]])
Load a string and return a simplexml_element object to allow for processing */
PHP_FUNCTION(simplexml_load_string)
{
int data_len;
xmlDocPtr docp;
char *classname = "";
- int classname_len = 0;
+ int classname_len = 0, options=0;
zend_class_entry *ce= sxe_class_entry;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &data, &data_len, &classname, &classname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sl", &data, &data_len, &classname, &classname_len, &options) == FAILURE) {
return;
}
+#if LIBXML_VERSION >= 20600
+ docp = xmlReadMemory(data, data_len, NULL, NULL, options);
+#else
docp = xmlParseMemory(data, data_len);
+#endif
+
if (! docp) {
RETURN_FALSE;
}