mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
* 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:
parent
9a5f196bf1
commit
8f97e14738
4 changed files with 74 additions and 7 deletions
|
@ -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>
|
2012-01-03 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSException.m (-raise): Only set the stack when the
|
* Source/NSException.m (-raise): Only set the stack when the
|
||||||
|
|
|
@ -95,6 +95,7 @@
|
||||||
ASSIGN(_xmlData, data);
|
ASSIGN(_xmlData, data);
|
||||||
[parser setDelegate: self];
|
[parser setDelegate: self];
|
||||||
[parser parse];
|
[parser parse];
|
||||||
|
RELEASE(parser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
@ -294,8 +295,7 @@
|
||||||
NSXMLElement *currentElement =
|
NSXMLElement *currentElement =
|
||||||
[[NSXMLElement alloc] initWithName: elementName];
|
[[NSXMLElement alloc] initWithName: elementName];
|
||||||
|
|
||||||
[_elementStack insertObject: currentElement
|
[_elementStack addObject: currentElement];
|
||||||
atIndex: 0];
|
|
||||||
if (_rootElement == nil)
|
if (_rootElement == nil)
|
||||||
{
|
{
|
||||||
[self setRootElement: currentElement];
|
[self setRootElement: currentElement];
|
||||||
|
@ -312,10 +312,10 @@
|
||||||
{
|
{
|
||||||
if ([_elementStack count] > 0)
|
if ([_elementStack count] > 0)
|
||||||
{
|
{
|
||||||
NSXMLElement *currentElement = [_elementStack objectAtIndex: 0];
|
NSXMLElement *currentElement = [_elementStack lastObject];
|
||||||
if ([[currentElement name] isEqualToString: elementName])
|
if ([[currentElement name] isEqualToString: elementName])
|
||||||
{
|
{
|
||||||
[_elementStack removeObjectAtIndex: 0];
|
[_elementStack removeLastObject];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@
|
||||||
- (void) parser: (NSXMLParser *)parser
|
- (void) parser: (NSXMLParser *)parser
|
||||||
foundCharacters: (NSString *)string
|
foundCharacters: (NSString *)string
|
||||||
{
|
{
|
||||||
NSXMLElement *currentElement = [_elementStack objectAtIndex: 0];
|
NSXMLElement *currentElement = [_elementStack lastObject];
|
||||||
[currentElement setStringValue: string];
|
[currentElement setStringValue: string];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -213,5 +213,41 @@
|
||||||
[self notImplemented: _cmd];
|
[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
|
@end
|
||||||
|
|
||||||
|
|
|
@ -488,7 +488,22 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
|
||||||
|
|
||||||
- (NSString*) XMLStringWithOptions: (NSUInteger)options
|
- (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
|
- (void) setObjectValue: (id)value
|
||||||
|
@ -513,7 +528,14 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
|
||||||
|
|
||||||
- (void) setStringValue: (NSString*)string resolvingEntities: (BOOL)resolve
|
- (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
|
- (NSString*) XPath
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue