diff --git a/Source/Additions/GSXML.m b/Source/Additions/GSXML.m index 2f7b1cc90..916b0de40 100644 --- a/Source/Additions/GSXML.m +++ b/Source/Additions/GSXML.m @@ -2827,12 +2827,11 @@ startElementNsFunction(void *ctx, const unsigned char *name, if (namespaces[pos] == 0) { - key = @"xmlns"; + key = @""; } else { - key = [@"xmlns:" stringByAppendingString: - UTF8Str(namespaces[pos])]; + key = UTF8Str(namespaces[pos]); } pos++; if (namespaces[pos] == 0) diff --git a/Source/NSXMLParser.m b/Source/NSXMLParser.m index 3ac9c716c..f27a882b8 100644 --- a/Source/NSXMLParser.m +++ b/Source/NSXMLParser.m @@ -26,6 +26,7 @@ #include "config.h" #include #include +#include #include #include #include @@ -74,6 +75,7 @@ NSString* const NSXMLParserErrorDomain = @"NSXMLParserErrorDomain"; prefix: (NSString*)prefix href: (NSString*)href attributes: (NSMutableDictionary*)elementAttributes + namespaces: (NSMutableDictionary*)elementNamespaces { NSString *qName = elementName; @@ -91,6 +93,33 @@ NSString* const NSXMLParserErrorDomain = @"NSXMLParserErrorDomain"; } else { + /* When we are not handling namespaces specially, any namespaces + * should appear as attributes of the element. + */ + if ([elementNamespaces count] > 0) + { + NSEnumerator *e = [elementNamespaces keyEnumerator]; + NSString *k; + + if (elementAttributes == nil) + { + elementAttributes = [NSMutableDictionary dictionary]; + } + while ((k = [e nextObject]) != nil) + { + NSString *v = [elementNamespaces objectForKey: k]; + + if ([k length] == 0) + { + [elementAttributes setObject: v forKey: @"xmlns"]; + } + else + { + k = [@"xmlns:" stringByAppendingString: k]; + [elementAttributes setObject: v forKey: k]; + } + } + } [_delegate parser: _owner didStartElement: qName namespaceURI: nil