* Source/NSXMLDocument.m: Change stack implementation to

use lastObject/removeLastObject to implement the stack instead
	of inserting and deleting at index 0.
	* Source/NSXMLElement.m: Implemented XMLStringWithOptions:
	* Source/NSXMLNode.m: Implemented XMLStringWithOptions:,
	skeletal implementation of setStringValue:resolvingEntities:



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34403 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2012-01-03 17:15:29 +00:00
parent c9e06e97fd
commit 7dc6ad72bd
4 changed files with 74 additions and 7 deletions

View file

@ -1,3 +1,12 @@
2012-01-03 12:06-EST Gregory John Casamento <greg.casamento@gmail.com>
* Source/NSXMLDocument.m: Change stack implementation to
use lastObject/removeLastObject to implement the stack instead
of inserting and deleting at index 0.
* Source/NSXMLElement.m: Implemented XMLStringWithOptions:
* Source/NSXMLNode.m: Implemented XMLStringWithOptions:,
skeletal implementation of setStringValue:resolvingEntities:
2012-01-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSException.m (-raise): Only set the stack when the

View file

@ -95,6 +95,7 @@
ASSIGN(_xmlData, data);
[parser setDelegate: self];
[parser parse];
RELEASE(parser);
}
}
return self;
@ -294,8 +295,7 @@
NSXMLElement *currentElement =
[[NSXMLElement alloc] initWithName: elementName];
[_elementStack insertObject: currentElement
atIndex: 0];
[_elementStack addObject: currentElement];
if (_rootElement == nil)
{
[self setRootElement: currentElement];
@ -312,10 +312,10 @@
{
if ([_elementStack count] > 0)
{
NSXMLElement *currentElement = [_elementStack objectAtIndex: 0];
NSXMLElement *currentElement = [_elementStack lastObject];
if ([[currentElement name] isEqualToString: elementName])
{
[_elementStack removeObjectAtIndex: 0];
[_elementStack removeLastObject];
}
}
}
@ -323,7 +323,7 @@
- (void) parser: (NSXMLParser *)parser
foundCharacters: (NSString *)string
{
NSXMLElement *currentElement = [_elementStack objectAtIndex: 0];
NSXMLElement *currentElement = [_elementStack lastObject];
[currentElement setStringValue: string];
}
@end

View file

@ -213,5 +213,41 @@
[self notImplemented: _cmd];
}
- (NSString *) XMLStringWithOptions: (NSUInteger)options
{
NSMutableString *result = [NSMutableString string];
NSEnumerator *en = nil;
id object = nil;
// XML Element open tag...
[result appendString: [NSString stringWithFormat: @"<%@",[self name]]];
// get the attributes...
en = [[self attributes] objectEnumerator];
while((object = [en nextObject]) != nil)
{
[result appendString: @" "];
[result appendString: [object XMLStringWithOptions: options]];
}
// close the brackets...
[result appendString: @">"];
[result appendString: [self stringValue]]; // need to escape entities...
// Iterate over the children...
en = [[self children] objectEnumerator];
while((object = [en nextObject]) != nil)
{
[result appendString: @" "];
[result appendString: [object XMLStringWithOptions: options]];
}
// Close the entire tag...
[result appendString: [NSString stringWithFormat: @"</%@>",[self name]]];
// return
return result;
}
@end

View file

@ -488,7 +488,22 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
- (NSString*) XMLStringWithOptions: (NSUInteger)options
{
return [self notImplemented: _cmd]; // FIXME ... generate from libxml
NSMutableString *returnValue = [NSMutableString string];
NSXMLNodeKind kind = [self kind];
if(kind == NSXMLAttributeKind)
{
[returnValue appendString: [self name]];
[returnValue appendString: @"=\""];
[returnValue appendString: [self stringValue]];
[returnValue appendString: @"\""];
}
else
{
// for all other types, do nothing for now...
}
return returnValue;
}
- (void) setObjectValue: (id)value
@ -513,7 +528,14 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
- (void) setStringValue: (NSString*)string resolvingEntities: (BOOL)resolve
{
[self notImplemented: _cmd]; // FIXME ... set in libxml
if(resolve == NO)
{
ASSIGN(_objectValue, string);
}
else
{
ASSIGN(_objectValue, string); // need to actually resolve entities...
}
}
- (NSString*) XPath