replace a few lost lines

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34415 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-01-05 15:44:45 +00:00
parent 40f0d0425c
commit bcd94d6a14
3 changed files with 62 additions and 17 deletions

View file

@ -1,3 +1,9 @@
2012-01-05 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSXMLDocument.m:
* Source/NSXMLElement.m:
Replace a few lines accidentally lost.
2012-01-04 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Foundation/NSXMLDocument.h:

View file

@ -93,16 +93,24 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
GS_CREATE_INTERNAL(NSXMLDocument)
if ((self = [super initWithKind: NSXMLDocumentKind options: 0]) != nil)
{
NSXMLParser *parser = [[NSXMLParser alloc] initWithData: data];
if (parser != nil)
if (nil != data)
{
internal->standalone = YES;
internal->elementStack = [[NSMutableArray alloc] initWithCapacity: 10];
ASSIGN(internal->xmlData, data);
[parser setDelegate: self];
[parser parse];
RELEASE(parser);
NSXMLParser *parser = [[NSXMLParser alloc] initWithData: data];
if (nil == parser)
{
DESTROY(self);
}
else
{
internal->standalone = YES;
internal->elementStack
= [[NSMutableArray alloc] initWithCapacity: 10];
ASSIGN(internal->xmlData, data);
[parser setDelegate: self];
[parser parse];
RELEASE(parser);
}
}
}
return self;
@ -218,7 +226,7 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
{
[child setParent: self];
[(NSMutableArray *)internal->children insertObject: child atIndex: index];
internal->childrenHaveMutated = YES;
// internal->childrenHaveMutated = YES;
}
- (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index
@ -235,7 +243,7 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
- (void) removeChildAtIndex: (NSUInteger)index
{
[(NSMutableArray *)internal->children removeObjectAtIndex: index];
internal->childrenHaveMutated = YES;
// internal->childrenHaveMutated = YES;
}
- (void) setChildren: (NSArray*)children
@ -271,6 +279,26 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
return internal->xmlData;
}
- (NSString *) XMLStringWithOptions: (NSUInteger)options
{
NSMutableString *string = [NSMutableString string];
NSEnumerator *en = [internal->children objectEnumerator];
id obj = nil;
[string appendString: @"<?xml version=\"1.0\""];
if (YES == internal->standalone)
{
[string appendString: @" standalone=\"yes\""];
}
[string appendString: @"?>\n"];
while ((obj = [en nextObject]) != nil)
{
[string appendString: [obj XMLStringWithOptions: options]];
}
return string;
}
- (id) objectByApplyingXSLT: (NSData*)xslt
arguments: (NSDictionary*)arguments
error: (NSError**)error
@ -311,17 +339,18 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
qualifiedName: (NSString *)qualifiedName
attributes: (NSDictionary *)attributeDict
{
NSXMLElement *lastElement = [internal->elementStack lastObject];
NSXMLElement *currentElement =
[[NSXMLElement alloc] initWithName: elementName];
[lastElement addChild: currentElement];
[internal->elementStack addObject: currentElement];
[currentElement release];
if (internal->rootElement == nil)
{
[self setRootElement: currentElement];
}
[currentElement setAttributesAsDictionary:
attributeDict];
[currentElement setAttributesAsDictionary: attributeDict];
}
- (void)parser:(NSXMLParser *)parser

View file

@ -125,7 +125,16 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
- (void) setAttributesAsDictionary: (NSDictionary*)attributes
{
ASSIGN(internal->attributes, [attributes mutableCopy]);
NSEnumerator *en = [attributes keyEnumerator];
NSString *key;
while ((key = [en nextObject]) != nil)
{
NSString *val = [attributes objectForKey: key];
NSXMLNode *attribute = [NSXMLNode attributeWithName: key
stringValue: val];
[self addAttribute: attribute];
}
}
- (NSArray*) attributes
@ -214,13 +223,14 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
ASSIGN(internal->children, c);
[c release];
internal->childrenHaveMutated = YES;
// internal->childrenHaveMutated = YES;
}
- (void) addChild: (NSXMLNode*)child
{
[child setParent: self];
[internal->children addObject: child];
internal->childrenHaveMutated = YES;
// internal->childrenHaveMutated = YES;
}
- (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)node