Back to index

php5  5.3.10
Functions
php_xml.c File Reference
#include "php_soap.h"
#include "libxml/parser.h"
#include "libxml/parserInternals.h"

Go to the source code of this file.

Functions

static int is_blank (const xmlChar *str)
static void cleanup_xml_node (xmlNodePtr node)
static void soap_ignorableWhitespace (void *ctx, const xmlChar *ch, int len)
static void soap_Comment (void *ctx, const xmlChar *value)
xmlDocPtr soap_xmlParseFile (const char *filename TSRMLS_DC)
xmlDocPtr soap_xmlParseMemory (const void *buf, size_t buf_size)
int php_stream_xmlIO_match_wrapper (const char *filename)
void * php_stream_xmlIO_open_wrapper (const char *filename)
int php_stream_xmlIO_read (void *context, char *buffer, int len)
int php_stream_xmlIO_close (void *context)
xmlNsPtr attr_find_ns (xmlAttrPtr node)
xmlNsPtr node_find_ns (xmlNodePtr node)
int attr_is_equal_ex (xmlAttrPtr node, char *name, char *ns)
int node_is_equal_ex (xmlNodePtr node, char *name, char *ns)
xmlAttrPtr get_attribute_ex (xmlAttrPtr node, char *name, char *ns)
xmlNodePtr get_node_ex (xmlNodePtr node, char *name, char *ns)
xmlNodePtr get_node_recurisve_ex (xmlNodePtr node, char *name, char *ns)
xmlNodePtr get_node_with_attribute_ex (xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns)
xmlNodePtr get_node_with_attribute_recursive_ex (xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns)
int parse_namespace (const xmlChar *inval, char **value, char **namespace)

Function Documentation

xmlNsPtr attr_find_ns ( xmlAttrPtr  node)

Definition at line 198 of file php_xml.c.

{
       if (node->ns) {
              return node->ns;
       } else if (node->parent->ns) {
              return node->parent->ns;
       } else {
              return xmlSearchNs(node->doc, node->parent, NULL);
       }
}

Here is the caller graph for this function:

int attr_is_equal_ex ( xmlAttrPtr  node,
char *  name,
char *  ns 
)

Definition at line 218 of file php_xml.c.

{
       if (name == NULL || strcmp((char*)node->name, name) == 0) {
              if (ns) {
                     xmlNsPtr nsPtr = attr_find_ns(node);
                     if (nsPtr) {
                            return (strcmp((char*)nsPtr->href, ns) == 0);
                     } else {
                            return FALSE;
                     }
              }
              return TRUE;
       }
       return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void cleanup_xml_node ( xmlNodePtr  node) [static]

Definition at line 41 of file php_xml.c.

{
       xmlNodePtr trav;
       xmlNodePtr del = NULL;

       trav = node->children;
       while (trav != NULL) {
              if (del != NULL) {
                     xmlUnlinkNode(del);
                     xmlFreeNode(del);
                     del = NULL;
              }
              if (trav->type == XML_TEXT_NODE) {
                     if (is_blank(trav->content)) {
                            del = trav;
                     }
              } else if ((trav->type != XML_ELEMENT_NODE) &&
                         (trav->type != XML_CDATA_SECTION_NODE)) {
                     del = trav;
              } else if (trav->children != NULL) {
                     cleanup_xml_node(trav);
              }
              trav = trav->next;
       }
       if (del != NULL) {
              xmlUnlinkNode(del);
              xmlFreeNode(del);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

xmlAttrPtr get_attribute_ex ( xmlAttrPtr  node,
char *  name,
char *  ns 
)

Definition at line 251 of file php_xml.c.

{
       while (node!=NULL) {
              if (attr_is_equal_ex(node, name, ns)) {
                     return node;
              }
              node = node->next;
       }
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

xmlNodePtr get_node_ex ( xmlNodePtr  node,
char *  name,
char *  ns 
)

Definition at line 262 of file php_xml.c.

{
       while (node!=NULL) {
              if (node_is_equal_ex(node, name, ns)) {
                     return node;
              }
              node = node->next;
       }
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

xmlNodePtr get_node_recurisve_ex ( xmlNodePtr  node,
char *  name,
char *  ns 
)

Definition at line 273 of file php_xml.c.

{
       while (node != NULL) {
              if (node_is_equal_ex(node, name, ns)) {
                     return node;
              } else if (node->children != NULL) {
                     xmlNodePtr tmp = get_node_recurisve_ex(node->children, name, ns);
                     if (tmp) {
                            return tmp;
                     }
              }
              node = node->next;
       }
       return NULL;
}

Here is the call graph for this function:

xmlNodePtr get_node_with_attribute_ex ( xmlNodePtr  node,
char *  name,
char *  name_ns,
char *  attribute,
char *  value,
char *  attr_ns 
)

Definition at line 289 of file php_xml.c.

{
       xmlAttrPtr attr;

       while (node != NULL) {
              if (name != NULL) {
                     node = get_node_ex(node, name, name_ns);
                     if (node==NULL) {
                            return NULL;
                     }
              }

              attr = get_attribute_ex(node->properties, attribute, attr_ns);
              if (attr != NULL && strcmp((char*)attr->children->content, value) == 0) {
                     return node;
              }
              node = node->next;
       }
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

xmlNodePtr get_node_with_attribute_recursive_ex ( xmlNodePtr  node,
char *  name,
char *  name_ns,
char *  attribute,
char *  value,
char *  attr_ns 
)

Definition at line 310 of file php_xml.c.

{
       while (node != NULL) {
              if (node_is_equal_ex(node, name, name_ns)) {
                     xmlAttrPtr attr = get_attribute_ex(node->properties, attribute, attr_ns);
                     if (attr != NULL && strcmp((char*)attr->children->content, value) == 0) {
                            return node;
                     }
              }
              if (node->children != NULL) {
                     xmlNodePtr tmp = get_node_with_attribute_recursive_ex(node->children, name, name_ns, attribute, value, attr_ns);
                     if (tmp) {
                            return tmp;
                     }
              }
              node = node->next;
       }
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int is_blank ( const xmlChar *  str) [static]

Definition at line 29 of file php_xml.c.

{
       while (*str != '\0') {
              if (*str != ' '  && *str != 0x9 && *str != 0xa && *str != 0xd) {
                     return 0;
              }
              str++;
       }
       return 1;
}

Here is the caller graph for this function:

xmlNsPtr node_find_ns ( xmlNodePtr  node)

Definition at line 209 of file php_xml.c.

{
       if (node->ns) {
              return node->ns;
       } else {
              return xmlSearchNs(node->doc, node, NULL);
       }
}

Here is the caller graph for this function:

int node_is_equal_ex ( xmlNodePtr  node,
char *  name,
char *  ns 
)

Definition at line 234 of file php_xml.c.

{
       if (name == NULL || strcmp((char*)node->name, name) == 0) {
              if (ns) {
                     xmlNsPtr nsPtr = node_find_ns(node);
                     if (nsPtr) {
                            return (strcmp((char*)nsPtr->href, ns) == 0);
                     } else {
                            return FALSE;
                     }
              }
              return TRUE;
       }
       return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int parse_namespace ( const xmlChar *  inval,
char **  value,
char **  namespace 
)

Definition at line 330 of file php_xml.c.

{
       char *found = strrchr((char*)inval, ':');

       if (found != NULL && found != (char*)inval) {
              (*namespace) = estrndup((char*)inval, found - (char*)inval);
              (*value) = estrdup(++found);
       } else {
              (*value) = estrdup((char*)inval);
              (*namespace) = NULL;
       }

       return FALSE;
}

Here is the caller graph for this function:

int php_stream_xmlIO_close ( void *  context)

Definition at line 191 of file php_xml.c.

{
       TSRMLS_FETCH();
       return php_stream_close((php_stream*)context);
}

Here is the caller graph for this function:

int php_stream_xmlIO_match_wrapper ( const char *  filename)

Definition at line 173 of file php_xml.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void* php_stream_xmlIO_open_wrapper ( const char *  filename)

Definition at line 179 of file php_xml.c.

Here is the caller graph for this function:

int php_stream_xmlIO_read ( void *  context,
char *  buffer,
int  len 
)

Definition at line 185 of file php_xml.c.

{
       TSRMLS_FETCH();
       return php_stream_read((php_stream*)context, buffer, len);
}

Here is the caller graph for this function:

static void soap_Comment ( void *  ctx,
const xmlChar *  value 
) [static]

Definition at line 75 of file php_xml.c.

{
}

Here is the caller graph for this function:

static void soap_ignorableWhitespace ( void *  ctx,
const xmlChar *  ch,
int  len 
) [static]

Definition at line 71 of file php_xml.c.

{
}

Here is the caller graph for this function:

xmlDocPtr soap_xmlParseFile ( const char *filename  TSRMLS_DC)

Definition at line 79 of file php_xml.c.

{
       xmlParserCtxtPtr ctxt = NULL;
       xmlDocPtr ret;
       zend_bool old_allow_url_fopen;

/*
       xmlInitParser();
*/

       old_allow_url_fopen = PG(allow_url_fopen);
       PG(allow_url_fopen) = 1;
       ctxt = xmlCreateFileParserCtxt(filename);
       PG(allow_url_fopen) = old_allow_url_fopen;
       if (ctxt) {
              ctxt->keepBlanks = 0;
              ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
              ctxt->sax->comment = soap_Comment;
              ctxt->sax->warning = NULL;
              ctxt->sax->error = NULL;
              /*ctxt->sax->fatalError = NULL;*/
              xmlParseDocument(ctxt);
              if (ctxt->wellFormed) {
                     ret = ctxt->myDoc;
                     if (ret->URL == NULL && ctxt->directory != NULL) {
                            ret->URL = xmlCharStrdup(ctxt->directory);
                     }
              } else {
                     ret = NULL;
                     xmlFreeDoc(ctxt->myDoc);
                     ctxt->myDoc = NULL;
              }
              xmlFreeParserCtxt(ctxt);
       } else {
              ret = NULL;
       }

/*
       xmlCleanupParser();
*/

       if (ret) {
              cleanup_xml_node((xmlNodePtr)ret);
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

xmlDocPtr soap_xmlParseMemory ( const void *  buf,
size_t  buf_size 
)

Definition at line 126 of file php_xml.c.

{
       xmlParserCtxtPtr ctxt = NULL;
       xmlDocPtr ret;

/*
       xmlInitParser();
*/
       ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
       if (ctxt) {
              ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
              ctxt->sax->comment = soap_Comment;
              ctxt->sax->warning = NULL;
              ctxt->sax->error = NULL;
              /*ctxt->sax->fatalError = NULL;*/
#if LIBXML_VERSION >= 20703
              ctxt->options |= XML_PARSE_HUGE;
#endif
              xmlParseDocument(ctxt);
              if (ctxt->wellFormed) {
                     ret = ctxt->myDoc;
                     if (ret->URL == NULL && ctxt->directory != NULL) {
                            ret->URL = xmlCharStrdup(ctxt->directory);
                     }
              } else {
                     ret = NULL;
                     xmlFreeDoc(ctxt->myDoc);
                     ctxt->myDoc = NULL;
              }
              xmlFreeParserCtxt(ctxt);
       } else {
              ret = NULL;
       }

/*
       xmlCleanupParser();
*/

/*
       if (ret) {
              cleanup_xml_node((xmlNodePtr)ret);
       }
*/
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function: