php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
entityreference.c
Go to the documentation of this file.
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: Christian Stocker <chregu@php.net> |
14 | Rob Richards <rrichards@php.net> |
15 +----------------------------------------------------------------------+
16*/
17
18#ifdef HAVE_CONFIG_H
19#include <config.h>
20#endif
21
22#include "php.h"
23#if defined(HAVE_LIBXML) && defined(HAVE_DOM)
24#include "php_dom.h"
25#include "dom_properties.h"
26
27/*
28* class DOMEntityReference extends DOMNode
29*
30* URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-11C98490
31* Since:
32*/
33
34/* {{{ */
36{
37 xmlNode *node;
38 xmlNodePtr oldnode = NULL;
39 dom_object *intern;
40 char *name;
41 size_t name_len, name_valid;
42
43 if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
45 }
46
47 name_valid = xmlValidateName(BAD_CAST name, 0);
48 if (name_valid != 0) {
51 }
52
53 node = xmlNewReference(NULL, BAD_CAST name);
54
55 if (!node) {
58 }
59
60 intern = Z_DOMOBJ_P(ZEND_THIS);
61 oldnode = dom_object_get_node(intern);
62 if (oldnode != NULL) {
63 php_libxml_node_decrement_resource((php_libxml_node_object *)intern);
64 }
65 php_libxml_increment_node_ptr((php_libxml_node_object *)intern, node, (void *)intern);
66}
67/* }}} end DOMEntityReference::__construct */
68
69/* The following property handlers are necessary because of special lifetime management with entities and entity
70 * references. The issue is that entity references hold a reference to an entity declaration, but don't
71 * register that reference anywhere. When the entity declaration disappears we have no way of notifying the
72 * entity references. Override the property handlers for the declaration-accessing properties to fix this problem. */
73
74xmlEntityPtr dom_entity_reference_fetch_and_sync_declaration(xmlNodePtr reference)
75{
76 xmlEntityPtr entity = xmlGetDocEntity(reference->doc, reference->name);
77 reference->children = (xmlNodePtr) entity;
78 reference->last = (xmlNodePtr) entity;
79 reference->content = entity ? entity->content : NULL;
80 return entity;
81}
82
84{
85 DOM_PROP_NODE(xmlNodePtr, nodep, obj);
86
87 xmlEntityPtr entity = dom_entity_reference_fetch_and_sync_declaration(nodep);
88
89 php_dom_create_nullable_object((xmlNodePtr) entity, retval, obj);
90 return SUCCESS;
91}
92
94{
95 DOM_PROP_NODE(xmlNodePtr, nodep, obj);
96
99}
100
102{
103 DOM_PROP_NODE(xmlNodePtr, nodep, obj);
104
107}
108
109#endif
zend_result dom_entity_reference_text_content_read(dom_object *obj, zval *retval)
zend_result dom_node_child_nodes_read(dom_object *obj, zval *retval)
zend_result dom_entity_reference_child_read(dom_object *obj, zval *retval)
#define DOM_PROP_NODE(type, name, obj)
zend_result dom_entity_reference_child_nodes_read(dom_object *obj, zval *retval)
zend_result dom_node_text_content_read(dom_object *obj, zval *retval)
void php_dom_throw_error(dom_exception_code error_code, bool strict_error)
@ INVALID_STATE_ERR
@ INVALID_CHARACTER_ERR
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
#define PHP_METHOD
Definition php.h:365
xmlEntityPtr dom_entity_reference_fetch_and_sync_declaration(xmlNodePtr reference)
bool php_dom_create_nullable_object(xmlNodePtr obj, zval *return_value, dom_object *domobj)
PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj)
struct _dom_object dom_object
#define Z_DOMOBJ_P(zv)
Definition xml_common.h:36
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
#define ZEND_NUM_ARGS()
Definition zend_API.h:530
#define RETURN_THROWS()
Definition zend_API.h:1060
#define ZEND_THIS
Definition zend_API.h:523
struct _zval_struct zval
@ FAILURE
Definition zend_types.h:61
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
zval retval
zend_string * name