chregu          Mon Feb 23 10:43:49 2004 EDT

  Modified files:              
    /php-src/ext/xml    compat.c 
  Log:
  fix attribute handling in combination with sax2
  
  
http://cvs.php.net/diff.php/php-src/ext/xml/compat.c?r1=1.28&r2=1.29&ty=u
Index: php-src/ext/xml/compat.c
diff -u php-src/ext/xml/compat.c:1.28 php-src/ext/xml/compat.c:1.29
--- php-src/ext/xml/compat.c:1.28       Mon Feb 23 04:19:25 2004
+++ php-src/ext/xml/compat.c    Mon Feb 23 10:43:49 2004
@@ -71,13 +71,39 @@
 {
        XML_Parser  parser = (XML_Parser) user;
        xmlChar    *qualified_name = NULL;
-
+       xmlChar **attrs = NULL;
+       int i;
+       int z = 0;
+       int y = 0;
+       
        if (parser->h_start_element == NULL) {
                return;
        }
        _qualify_namespace(parser, name, URI, &qualified_name);
-       parser->h_start_element(parser->user, (const XML_Char *) qualified_name, 
(const XML_Char **) attributes);
-
+       
+       if (attributes != NULL) {
+               attrs = safe_emalloc((nb_attributes  * 2) + 1, sizeof(int *), 0);
+               xmlChar    *qualified_name_attr = NULL;
+               
+               for (i = 0; i < nb_attributes; i += 1) {
+                       attrs[z] =  xmlStrdup( attributes[y]);
+                       
+                       if (attributes[y+1] != NULL) {
+                               _qualify_namespace(parser, xmlStrndup(attributes[y + 
3] , (int) (attributes[y + 4] - attributes[y + 3])), attributes[2], 
&qualified_name_attr);
+                       } else {
+                               qualified_name_attr = xmlStrndup(attributes[y + 3] , 
(int) (attributes[y + 4] - attributes[y + 3]));
+                       }
+                       attrs[z + 1] = qualified_name_attr;
+                       z += 2;
+                       y += 5;
+               }
+               
+               attrs[z] = NULL;
+       }
+       parser->h_start_element(parser->user, (const XML_Char *) qualified_name, 
(const XML_Char **) attrs);
+       if (attrs) {
+               efree(attrs);
+       }
        xmlFree(qualified_name);
 }
 #endif

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to