mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Merge pull request #405 from gnustep/small_xml_fixes
Two small xml fixes
This commit is contained in:
commit
0935f77d8f
5 changed files with 83 additions and 3 deletions
|
@ -362,7 +362,16 @@ extern void ensure_oldNs(xmlNodePtr node);
|
|||
NSEnumerator *enumerator = [attributes objectEnumerator];
|
||||
NSXMLNode *attribute;
|
||||
|
||||
// FIXME: Remove all previous attributes
|
||||
// Remove all previous attributes
|
||||
NSArray *currentAttributes = [self attributes];
|
||||
int index;
|
||||
for (index = [currentAttributes count]-1; index >= 0; index--)
|
||||
{
|
||||
NSXMLNode *attrNode = [currentAttributes objectAtIndex:index];
|
||||
NSString *name = [attrNode name];
|
||||
[self removeAttributeForName:name];
|
||||
}
|
||||
|
||||
while ((attribute = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[self addAttribute: attribute];
|
||||
|
@ -379,7 +388,16 @@ extern void ensure_oldNs(xmlNodePtr node);
|
|||
NSEnumerator *en = [attributes keyEnumerator];
|
||||
NSString *key;
|
||||
|
||||
// FIXME: Remove all previous attributes
|
||||
// Remove all previous attributes
|
||||
NSArray *currentAttributes = [self attributes];
|
||||
int index;
|
||||
for (index = [currentAttributes count]-1; index >= 0; index--)
|
||||
{
|
||||
NSXMLNode *attrNode = [currentAttributes objectAtIndex:index];
|
||||
NSString *name = [attrNode name];
|
||||
[self removeAttributeForName:name];
|
||||
}
|
||||
|
||||
while ((key = [en nextObject]) != nil)
|
||||
{
|
||||
NSString *val = [[attributes objectForKey: key] stringValue];
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#define GSInternal NSXMLNodeInternal
|
||||
|
||||
#import "Foundation/NSCharacterSet.h"
|
||||
#import "Foundation/NSError.h"
|
||||
#import "NSXMLPrivate.h"
|
||||
#import "GSInternal.h"
|
||||
GS_PRIVATE_INTERNAL(NSXMLNode)
|
||||
|
@ -826,6 +827,14 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
|
|||
if (xpathObj == NULL)
|
||||
{
|
||||
NSLog(@"Error: unable to evaluate xpath expression \"%s\"", xpathExpr);
|
||||
if (error != 0)
|
||||
{
|
||||
xmlError xmlError = xpathCtx->lastError;
|
||||
NSString *message = [NSString stringWithFormat:@"Error: unable to evaluate xpath expression \"%s\" (%d)", xpathExpr, xmlError.code];
|
||||
*error = [NSError errorWithDomain: @"LibXMLErrorDomain"
|
||||
code: xmlError.code
|
||||
userInfo: [NSDictionary dictionaryWithObject:message forKey:NSLocalizedDescriptionKey]];
|
||||
}
|
||||
xmlXPathFreeContext(xpathCtx);
|
||||
return nil;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue