diff options
author | Christian Stocker <chregu@php.net> | 2004-02-23 15:43:49 +0000 |
---|---|---|
committer | Christian Stocker <chregu@php.net> | 2004-02-23 15:43:49 +0000 |
commit | 0c942d06e6fc9f39021f56f0d26ea1f04f39c0c4 (patch) | |
tree | 287e75186d9a330aad33aa4424f634b74e366057 /ext/xml/compat.c | |
parent | 2fdd9a9757b7f5ea2c48d417fa5f7b7ed504f42c (diff) | |
download | php-git-0c942d06e6fc9f39021f56f0d26ea1f04f39c0c4.tar.gz |
fix attribute handling in combination with sax2
Diffstat (limited to 'ext/xml/compat.c')
-rw-r--r-- | ext/xml/compat.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/ext/xml/compat.c b/ext/xml/compat.c index 57b5f764a4..5c3f903835 100644 --- a/ext/xml/compat.c +++ b/ext/xml/compat.c @@ -71,13 +71,39 @@ _start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix { 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 |