Back to index

php5  5.3.10
documenttype.c
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Christian Stocker <chregu@php.net>                          |
00016    |          Rob Richards <rrichards@php.net>                            |
00017    +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: documenttype.c 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include "config.h"
00024 #endif
00025 
00026 #include "php.h"
00027 #if HAVE_LIBXML && HAVE_DOM
00028 #include "php_dom.h"
00029 
00030 /*
00031 * class DOMDocumentType extends DOMNode 
00032 *
00033 * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-412266927
00034 * Since: 
00035 */
00036 
00037 const zend_function_entry php_dom_documenttype_class_functions[] = {
00038        PHP_FE_END
00039 };
00040 
00041 /* {{{ name   string 
00042 readonly=yes 
00043 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1844763134
00044 Since: 
00045 */
00046 int dom_documenttype_name_read(dom_object *obj, zval **retval TSRMLS_DC)
00047 {
00048        xmlDtdPtr dtdptr;
00049 
00050        dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
00051 
00052        if (dtdptr == NULL) {
00053               php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
00054               return FAILURE;
00055        }
00056 
00057        ALLOC_ZVAL(*retval);
00058        ZVAL_STRING(*retval, (char *) (dtdptr->name), 1);
00059 
00060        return SUCCESS;
00061 }
00062 
00063 /* }}} */
00064 
00065 /* {{{ entities      DOMNamedNodeMap      
00066 readonly=yes 
00067 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1788794630
00068 Since: 
00069 */
00070 int dom_documenttype_entities_read(dom_object *obj, zval **retval TSRMLS_DC)
00071 {
00072        xmlDtdPtr doctypep;
00073        xmlHashTable *entityht;
00074        dom_object *intern;
00075 
00076        doctypep = (xmlDtdPtr) dom_object_get_node(obj);
00077 
00078        if (doctypep == NULL) {
00079               php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
00080               return FAILURE;
00081        }
00082 
00083        MAKE_STD_ZVAL(*retval);
00084        php_dom_create_interator(*retval, DOM_NAMEDNODEMAP TSRMLS_CC);
00085 
00086        entityht = (xmlHashTable *) doctypep->entities;
00087 
00088        intern = (dom_object *)zend_objects_get_address(*retval TSRMLS_CC);
00089        dom_namednode_iter(obj, XML_ENTITY_NODE, intern, entityht, NULL, NULL TSRMLS_CC);
00090 
00091        return SUCCESS;
00092 }
00093 
00094 /* }}} */
00095 
00096 /* {{{ notations     DOMNamedNodeMap      
00097 readonly=yes 
00098 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D46829EF
00099 Since: 
00100 */
00101 int dom_documenttype_notations_read(dom_object *obj, zval **retval TSRMLS_DC)
00102 {
00103        xmlDtdPtr doctypep;
00104        xmlHashTable *notationht;
00105        dom_object *intern;
00106 
00107        doctypep = (xmlDtdPtr) dom_object_get_node(obj);
00108 
00109        if (doctypep == NULL) {
00110               php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
00111               return FAILURE;
00112        }
00113 
00114        MAKE_STD_ZVAL(*retval);
00115        php_dom_create_interator(*retval, DOM_NAMEDNODEMAP TSRMLS_CC);
00116 
00117        notationht = (xmlHashTable *) doctypep->notations;
00118 
00119        intern = (dom_object *)zend_objects_get_address(*retval TSRMLS_CC);
00120        dom_namednode_iter(obj, XML_NOTATION_NODE, intern, notationht, NULL, NULL TSRMLS_CC);
00121 
00122        return SUCCESS;
00123 }
00124 
00125 /* }}} */
00126 
00127 /* {{{ publicId      string 
00128 readonly=yes 
00129 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-publicId
00130 Since: DOM Level 2
00131 */
00132 int dom_documenttype_public_id_read(dom_object *obj, zval **retval TSRMLS_DC)
00133 {
00134        xmlDtdPtr dtdptr;
00135 
00136        dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
00137 
00138        if (dtdptr == NULL) {
00139               php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
00140               return FAILURE;
00141        }
00142 
00143        ALLOC_ZVAL(*retval);
00144        if (dtdptr->ExternalID) {
00145               ZVAL_STRING(*retval, (char *) (dtdptr->ExternalID), 1);
00146        } else {
00147               ZVAL_EMPTY_STRING(*retval);
00148        }
00149        return SUCCESS;
00150 
00151 }
00152 
00153 /* }}} */
00154 
00155 /* {{{ systemId      string 
00156 readonly=yes 
00157 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-systemId
00158 Since: DOM Level 2
00159 */
00160 int dom_documenttype_system_id_read(dom_object *obj, zval **retval TSRMLS_DC)
00161 {
00162        xmlDtdPtr dtdptr;
00163 
00164        dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
00165 
00166        if (dtdptr == NULL) {
00167               php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
00168               return FAILURE;
00169        }
00170 
00171        ALLOC_ZVAL(*retval);
00172        if (dtdptr->SystemID) {
00173               ZVAL_STRING(*retval, (char *) (dtdptr->SystemID), 1);
00174        } else {
00175               ZVAL_EMPTY_STRING(*retval);
00176        }
00177        return SUCCESS;
00178 }
00179 
00180 /* }}} */
00181 
00182 /* {{{ internalSubset       string 
00183 readonly=yes 
00184 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-internalSubset
00185 Since: DOM Level 2
00186 */
00187 int dom_documenttype_internal_subset_read(dom_object *obj, zval **retval TSRMLS_DC)
00188 {
00189 
00190        xmlDtdPtr dtdptr;
00191        xmlDtd *intsubset;
00192        xmlOutputBuffer *buff = NULL;
00193 
00194        dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
00195 
00196        if (dtdptr == NULL) {
00197               php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
00198               return FAILURE;
00199        }
00200 
00201        ALLOC_ZVAL(*retval);
00202 
00203        if (dtdptr->doc != NULL && ((intsubset = dtdptr->doc->intSubset) != NULL)) {
00204               buff = xmlAllocOutputBuffer(NULL);
00205               if (buff != NULL) {
00206                      xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL);
00207                      xmlOutputBufferFlush(buff);
00208                      ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1);
00209                      (void)xmlOutputBufferClose(buff);
00210                      return SUCCESS;
00211               }
00212        }
00213 
00214        ZVAL_EMPTY_STRING(*retval);
00215 
00216        return SUCCESS;
00217 
00218 }
00219 
00220 /* }}} */
00221 
00222 #endif
00223 
00224 /*
00225  * Local variables:
00226  * tab-width: 4
00227  * c-basic-offset: 4
00228  * End:
00229  * vim600: noet sw=4 ts=4 fdm=marker
00230  * vim<600: noet sw=4 ts=4
00231  */