mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Report namespace prefixes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26006 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2b48d85f2a
commit
bf4c6b6717
2 changed files with 63 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2008-01-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSXMLParser.m: Implement reporting of namespace
|
||||
prefixes with libxml2 based parser.
|
||||
|
||||
2008-01-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/NSXML.m: Fixup SAX interface to pass namespace
|
||||
|
|
|
@ -56,12 +56,29 @@ NSString* const NSXMLParserErrorDomain = @"NSXMLParserErrorDomain";
|
|||
BOOL _shouldProcessNamespaces;
|
||||
BOOL _shouldReportNamespacePrefixes;
|
||||
BOOL _shouldResolveExternalEntities;
|
||||
NSMutableArray *_namespaces;
|
||||
}
|
||||
- (void) _setOwner: (id)owner;
|
||||
@end
|
||||
|
||||
@implementation NSXMLSAXHandler
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
DESTROY(_namespaces);
|
||||
DESTROY(_lastError);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
_namespaces = [NSMutableArray new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) endDocument
|
||||
{
|
||||
[_delegate parserDidEndDocument: _owner];
|
||||
|
@ -83,6 +100,30 @@ NSString* const NSXMLParserErrorDomain = @"NSXMLParserErrorDomain";
|
|||
{
|
||||
qName = [NSString stringWithFormat: @"%@:%@", prefix, qName];
|
||||
}
|
||||
|
||||
if ([elementNamespaces count] > 0)
|
||||
{
|
||||
[_namespaces addObject: elementNamespaces];
|
||||
if (_shouldReportNamespacePrefixes)
|
||||
{
|
||||
NSEnumerator *e = [elementNamespaces keyEnumerator];
|
||||
NSString *k;
|
||||
|
||||
while ((k = [e nextObject]) != nil)
|
||||
{
|
||||
NSString *v = [elementNamespaces objectForKey: k];
|
||||
|
||||
[_delegate parser: _owner
|
||||
didStartMappingPrefix: k
|
||||
toURI: v];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[_namespaces addObject: [NSDictionary dictionary]];
|
||||
}
|
||||
|
||||
if (_shouldProcessNamespaces)
|
||||
{
|
||||
[_delegate parser: _owner
|
||||
|
@ -152,6 +193,23 @@ NSString* const NSXMLParserErrorDomain = @"NSXMLParserErrorDomain";
|
|||
namespaceURI: nil
|
||||
qualifiedName: nil];
|
||||
}
|
||||
|
||||
if (_shouldReportNamespacePrefixes)
|
||||
{
|
||||
NSDictionary *d = [_namespaces lastObject];
|
||||
|
||||
if ([d count] > 0)
|
||||
{
|
||||
NSEnumerator *e = [d keyEnumerator];
|
||||
NSString *k;
|
||||
|
||||
while ((k = [e nextObject]) != nil)
|
||||
{
|
||||
[_delegate parser: _owner didEndMappingPrefix: k];
|
||||
}
|
||||
}
|
||||
}
|
||||
[_namespaces removeLastObject];
|
||||
}
|
||||
- (void) attribute: (NSString*) name value: (NSString*)value
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue