1 /* 2 +----------------------------------------------------------------------+ 3 | Copyright (c) The PHP Group | 4 +----------------------------------------------------------------------+ 5 | This source file is subject to version 3.01 of the PHP license, | 6 | that is bundled with this package in the file LICENSE, and is | 7 | available through the world-wide-web at the following url: | 8 | https://www.php.net/license/3_01.txt | 9 | If you did not receive a copy of the PHP license and are unable to | 10 | obtain it through the world-wide-web, please send a note to | 11 | license@php.net so we can mail you a copy immediately. | 12 +----------------------------------------------------------------------+ 13 | Authors: Niels Dossche <nielsdos@php.net> | 14 +----------------------------------------------------------------------+ 15 */ 16 17 #ifndef NAMESPACE_COMPAT_H 18 #define NAMESPACE_COMPAT_H 19 20 #include "xml_common.h" 21 22 /* https://infra.spec.whatwg.org/#namespaces */ 23 #define DOM_XHTML_NS_URI "http://www.w3.org/1999/xhtml" 24 #define DOM_MATHML_NS_URI "http://www.w3.org/1998/Math/MathML" 25 #define DOM_SVG_NS_URI "http://www.w3.org/2000/svg" 26 #define DOM_XLINK_NS_URI "http://www.w3.org/1999/xlink" 27 #define DOM_XML_NS_URI "http://www.w3.org/XML/1998/namespace" 28 #define DOM_XMLNS_NS_URI "http://www.w3.org/2000/xmlns/" 29 30 struct php_dom_ns_magic_token; 31 typedef struct php_dom_ns_magic_token php_dom_ns_magic_token; 32 33 struct php_dom_libxml_ns_mapper; 34 typedef struct php_dom_libxml_ns_mapper php_dom_libxml_ns_mapper; 35 36 PHP_DOM_EXPORT extern const php_dom_ns_magic_token *php_dom_ns_is_html_magic_token; 37 PHP_DOM_EXPORT extern const php_dom_ns_magic_token *php_dom_ns_is_mathml_magic_token; 38 PHP_DOM_EXPORT extern const php_dom_ns_magic_token *php_dom_ns_is_svg_magic_token; 39 PHP_DOM_EXPORT extern const php_dom_ns_magic_token *php_dom_ns_is_xlink_magic_token; 40 PHP_DOM_EXPORT extern const php_dom_ns_magic_token *php_dom_ns_is_xml_magic_token; 41 PHP_DOM_EXPORT extern const php_dom_ns_magic_token *php_dom_ns_is_xmlns_magic_token; 42 43 /* These functions make it possible to make a namespace declaration also visible as an attribute by 44 * creating an equivalent attribute node. */ 45 46 PHP_DOM_EXPORT xmlNsPtr php_dom_libxml_ns_mapper_ensure_html_ns(php_dom_libxml_ns_mapper *mapper); 47 PHP_DOM_EXPORT xmlNsPtr php_dom_libxml_ns_mapper_ensure_prefixless_xmlns_ns(php_dom_libxml_ns_mapper *mapper); 48 PHP_DOM_EXPORT xmlNsPtr php_dom_libxml_ns_mapper_get_ns(php_dom_libxml_ns_mapper *mapper, zend_string *prefix, zend_string *uri); 49 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); 50 PHP_DOM_EXPORT xmlNsPtr php_dom_libxml_ns_mapper_get_ns_raw_strings_nullsafe(php_dom_libxml_ns_mapper *mapper, const char *prefix, const char *uri); 51 52 PHP_DOM_EXPORT php_dom_libxml_ns_mapper *php_dom_get_ns_mapper(dom_object *object); 53 PHP_DOM_EXPORT void php_dom_ns_compat_mark_attribute_list(php_dom_libxml_ns_mapper *mapper, xmlNodePtr node); 54 PHP_DOM_EXPORT void php_dom_libxml_reconcile_modern(php_dom_libxml_ns_mapper *ns_mapper, xmlNodePtr node); 55 PHP_DOM_EXPORT void php_dom_reconcile_attribute_namespace_after_insertion(xmlAttrPtr attrp); 56 PHP_DOM_EXPORT xmlAttrPtr php_dom_ns_compat_mark_attribute(php_dom_libxml_ns_mapper *mapper, xmlNodePtr node, xmlNsPtr ns); 57 58 PHP_DOM_EXPORT bool php_dom_ns_is_fast(const xmlNode *nodep, const php_dom_ns_magic_token *magic_token); 59 PHP_DOM_EXPORT bool php_dom_ns_is_fast_ex(xmlNsPtr ns, const php_dom_ns_magic_token *magic_token); 60 PHP_DOM_EXPORT bool php_dom_ns_is_html_and_document_is_html(const xmlNode *nodep); 61 62 typedef struct php_dom_in_scope_ns { 63 xmlNsPtr *list; 64 size_t count; 65 bool origin_is_ns_compat; 66 } php_dom_in_scope_ns; 67 68 PHP_DOM_EXPORT php_dom_in_scope_ns php_dom_get_in_scope_ns(php_dom_libxml_ns_mapper *ns_mapper, const xmlNode *node, bool ignore_elements); 69 PHP_DOM_EXPORT php_dom_in_scope_ns php_dom_get_in_scope_ns_legacy(const xmlNode *node); 70 PHP_DOM_EXPORT void php_dom_in_scope_ns_destroy(php_dom_in_scope_ns *in_scope_ns); 71 72 #endif 73