From 0c942d06e6fc9f39021f56f0d26ea1f04f39c0c4 Mon Sep 17 00:00:00 2001 From: Christian Stocker Date: Mon, 23 Feb 2004 15:43:49 +0000 Subject: [PATCH] fix attribute handling in combination with sax2 --- ext/xml/compat.c | 32 +++++++++++++++++++++++++++++--- 1 file 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 -- 2.50.1