entity.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. #ifdef HAVE_CONFIG_H
  18. #include "config.h"
  19. #endif
  20. #include "php.h"
  21. #if defined(HAVE_LIBXML) && defined(HAVE_DOM)
  22. #include "php_dom.h"
  23. /*
  24. * class DOMEntity extends DOMNode
  25. *
  26. * URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-527DCFF2
  27. * Since:
  28. */
  29. /* {{{ publicId string
  30. readonly=yes
  31. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7303025
  32. Since:
  33. */
  34. int dom_entity_public_id_read(dom_object *obj, zval *retval)
  35. {
  36. xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
  37. if (nodep == NULL) {
  38. php_dom_throw_error(INVALID_STATE_ERR, 1);
  39. return FAILURE;
  40. }
  41. if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
  42. ZVAL_NULL(retval);
  43. } else {
  44. ZVAL_STRING(retval, (char *) (nodep->ExternalID));
  45. }
  46. return SUCCESS;
  47. }
  48. /* }}} */
  49. /* {{{ systemId string
  50. readonly=yes
  51. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7C29F3E
  52. Since:
  53. */
  54. int dom_entity_system_id_read(dom_object *obj, zval *retval)
  55. {
  56. xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
  57. if (nodep == NULL) {
  58. php_dom_throw_error(INVALID_STATE_ERR, 1);
  59. return FAILURE;
  60. }
  61. if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
  62. ZVAL_NULL(retval);
  63. } else {
  64. ZVAL_STRING(retval, (char *) (nodep->SystemID));
  65. }
  66. return SUCCESS;
  67. }
  68. /* }}} */
  69. /* {{{ notationName string
  70. readonly=yes
  71. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-6ABAEB38
  72. Since:
  73. */
  74. int dom_entity_notation_name_read(dom_object *obj, zval *retval)
  75. {
  76. xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
  77. char *content;
  78. if (nodep == NULL) {
  79. php_dom_throw_error(INVALID_STATE_ERR, 1);
  80. return FAILURE;
  81. }
  82. if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
  83. ZVAL_NULL(retval);
  84. } else {
  85. content = (char *) xmlNodeGetContent((xmlNodePtr) nodep);
  86. ZVAL_STRING(retval, content);
  87. xmlFree(content);
  88. }
  89. return SUCCESS;
  90. }
  91. /* }}} */
  92. /* {{{ actualEncoding string
  93. readonly=yes
  94. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-actualEncoding
  95. Since: DOM Level 3
  96. */
  97. int dom_entity_actual_encoding_read(dom_object *obj, zval *retval)
  98. {
  99. ZVAL_NULL(retval);
  100. return SUCCESS;
  101. }
  102. /* }}} */
  103. /* {{{ encoding string
  104. readonly=yes
  105. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-encoding
  106. Since: DOM Level 3
  107. */
  108. int dom_entity_encoding_read(dom_object *obj, zval *retval)
  109. {
  110. ZVAL_NULL(retval);
  111. return SUCCESS;
  112. }
  113. /* }}} */
  114. /* {{{ version string
  115. readonly=yes
  116. URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-version
  117. Since: DOM Level 3
  118. */
  119. int dom_entity_version_read(dom_object *obj, zval *retval)
  120. {
  121. ZVAL_NULL(retval);
  122. return SUCCESS;
  123. }
  124. /* }}} */
  125. #endif