xref: /PHP-8.3/ext/dom/notation.c (revision 01b3fc03)
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 
26 /*
27 * class DOMNotation extends DOMNode
28 *
29 * URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-5431D1B9
30 * Since:
31 */
32 
33 /* {{{ attribute protos, not implemented yet */
34 
35 /* {{{ publicId	string
36 readonly=yes
37 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-54F2B4D0
38 Since:
39 */
dom_notation_public_id_read(dom_object * obj,zval * retval)40 int dom_notation_public_id_read(dom_object *obj, zval *retval)
41 {
42 	xmlEntityPtr nodep = (xmlEntityPtr) dom_object_get_node(obj);
43 
44 	if (nodep == NULL) {
45 		php_dom_throw_error(INVALID_STATE_ERR, 1);
46 		return FAILURE;
47 	}
48 
49 	if (nodep->ExternalID) {
50 		ZVAL_STRING(retval, (char *) (nodep->ExternalID));
51 	} else {
52 		ZVAL_EMPTY_STRING(retval);
53 	}
54 
55 	return SUCCESS;
56 }
57 
58 /* }}} */
59 
60 /* {{{ systemId	string
61 readonly=yes
62 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-E8AAB1D0
63 Since:
64 */
dom_notation_system_id_read(dom_object * obj,zval * retval)65 int dom_notation_system_id_read(dom_object *obj, zval *retval)
66 {
67 	xmlEntityPtr nodep = (xmlEntityPtr) dom_object_get_node(obj);
68 
69 	if (nodep == NULL) {
70 		php_dom_throw_error(INVALID_STATE_ERR, 1);
71 		return FAILURE;
72 	}
73 
74 	if (nodep->SystemID) {
75 		ZVAL_STRING(retval, (char *) (nodep->SystemID));
76 	} else {
77 		ZVAL_EMPTY_STRING(retval);
78 	}
79 
80 	return SUCCESS;
81 }
82 
83 /* }}} */
84 
85 /* }}} */
86 
87 #endif
88