Back to index

php5  5.3.10
Classes | Defines | Typedefs | Functions | Variables
xml_element.c File Reference
#include "ext/xml/expat_compat.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "xml_element.h"
#include "queue.h"
#include "encodings.h"

Go to the source code of this file.

Classes

struct  _xml_elem_data

Defines

#define my_free(thing)   if(thing) {free(thing); thing = NULL;}
#define XML_DECL_START   "<?xml"
#define XML_DECL_START_LEN   sizeof(XML_DECL_START) - 1
#define XML_DECL_VERSION   "version=\"1.0\""
#define XML_DECL_VERSION_LEN   sizeof(XML_DECL_VERSION) - 1
#define XML_DECL_ENCODING_ATTR   "encoding"
#define XML_DECL_ENCODING_ATTR_LEN   sizeof(XML_DECL_ENCODING_ATTR) - 1
#define XML_DECL_ENCODING_DEFAULT   "utf-8"
#define XML_DECL_ENCODING_DEFAULT_LEN   sizeof(XML_DECL_ENCODING_DEFAULT) - 1
#define XML_DECL_END   "?>"
#define XML_DECL_END_LEN   sizeof(XML_DECL_END) - 1
#define START_TOKEN_BEGIN   "<"
#define START_TOKEN_BEGIN_LEN   sizeof(START_TOKEN_BEGIN) - 1
#define START_TOKEN_END   ">"
#define START_TOKEN_END_LEN   sizeof(START_TOKEN_END) - 1
#define EMPTY_START_TOKEN_END   "/>"
#define EMPTY_START_TOKEN_END_LEN   sizeof(EMPTY_START_TOKEN_END) - 1
#define END_TOKEN_BEGIN   "</"
#define END_TOKEN_BEGIN_LEN   sizeof(END_TOKEN_BEGIN) - 1
#define END_TOKEN_END   ">"
#define END_TOKEN_END_LEN   sizeof(END_TOKEN_END) - 1
#define ATTR_DELIMITER   "\""
#define ATTR_DELIMITER_LEN   sizeof(ATTR_DELIMITER) - 1
#define CDATA_BEGIN   "<![CDATA["
#define CDATA_BEGIN_LEN   sizeof(CDATA_BEGIN) - 1
#define CDATA_END   "]]>"
#define CDATA_END_LEN   sizeof(CDATA_END) - 1
#define EQUALS   "="
#define EQUALS_LEN   sizeof(EQUALS) - 1
#define WHITESPACE   " "
#define WHITESPACE_LEN   sizeof(WHITESPACE) - 1
#define NEWLINE   "\n"
#define NEWLINE_LEN   sizeof(NEWLINE) - 1
#define MAX_VAL_BUF   144
#define SCALAR_STR   "SCALAR"
#define SCALAR_STR_LEN   sizeof(SCALAR_STR) - 1
#define VECTOR_STR   "VECTOR"
#define VECTOR_STR_LEN   sizeof(VECTOR_STR) - 1
#define RESPONSE_STR   "RESPONSE"
#define RESPONSE_STR_LEN   sizeof(RESPONSE_STR) - 1
#define non_ascii(c)   (c > 127)
#define non_print(c)   (!isprint(c))
#define markup(c)   (c == '&' || c == '\"' || c == '>' || c == '<')
#define entity_length(c)   ( (c >= 100) ? 3 : ((c >= 10) ? 2 : 1) ) + 3; /* "&#" + c + ";" */
#define should_escape(c, flag)

Typedefs

typedef struct _xml_elem_data xml_elem_data

Functions

void xml_elem_free_non_recurse (xml_element *root)
void xml_elem_free (xml_element *root)
xml_elementxml_elem_new ()
static int xml_elem_writefunc (int(*fptr)(void *data, const char *text, int size), const char *text, void *data, int len)
static int create_xml_escape (char *pString, unsigned char c)
static char * xml_elem_entity_escape (const char *buf, int old_len, int *newlen, XML_ELEM_ESCAPING flags)
static void xml_element_serialize (xml_element *el, int(*fptr)(void *data, const char *text, int size), void *data, XML_ELEM_OUTPUT_OPTIONS options, int depth)
static int file_out_fptr (void *f, const char *text, int size)
static int simplestring_out_fptr (void *f, const char *text, int size)
char * xml_elem_serialize_to_string (xml_element *el, XML_ELEM_OUTPUT_OPTIONS options, int *buf_len)
void xml_elem_serialize_to_stream (xml_element *el, FILE *output, XML_ELEM_OUTPUT_OPTIONS options)
static void _xmlrpc_startElement (void *userData, const char *name, const char **attrs)
static void _xmlrpc_endElement (void *userData, const char *name)
static void _xmlrpc_charHandler (void *userData, const char *s, int len)
xml_elementxml_elem_parse_buf (const char *in_buf, int len, XML_ELEM_INPUT_OPTIONS options, XML_ELEM_ERROR error)

Variables

static const char rcsid [] = "#(@) $Id: xml_element.c 271367 2008-12-17 00:30:27Z iliaa $"

Class Documentation

struct _xml_elem_data

Definition at line 586 of file xml_element.c.

Collaboration diagram for _xml_elem_data:
Class Members
xml_element * current
XML_ELEM_INPUT_OPTIONS input_options
int needs_enc_conversion
xml_element * root

Define Documentation

#define ATTR_DELIMITER   "\""

Definition at line 155 of file xml_element.c.

#define ATTR_DELIMITER_LEN   sizeof(ATTR_DELIMITER) - 1

Definition at line 156 of file xml_element.c.

#define CDATA_BEGIN   "<![CDATA["

Definition at line 157 of file xml_element.c.

#define CDATA_BEGIN_LEN   sizeof(CDATA_BEGIN) - 1

Definition at line 158 of file xml_element.c.

#define CDATA_END   "]]>"

Definition at line 159 of file xml_element.c.

#define CDATA_END_LEN   sizeof(CDATA_END) - 1

Definition at line 160 of file xml_element.c.

#define EMPTY_START_TOKEN_END   "/>"

Definition at line 149 of file xml_element.c.

Definition at line 150 of file xml_element.c.

#define END_TOKEN_BEGIN   "</"

Definition at line 151 of file xml_element.c.

#define END_TOKEN_BEGIN_LEN   sizeof(END_TOKEN_BEGIN) - 1

Definition at line 152 of file xml_element.c.

#define END_TOKEN_END   ">"

Definition at line 153 of file xml_element.c.

#define END_TOKEN_END_LEN   sizeof(END_TOKEN_END) - 1

Definition at line 154 of file xml_element.c.

#define entity_length (   c)    ( (c >= 100) ? 3 : ((c >= 10) ? 2 : 1) ) + 3; /* "&#" + c + ";" */

Definition at line 307 of file xml_element.c.

#define EQUALS   "="

Definition at line 161 of file xml_element.c.

#define EQUALS_LEN   sizeof(EQUALS) - 1

Definition at line 162 of file xml_element.c.

#define markup (   c)    (c == '&' || c == '\"' || c == '>' || c == '<')

Definition at line 306 of file xml_element.c.

#define MAX_VAL_BUF   144

Definition at line 167 of file xml_element.c.

#define my_free (   thing)    if(thing) {free(thing); thing = NULL;}

Definition at line 133 of file xml_element.c.

#define NEWLINE   "\n"

Definition at line 165 of file xml_element.c.

#define NEWLINE_LEN   sizeof(NEWLINE) - 1

Definition at line 166 of file xml_element.c.

#define non_ascii (   c)    (c > 127)

Definition at line 304 of file xml_element.c.

#define non_print (   c)    (!isprint(c))

Definition at line 305 of file xml_element.c.

#define RESPONSE_STR   "RESPONSE"

Definition at line 172 of file xml_element.c.

#define RESPONSE_STR_LEN   sizeof(RESPONSE_STR) - 1

Definition at line 173 of file xml_element.c.

#define SCALAR_STR   "SCALAR"

Definition at line 168 of file xml_element.c.

#define SCALAR_STR_LEN   sizeof(SCALAR_STR) - 1

Definition at line 169 of file xml_element.c.

#define should_escape (   c,
  flag 
)
Value:
( ((flag & xml_elem_markup_escaping) && markup(c)) || \
                                 ((flag & xml_elem_non_ascii_escaping) && non_ascii(c)) || \
                                 ((flag & xml_elem_non_print_escaping) && non_print(c)) )
#define START_TOKEN_BEGIN   "<"

Definition at line 145 of file xml_element.c.

#define START_TOKEN_BEGIN_LEN   sizeof(START_TOKEN_BEGIN) - 1

Definition at line 146 of file xml_element.c.

#define START_TOKEN_END   ">"

Definition at line 147 of file xml_element.c.

#define START_TOKEN_END_LEN   sizeof(START_TOKEN_END) - 1

Definition at line 148 of file xml_element.c.

#define VECTOR_STR   "VECTOR"

Definition at line 170 of file xml_element.c.

#define VECTOR_STR_LEN   sizeof(VECTOR_STR) - 1

Definition at line 171 of file xml_element.c.

#define WHITESPACE   " "

Definition at line 163 of file xml_element.c.

#define WHITESPACE_LEN   sizeof(WHITESPACE) - 1

Definition at line 164 of file xml_element.c.

#define XML_DECL_ENCODING_ATTR   "encoding"

Definition at line 139 of file xml_element.c.

Definition at line 140 of file xml_element.c.

#define XML_DECL_ENCODING_DEFAULT   "utf-8"

Definition at line 141 of file xml_element.c.

Definition at line 142 of file xml_element.c.

#define XML_DECL_END   "?>"

Definition at line 143 of file xml_element.c.

#define XML_DECL_END_LEN   sizeof(XML_DECL_END) - 1

Definition at line 144 of file xml_element.c.

#define XML_DECL_START   "<?xml"

Definition at line 135 of file xml_element.c.

#define XML_DECL_START_LEN   sizeof(XML_DECL_START) - 1

Definition at line 136 of file xml_element.c.

#define XML_DECL_VERSION   "version=\"1.0\""

Definition at line 137 of file xml_element.c.

#define XML_DECL_VERSION_LEN   sizeof(XML_DECL_VERSION) - 1

Definition at line 138 of file xml_element.c.


Typedef Documentation

typedef struct _xml_elem_data xml_elem_data

Function Documentation

static void _xmlrpc_charHandler ( void *  userData,
const char *  s,
int  len 
) [static]

Definition at line 635 of file xml_element.c.

{
   xml_elem_data* mydata = (xml_elem_data*)userData;
   if(mydata && mydata->current) {

      /* Check if we need to decode utf-8 parser output to another encoding */
      if(mydata->needs_enc_conversion && mydata->input_options->encoding) {
         int new_len = 0;
         char* add_text = utf8_decode(s, len, &new_len, mydata->input_options->encoding);
         if(add_text) {
            len = new_len;
            simplestring_addn(&mydata->current->text, add_text, len);
            free(add_text);
            return;
         }
      }
      simplestring_addn(&mydata->current->text, s, len);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void _xmlrpc_endElement ( void *  userData,
const char *  name 
) [static]

Definition at line 623 of file xml_element.c.

{
   xml_elem_data* mydata = (xml_elem_data*)userData;

   if(mydata && mydata->current && mydata->current->parent) {
      Q_PushTail(&mydata->current->parent->children, mydata->current);

      mydata->current = mydata->current->parent;
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void _xmlrpc_startElement ( void *  userData,
const char *  name,
const char **  attrs 
) [static]

Definition at line 595 of file xml_element.c.

{
   xml_element *c;
   xml_elem_data* mydata = (xml_elem_data*)userData;
   const char** p = attrs;

   if(mydata) {
      c = mydata->current;

      mydata->current = xml_elem_new();
      mydata->current->name = (char*)strdup(name);
      mydata->current->parent = c;

      /* init attrs */
      while(p && *p) {
         xml_element_attr* attr = malloc(sizeof(xml_element_attr));
         if(attr) {
            attr->key = strdup(*p);
            attr->val = strdup(*(p+1));
            Q_PushTail(&mydata->current->attrs, attr);

            p += 2;
         }
      }
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int create_xml_escape ( char *  pString,
unsigned char  c 
) [static]

Definition at line 286 of file xml_element.c.

{ 
  int counter = 0;

  pString[counter++] = '&';
  pString[counter++] = '#';
  if(c >= 100) {
    pString[counter++] = c / 100 + '0';
    c = c % 100;
  }
  pString[counter++] = c / 10 + '0';
  c = c % 10;

  pString[counter++] = c + '0';
  pString[counter++] = ';';
  return counter; 
}

Here is the caller graph for this function:

static int file_out_fptr ( void *  f,
const char *  text,
int  size 
) [static]

Definition at line 502 of file xml_element.c.

{
   fputs(text, (FILE *)f);
   return 0;
}

Here is the caller graph for this function:

static int simplestring_out_fptr ( void *  f,
const char *  text,
int  size 
) [static]

Definition at line 509 of file xml_element.c.

{
   simplestring* buf = (simplestring*)f;
   if(buf) {
      simplestring_addn(buf, text, size);
   }
   return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static char* xml_elem_entity_escape ( const char *  buf,
int  old_len,
int newlen,
XML_ELEM_ESCAPING  flags 
) [static]

Definition at line 324 of file xml_element.c.

                                                                                                        {
  char *pRetval = 0;
  int iNewBufLen=0;

#define should_escape(c, flag) ( ((flag & xml_elem_markup_escaping) && markup(c)) || \
                                 ((flag & xml_elem_non_ascii_escaping) && non_ascii(c)) || \
                                 ((flag & xml_elem_non_print_escaping) && non_print(c)) )

  if(buf && *buf) {
    const unsigned char *bufcopy;
    char *NewBuffer;
    int ToBeXmlEscaped=0;
    int iLength;
    bufcopy = buf;
    iLength= old_len ? old_len : strlen(buf);
    while(*bufcopy) {
      if( should_escape(*bufcopy, flags) ) {
       /* the length will increase by length of xml escape - the character length */
       iLength += entity_length(*bufcopy);
       ToBeXmlEscaped=1;
      }
      bufcopy++;
    }

    if(ToBeXmlEscaped) {

      NewBuffer= malloc(iLength+1);
      if(NewBuffer) {
       bufcopy=buf;
       while(*bufcopy) {
         if(should_escape(*bufcopy, flags)) {
           iNewBufLen += create_xml_escape(NewBuffer+iNewBufLen,*bufcopy);
         }
         else {
           NewBuffer[iNewBufLen++]=*bufcopy;
         }
         bufcopy++;
       }
       NewBuffer[iNewBufLen] = 0;
       pRetval = NewBuffer;
      }
    }
  }

  if(newlen) {
     *newlen = iNewBufLen;
  }

  return pRetval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void xml_elem_free ( xml_element root)

Definition at line 236 of file xml_element.c.

                                      {
   if(root) {
      xml_element* kids = Q_Head(&root->children);
      while(kids) {
         xml_elem_free(kids);
         kids = Q_Next(&root->children);
      }
      xml_elem_free_non_recurse(root);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 197 of file xml_element.c.

                                                  {
   if(root) {
      xml_element_attr* attrs = Q_Head(&root->attrs);
      while(attrs) {
         my_free(attrs->key);
         my_free(attrs->val);
         my_free(attrs);
         attrs = Q_Next(&root->attrs);
      }

      Q_Destroy(&root->children);
      Q_Destroy(&root->attrs);
      if(root->name) {
          free((char *)root->name);
          root->name = NULL;
      }
      simplestring_free(&root->text);
      my_free(root);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 265 of file xml_element.c.

                            {
   xml_element* elem = calloc(1, sizeof(xml_element));
   if(elem) {
      Q_Init(&elem->children);
      Q_Init(&elem->attrs);
      simplestring_init(&elem->text);

      /* init empty string in case we don't find any char data */
      simplestring_addn(&elem->text, "", 0);
   }
   return elem;
}

Here is the call graph for this function:

Here is the caller graph for this function:

xml_element* xml_elem_parse_buf ( const char *  in_buf,
int  len,
XML_ELEM_INPUT_OPTIONS  options,
XML_ELEM_ERROR  error 
)

Definition at line 687 of file xml_element.c.

{
   xml_element* xReturn = NULL;
   char buf[100] = "";
   static STRUCT_XML_ELEM_INPUT_OPTIONS default_opts = {encoding_utf_8};

   if(!options) {
      options = &default_opts;
   }

   if(in_buf) {
      XML_Parser parser;
      xml_elem_data mydata = {0};

      parser = XML_ParserCreate(NULL);

      mydata.root = xml_elem_new();
      mydata.current = mydata.root;
      mydata.input_options = options;
      mydata.needs_enc_conversion = options->encoding && strcmp(options->encoding, encoding_utf_8);

      XML_SetElementHandler(parser, (XML_StartElementHandler)_xmlrpc_startElement, (XML_EndElementHandler)_xmlrpc_endElement);
      XML_SetCharacterDataHandler(parser, (XML_CharacterDataHandler)_xmlrpc_charHandler);

      /* pass the xml_elem_data struct along */
      XML_SetUserData(parser, (void*)&mydata);

      if(!len) {
         len = strlen(in_buf);
      }

      /* parse the XML */
      if(XML_Parse(parser, in_buf, len, 1) == 0) {
         enum XML_Error err_code = XML_GetErrorCode(parser);
         int line_num = XML_GetCurrentLineNumber(parser);
         int col_num = XML_GetCurrentColumnNumber(parser);
         long byte_idx = XML_GetCurrentByteIndex(parser);
/*         int byte_total = XML_GetCurrentByteCount(parser); */
         const char * error_str = XML_ErrorString(err_code);
         if(byte_idx >= 0) {
             snprintf(buf, 
                      sizeof(buf),
                      "\n\tdata beginning %ld before byte index: %s\n",
                      byte_idx > 10  ? 10 : byte_idx,
                      in_buf + (byte_idx > 10 ? byte_idx - 10 : byte_idx));
         }
/*
         fprintf(stderr, "expat reports error code %i\n"
                "\tdescription: %s\n"
                "\tline: %i\n"
                "\tcolumn: %i\n"
                "\tbyte index: %ld\n"
                "\ttotal bytes: %i\n%s ",
                err_code, error_str, line_num, 
                col_num, byte_idx, byte_total, buf);
*/

          /* error condition */
          if(error) {
              error->parser_code = (long)err_code;
              error->line = line_num;
              error->column = col_num;
              error->byte_index = byte_idx;
              error->parser_error = error_str;
          }
      }
      else {
         xReturn = (xml_element*)Q_Head(&mydata.root->children);
         xReturn->parent = NULL;
      }

      XML_ParserFree(parser);


      xml_elem_free_non_recurse(mydata.root);
   }

   return xReturn;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void xml_elem_serialize_to_stream ( xml_element el,
FILE *  output,
XML_ELEM_OUTPUT_OPTIONS  options 
)

Definition at line 571 of file xml_element.c.

{
   xml_element_serialize(el, file_out_fptr, (void *)output, options, 0);
}

Here is the call graph for this function:

char* xml_elem_serialize_to_string ( xml_element el,
XML_ELEM_OUTPUT_OPTIONS  options,
int buf_len 
)

Definition at line 537 of file xml_element.c.

{
   simplestring buf;
   simplestring_init(&buf);

   xml_element_serialize(el, simplestring_out_fptr, (void *)&buf, options, 0);

   if(buf_len) {
      *buf_len = buf.len;
   }

   return buf.str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int xml_elem_writefunc ( int(*)(void *data, const char *text, int size)  fptr,
const char *  text,
void *  data,
int  len 
) [static]

Definition at line 279 of file xml_element.c.

{
   return fptr && text ? fptr(data, text, len ? len : strlen(text)) : 0;
}

Here is the caller graph for this function:

static void xml_element_serialize ( xml_element el,
int(*)(void *data, const char *text, int size)  fptr,
void *  data,
XML_ELEM_OUTPUT_OPTIONS  options,
int  depth 
) [static]

Definition at line 376 of file xml_element.c.

{
   int i;
   static STRUCT_XML_ELEM_OUTPUT_OPTIONS default_opts = {xml_elem_pretty, xml_elem_markup_escaping | xml_elem_non_print_escaping, XML_DECL_ENCODING_DEFAULT};
   static char whitespace[] = "                                                                                               "
                              "                                                                                               "
                              "                                                                                               ";
   depth++;

   if(!el) {
      /* fprintf(stderr, "Nothing to write\n"); */
      return;
   }
   if(!options) {
      options = &default_opts;
   }

   /* print xml declaration if at root level */
   if(depth == 1) {
      xml_elem_writefunc(fptr, XML_DECL_START, data, XML_DECL_START_LEN);
      xml_elem_writefunc(fptr, WHITESPACE, data, WHITESPACE_LEN);
      xml_elem_writefunc(fptr, XML_DECL_VERSION, data, XML_DECL_VERSION_LEN);
      if(options->encoding && *options->encoding) {
          xml_elem_writefunc(fptr, WHITESPACE, data, WHITESPACE_LEN);
          xml_elem_writefunc(fptr, XML_DECL_ENCODING_ATTR, data, XML_DECL_ENCODING_ATTR_LEN);
          xml_elem_writefunc(fptr, EQUALS, data, EQUALS_LEN);
          xml_elem_writefunc(fptr, ATTR_DELIMITER, data, ATTR_DELIMITER_LEN);
          xml_elem_writefunc(fptr, options->encoding, data, 0);
          xml_elem_writefunc(fptr, ATTR_DELIMITER, data, ATTR_DELIMITER_LEN);
      }
      xml_elem_writefunc(fptr, XML_DECL_END, data, XML_DECL_END_LEN);
      if(options->verbosity != xml_elem_no_white_space) {
         xml_elem_writefunc(fptr, NEWLINE, data, NEWLINE_LEN);
      }
   }

   if(options->verbosity == xml_elem_pretty && depth > 2) {
         xml_elem_writefunc(fptr, whitespace, data, depth - 2);
   }
   /* begin element */
   xml_elem_writefunc(fptr,START_TOKEN_BEGIN, data, START_TOKEN_BEGIN_LEN);
   if(el->name) {
      xml_elem_writefunc(fptr, el->name, data, 0);

      /* write attrs, if any */
      if(Q_Size(&el->attrs)) {
         xml_element_attr* iter = Q_Head(&el->attrs);
         while( iter ) {
            xml_elem_writefunc(fptr, WHITESPACE, data, WHITESPACE_LEN);
            xml_elem_writefunc(fptr, iter->key, data, 0);
            xml_elem_writefunc(fptr, EQUALS, data, EQUALS_LEN);
            xml_elem_writefunc(fptr, ATTR_DELIMITER, data, ATTR_DELIMITER_LEN);
            xml_elem_writefunc(fptr, iter->val, data, 0);
            xml_elem_writefunc(fptr, ATTR_DELIMITER, data, ATTR_DELIMITER_LEN);

            iter = Q_Next(&el->attrs);
         }
      }
   }
   else {
      xml_elem_writefunc(fptr, "None", data, 0);
   }
   /* if no text and no children, use abbreviated form, eg: <foo/> */
   if(!el->text.len && !Q_Size(&el->children)) {
       xml_elem_writefunc(fptr, EMPTY_START_TOKEN_END, data, EMPTY_START_TOKEN_END_LEN);
   }
   /* otherwise, print element contents */
   else {
       xml_elem_writefunc(fptr, START_TOKEN_END, data, START_TOKEN_END_LEN);

       /* print text, if any */
       if(el->text.len) {
          char* escaped_str = el->text.str;
          int buflen = el->text.len;

          if(options->escaping && options->escaping != xml_elem_cdata_escaping) {
             escaped_str = xml_elem_entity_escape(el->text.str, buflen, &buflen, options->escaping );
             if(!escaped_str) {
                escaped_str = el->text.str;
             }
          }

          if(options->escaping & xml_elem_cdata_escaping) {
             xml_elem_writefunc(fptr, CDATA_BEGIN, data, CDATA_BEGIN_LEN);
          }

          xml_elem_writefunc(fptr, escaped_str, data, buflen);

          if(escaped_str != el->text.str) {
             my_free(escaped_str);
          }

          if(options->escaping & xml_elem_cdata_escaping) {
             xml_elem_writefunc(fptr, CDATA_END, data, CDATA_END_LEN);
          }
       }
       /* no text, so print child elems */
       else {
          xml_element *kids = Q_Head(&el->children);
          i = 0;
          while( kids ) {
             if(i++ == 0) {
                if(options->verbosity != xml_elem_no_white_space) {
                   xml_elem_writefunc(fptr, NEWLINE, data, NEWLINE_LEN);
                }
             }
             xml_element_serialize(kids, fptr, data, options, depth);
             kids = Q_Next(&el->children);
          }
          if(i) {
             if(options->verbosity == xml_elem_pretty && depth > 2) {
                   xml_elem_writefunc(fptr, whitespace, data, depth - 2);
             }
          }
       }

       xml_elem_writefunc(fptr, END_TOKEN_BEGIN, data, END_TOKEN_BEGIN_LEN);
       xml_elem_writefunc(fptr,el->name ? el->name : "None", data, 0);
       xml_elem_writefunc(fptr, END_TOKEN_END, data, END_TOKEN_END_LEN);
   }
   if(options->verbosity != xml_elem_no_white_space) {
      xml_elem_writefunc(fptr, NEWLINE, data, NEWLINE_LEN);
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const char rcsid[] = "#(@) $Id: xml_element.c 271367 2008-12-17 00:30:27Z iliaa $" [static]

Definition at line 34 of file xml_element.c.