23#if defined(HAVE_LIBXML) && defined(HAVE_DOM)
57 size_t name_len = 0, publicid_len = 0, systemid_len = 0;
71 if (publicid_len > 0) {
72 pch1 = BAD_CAST publicid;
74 if (systemid_len > 0) {
75 pch2 = BAD_CAST systemid;
83 uri = xmlParseURI(
name);
84 if (uri !=
NULL && uri->opaque !=
NULL) {
85 localname = xmlStrdup(BAD_CAST uri->opaque);
86 if (xmlStrchr(localname, (xmlChar)
':') !=
NULL) {
93 localname = xmlStrdup(BAD_CAST
name);
100 doctype = xmlCreateIntSubset(
NULL, localname, pch1, pch2);
103 if (doctype ==
NULL) {
111PHP_METHOD(Dom_Implementation, createDocumentType)
113 size_t name_len, publicid_len = 0, systemid_len = 0;
121 if (xmlValidateQName(BAD_CAST
name, 0) != 0) {
127 xmlDtdPtr doctype = xmlCreateIntSubset(
130 publicid_len ? BAD_CAST publicid :
NULL,
131 systemid_len ? BAD_CAST systemid :
NULL
141 (xmlNodePtr) doctype,
155 xmlDtdPtr doctype =
NULL;
156 xmlNsPtr nsptr =
NULL;
158 size_t uri_len = 0, name_len = 0;
173 if (doctype->doc !=
NULL) {
185 if (errorcode == 0 && uri_len > 0
186 && ((nsptr = xmlNewNs(
NULL, BAD_CAST uri, BAD_CAST
prefix)) ==
NULL)
196 if (errorcode != 0) {
197 if (localname !=
NULL) {
205 docp = xmlNewDoc(
NULL);
207 if (localname !=
NULL) {
215 if (doctype !=
NULL) {
216 docp->intSubset = doctype;
217 doctype->parent = docp;
219 docp->children = (xmlNodePtr) doctype;
220 docp->last = (xmlNodePtr) doctype;
223 if (localname !=
NULL) {
224 nodep = xmlNewDocNode(docp, nsptr, BAD_CAST localname,
NULL);
226 if (doctype !=
NULL) {
227 docp->intSubset =
NULL;
228 doctype->parent =
NULL;
230 docp->children =
NULL;
239 nodep->nsDef = nsptr;
241 xmlDocSetRootElement(docp, nodep);
247 if (doctobj !=
NULL) {
248 doctobj->
document = ((
dom_object *)((php_libxml_node_ptr *)docp->_private)->_private)->document;
249 php_libxml_increment_doc_ref((php_libxml_node_object *)doctobj, docp);
256 xmlDtdPtr doctype =
NULL;
268 xmlDocPtr document =
NULL;
274 document = xmlNewDoc(BAD_CAST
"1.0");
278 document->encoding = xmlStrdup(BAD_CAST
"UTF-8");
281 xmlNodePtr element =
NULL;
284 if (
ZSTR_LEN(qualified_name) != 0) {
289 element = xmlNewDocNode(document, ns, localname,
NULL);
308 (xmlNodePtr) document,
315 if (doctype !=
NULL) {
317 xmlAddChild((xmlNodePtr) document, (xmlNodePtr) doctype);
318 doctype->doc = document;
319 document->intSubset = (xmlDtdPtr) doctype;
324 if (element !=
NULL) {
325 xmlAddChild((xmlNodePtr) document, element);
341 xmlFreeDoc(document);
348PHP_METHOD(Dom_Implementation, createHTMLDocument)
350 const char *title =
NULL;
351 size_t title_len = 0;
363 doc->encoding = xmlStrdup(BAD_CAST
"UTF-8");
369 xmlDtdPtr dtd = xmlCreateIntSubset(doc, BAD_CAST
"html",
NULL,
NULL);
376 xmlNodePtr html_element = xmlNewDocRawNode(doc, html_ns, BAD_CAST
"html",
NULL);
377 xmlAddChild((xmlNodePtr) doc, html_element);
380 xmlNodePtr head_element = xmlNewDocRawNode(doc, html_ns, BAD_CAST
"head",
NULL);
381 xmlAddChild(html_element, head_element);
384 xmlNodePtr title_element =
NULL;
388 title_element = xmlNewDocRawNode(doc, html_ns, BAD_CAST
"title", BAD_CAST title);
389 xmlAddChild(head_element, title_element);
393 xmlNodePtr body_element = xmlNewDocRawNode(doc, html_ns, BAD_CAST
"body",
NULL);
394 xmlAddChild(html_element, body_element);
strstr(string $haystack, string $needle, bool $before_needle=false)
PHP_DOM_EXPORT zend_class_entry * dom_html_document_class_entry
PHP_DOM_EXPORT zend_class_entry * dom_documenttype_class_entry
PHP_DOM_EXPORT zend_class_entry * dom_xml_document_class_entry
PHP_DOM_EXPORT zend_class_entry * dom_modern_documenttype_class_entry
void php_dom_throw_error(dom_exception_code error_code, bool strict_error)
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
PHP_DOM_EXPORT xmlNsPtr php_dom_libxml_ns_mapper_get_ns_raw_prefix_string(php_dom_libxml_ns_mapper *mapper, const xmlChar *prefix, size_t prefix_len, zend_string *uri)
PHP_DOM_EXPORT xmlNsPtr php_dom_libxml_ns_mapper_ensure_html_ns(php_dom_libxml_ns_mapper *mapper)
dom_object * php_dom_instantiate_object_helper(zval *return_value, zend_class_entry *ce, xmlNodePtr obj, dom_object *parent)
xmlDocPtr php_dom_create_html_doc(void)
bool dom_has_feature(zend_string *feature, zend_string *version)
void dom_set_xml_class(php_libxml_ref_obj *document)
int dom_check_qname(char *qname, char **localname, char **prefix, int uri_len, int name_len)
bool php_dom_adopt_node(xmlNodePtr nodep, dom_object *dom_object_new_document, xmlDocPtr new_document)
#define DOM_GET_OBJ(__ptr, __id, __prtype, __intern)
int dom_validate_and_extract(const zend_string *namespace, const zend_string *qname, xmlChar **localName, xmlChar **prefix)
const XML_DOCUMENT_TYPE_NODE
void php_dom_private_data_destroy(php_dom_private_data *data)
php_dom_private_data * php_dom_private_data_create(void)
php_dom_libxml_ns_mapper * php_dom_ns_mapper_from_private(php_dom_private_data *private_data)
php_libxml_private_data_header * php_dom_libxml_private_data_header(php_dom_private_data *private_data)
php_libxml_ref_obj * document
struct _dom_object dom_object
#define DOM_RET_OBJ(obj, domobject)
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num)
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
struct _zend_string zend_string
#define EXPECTED(condition)
#define UNEXPECTED(condition)
ZEND_API zend_string * zend_empty_string