Back to index

php5  5.3.10
Functions | Variables
xsl_fe.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 PHP_FUNCTION (xsl_xsltprocessor_import_stylesheet)
 PHP_FUNCTION (xsl_xsltprocessor_transform_to_doc)
 PHP_FUNCTION (xsl_xsltprocessor_transform_to_uri)
 PHP_FUNCTION (xsl_xsltprocessor_transform_to_xml)
 PHP_FUNCTION (xsl_xsltprocessor_set_parameter)
 PHP_FUNCTION (xsl_xsltprocessor_get_parameter)
 PHP_FUNCTION (xsl_xsltprocessor_remove_parameter)
 PHP_FUNCTION (xsl_xsltprocessor_has_exslt_support)
 PHP_FUNCTION (xsl_xsltprocessor_register_php_functions)
 PHP_FUNCTION (xsl_xsltprocessor_set_profiling)

Variables

const zend_function_entry php_xsl_xsltprocessor_class_functions []
zend_class_entry * xsl_xsltprocessor_class_entry

Function Documentation

PHP_FUNCTION ( xsl_xsltprocessor_import_stylesheet  )

Definition at line 383 of file xsltprocessor.c.

{
       zval *id, *docp = NULL;
       xmlDoc *doc = NULL, *newdoc = NULL;
       xsltStylesheetPtr sheetp, oldsheetp;
       xsl_object *intern;
       int prevSubstValue, prevExtDtdValue, clone_docu = 0;
       xmlNode *nodep = NULL;
       zend_object_handlers *std_hnd;
       zval *cloneDocu, *member;
       
       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &id, xsl_xsltprocessor_class_entry, &docp) == FAILURE) {
              RETURN_FALSE;
       }

       nodep = php_libxml_import_node(docp TSRMLS_CC);
       
       if (nodep) {
              doc = nodep->doc;
       }
       if (doc == NULL) {
              php_error(E_WARNING, "Invalid Document");
              RETURN_FALSE;
       }

       /* libxslt uses _private, so we must copy the imported 
       stylesheet document otherwise the node proxies will be a mess */
       newdoc = xmlCopyDoc(doc, 1);
       xmlNodeSetBase((xmlNodePtr) newdoc, (xmlChar *)doc->URL);
       prevSubstValue = xmlSubstituteEntitiesDefault(1);
       prevExtDtdValue = xmlLoadExtDtdDefaultValue;
       xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;

       sheetp = xsltParseStylesheetDoc(newdoc);
       xmlSubstituteEntitiesDefault(prevSubstValue);
       xmlLoadExtDtdDefaultValue = prevExtDtdValue;

       if (!sheetp) {
              xmlFreeDoc(newdoc);
              RETURN_FALSE;
       }

       intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC); 

       std_hnd = zend_get_std_object_handlers();
       MAKE_STD_ZVAL(member);
       ZVAL_STRING(member, "cloneDocument", 0);
       cloneDocu = std_hnd->read_property(id, member, BP_VAR_IS TSRMLS_CC);
       if (Z_TYPE_P(cloneDocu) != IS_NULL) {
              convert_to_long(cloneDocu);
              clone_docu = Z_LVAL_P(cloneDocu);
       }
       efree(member);
       if (clone_docu == 0) {
              /* check if the stylesheet is using xsl:key, if yes, we have to clone the document _always_ before a transformation */
              nodep = xmlDocGetRootElement(sheetp->doc);
              if (nodep && (nodep = nodep->children)) {
                     while (nodep) {
                            if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
                                   intern->hasKeys = 1;
                                   break;
                            }
                            nodep = nodep->next;
                     }
              }
       } else {
              intern->hasKeys = clone_docu;
       }

       if ((oldsheetp = (xsltStylesheetPtr)intern->ptr)) { 
              /* free wrapper */
              if (((xsltStylesheetPtr) intern->ptr)->_private != NULL) {
                     ((xsltStylesheetPtr) intern->ptr)->_private = NULL;   
              }
              xsltFreeStylesheet((xsltStylesheetPtr) intern->ptr);
              intern->ptr = NULL;
       }

       php_xsl_set_object(id, sheetp TSRMLS_CC);
       RETVAL_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( xsl_xsltprocessor_transform_to_doc  )

Definition at line 615 of file xsltprocessor.c.

{
       zval *id, *rv = NULL, *docp = NULL;
       xmlDoc *newdocp;
       xsltStylesheetPtr sheetp;
       int ret, ret_class_len=0;
       char *ret_class = NULL;
       xsl_object *intern;

       id = getThis();
       intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
       sheetp = (xsltStylesheetPtr) intern->ptr;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|s!", &docp, &ret_class, &ret_class_len) == FAILURE) {
              RETURN_FALSE;
       }

       newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp TSRMLS_CC);

       if (newdocp) {
              if (ret_class) {
                     int found;
                     char *curclass_name;
                     zend_class_entry *curce, **ce;
                     php_libxml_node_object *interndoc;

                     curce = Z_OBJCE_P(docp);
                     curclass_name = curce->name;
                     while (curce->parent != NULL) {
                            curce = curce->parent;
                     }

                     found = zend_lookup_class(ret_class, ret_class_len, &ce TSRMLS_CC);
                     if ((found != SUCCESS) || !instanceof_function(*ce, curce TSRMLS_CC)) {
                            xmlFreeDoc(newdocp);
                            php_error_docref(NULL TSRMLS_CC, E_WARNING, 
                                   "Expecting class compatible with %s, '%s' given", curclass_name, ret_class);
                            RETURN_FALSE;
                     }

                     object_init_ex(return_value, *ce);
              
                     interndoc = (php_libxml_node_object *)zend_objects_get_address(return_value TSRMLS_CC);
                     php_libxml_increment_doc_ref(interndoc, newdocp TSRMLS_CC);
                     php_libxml_increment_node_ptr(interndoc, (xmlNodePtr)newdocp, (void *)interndoc TSRMLS_CC);
              } else {
                     DOM_RET_OBJ(rv, (xmlNodePtr) newdocp, &ret, NULL);
              }
       } else {
              RETURN_FALSE;
       }
       
}

Here is the call graph for this function:

PHP_FUNCTION ( xsl_xsltprocessor_transform_to_uri  )

Definition at line 672 of file xsltprocessor.c.

{
       zval *id, *docp = NULL;
       xmlDoc *newdocp;
       xsltStylesheetPtr sheetp;
       int ret, uri_len;
       char *uri;
       xsl_object *intern;
       
       id = getThis();
       intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
       sheetp = (xsltStylesheetPtr) intern->ptr;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os", &docp, &uri, &uri_len) == FAILURE) {
              RETURN_FALSE;
       }

       newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp TSRMLS_CC);

       ret = -1;
       if (newdocp) {
              if (strlen(uri) != uri_len) {
                     xmlFreeDoc(newdocp);
                     RETURN_FALSE;
              }
              ret = xsltSaveResultToFilename(uri, newdocp, sheetp, 0);
              xmlFreeDoc(newdocp);
       }

       RETVAL_LONG(ret);
}

Here is the call graph for this function:

PHP_FUNCTION ( xsl_xsltprocessor_transform_to_xml  )

Definition at line 707 of file xsltprocessor.c.

{
       zval *id, *docp = NULL;
       xmlDoc *newdocp;
       xsltStylesheetPtr sheetp;
       int ret;
       xmlChar *doc_txt_ptr;
       int doc_txt_len;
       xsl_object *intern;
       
       id = getThis();
       intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
       sheetp = (xsltStylesheetPtr) intern->ptr;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &docp) == FAILURE) {
              RETURN_FALSE;
       }

       newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp TSRMLS_CC);

       ret = -1;
       if (newdocp) {
              ret = xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, newdocp, sheetp);
              if (doc_txt_ptr && doc_txt_len) {
                     RETVAL_STRINGL(doc_txt_ptr, doc_txt_len, 1);
                     xmlFree(doc_txt_ptr);
              }
              xmlFreeDoc(newdocp);
       }

       if (ret < 0) {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( xsl_xsltprocessor_set_parameter  )

Definition at line 745 of file xsltprocessor.c.

{
 
       zval *id;
       zval *array_value, **entry, *new_string;
       xsl_object *intern;
       char *string_key, *name, *value, *namespace;
       ulong idx;
       int string_key_len, namespace_len, name_len, value_len;
       DOM_GET_THIS(id);

       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "sa", &namespace, &namespace_len, &array_value) == SUCCESS) {
              intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
              zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value));

              while (zend_hash_get_current_data(Z_ARRVAL_P(array_value), (void **)&entry) == SUCCESS) {
                     SEPARATE_ZVAL(entry);
                     convert_to_string_ex(entry);
                     
                     if (zend_hash_get_current_key_ex(Z_ARRVAL_P(array_value), &string_key, &string_key_len, &idx, 0, NULL) != HASH_KEY_IS_STRING) {
                            php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter array");
                            RETURN_FALSE;
                     }
                     
                     ALLOC_ZVAL(new_string);
                     Z_ADDREF_PP(entry);
                     COPY_PZVAL_TO_ZVAL(*new_string, *entry);
                     
                     zend_hash_update(intern->parameter, string_key, string_key_len, &new_string, sizeof(zval*), NULL);
                     zend_hash_move_forward(Z_ARRVAL_P(array_value));
              }
              RETURN_TRUE;

       } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "sss", &namespace, &namespace_len, &name, &name_len, &value, &value_len) == SUCCESS) {
              
              intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
              
              MAKE_STD_ZVAL(new_string);
              ZVAL_STRING(new_string, value, 1);
              
              zend_hash_update(intern->parameter, name, name_len + 1, &new_string, sizeof(zval*), NULL);
              RETURN_TRUE;
       } else {
              WRONG_PARAM_COUNT;
       }
       
}

Here is the call graph for this function:

PHP_FUNCTION ( xsl_xsltprocessor_get_parameter  )

Definition at line 796 of file xsltprocessor.c.

{
       zval *id;
       int name_len = 0, namespace_len = 0;
       char *name, *namespace;
       zval **value;
       xsl_object *intern;

       DOM_GET_THIS(id);
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &namespace, &namespace_len, &name, &name_len) == FAILURE) {
              RETURN_FALSE;
       }
       intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
       if ( zend_hash_find(intern->parameter, name, name_len + 1,  (void**) &value) == SUCCESS) {
              convert_to_string_ex(value);
              RETVAL_STRING(Z_STRVAL_PP(value),1);
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( xsl_xsltprocessor_remove_parameter  )

Definition at line 821 of file xsltprocessor.c.

{
       zval *id;
       int name_len = 0, namespace_len = 0;
       char *name, *namespace;
       xsl_object *intern;

       DOM_GET_THIS(id);
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &namespace, &namespace_len, &name, &name_len) == FAILURE) {
              RETURN_FALSE;
       }
       intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
       if ( zend_hash_del(intern->parameter, name, name_len + 1) == SUCCESS) {
              RETURN_TRUE;
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( xsl_xsltprocessor_has_exslt_support  )

Definition at line 914 of file xsltprocessor.c.

{
#if HAVE_XSL_EXSLT
       RETURN_TRUE;
#else
       RETURN_FALSE;
#endif
}
PHP_FUNCTION ( xsl_xsltprocessor_register_php_functions  )

Definition at line 844 of file xsltprocessor.c.

{
       zval *id;
       xsl_object *intern;
       zval *array_value, **entry, *new_string;
       int  name_len = 0;
       char *name;

       DOM_GET_THIS(id);
       
       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "a",  &array_value) == SUCCESS) {
              intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
              zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value));

              while (zend_hash_get_current_data(Z_ARRVAL_P(array_value), (void **)&entry) == SUCCESS) {
                     SEPARATE_ZVAL(entry);
                     convert_to_string_ex(entry);
                     
                     MAKE_STD_ZVAL(new_string);
                     ZVAL_LONG(new_string,1);
              
                     zend_hash_update(intern->registered_phpfunctions, Z_STRVAL_PP(entry), Z_STRLEN_PP(entry) + 1, &new_string, sizeof(zval*), NULL);
                     zend_hash_move_forward(Z_ARRVAL_P(array_value));
              }
              intern->registerPhpFunctions = 2;

       } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s",  &name, &name_len) == SUCCESS) {
              intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
              
              MAKE_STD_ZVAL(new_string);
              ZVAL_LONG(new_string,1);
              zend_hash_update(intern->registered_phpfunctions, name, name_len + 1, &new_string, sizeof(zval*), NULL);
              intern->registerPhpFunctions = 2;
              
       } else {
              intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
              intern->registerPhpFunctions = 1;
       }
       
}

Here is the call graph for this function:

PHP_FUNCTION ( xsl_xsltprocessor_set_profiling  )

Definition at line 887 of file xsltprocessor.c.

{
       zval *id;
       xsl_object *intern;
       char *filename = NULL;
       int filename_len;
       DOM_GET_THIS(id);

       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s!", &filename, &filename_len) == SUCCESS) {
              intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
              if (intern->profiling) {
                     efree(intern->profiling);
              }
              if (filename != NULL && strlen(filename) == filename_len) {
                     intern->profiling = estrndup(filename,filename_len);
              } else {
                     intern->profiling = NULL;
              }
              RETURN_TRUE;
       } else {
              WRONG_PARAM_COUNT;
       }
}

Here is the call graph for this function:


Variable Documentation

Definition at line 83 of file xsltprocessor.c.

zend_class_entry* xsl_xsltprocessor_class_entry

Definition at line 30 of file php_xsl.c.