mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
* Source/NSXMLDocument.m
* Source/NSXMLElement.m * Source/NSXMLNode.m: Make all tests pass, correct child issues. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/nsxml_using_libxml2@34605 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0262025e3b
commit
49b12261cd
4 changed files with 51 additions and 78 deletions
|
@ -1,3 +1,10 @@
|
|||
2012-01-21 06:16-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/NSXMLDocument.m
|
||||
* Source/NSXMLElement.m
|
||||
* Source/NSXMLNode.m: Make all tests pass, correct child
|
||||
issues.
|
||||
|
||||
2012-01-18 16:21-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/NSXMLNode.m: fixes for issues found in GNUstep unit
|
||||
|
|
|
@ -269,11 +269,12 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
|
||||
- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index
|
||||
{
|
||||
NSXMLNodeKind kind;
|
||||
NSXMLNode *next = nil;
|
||||
xmlNodePtr nextNode = NULL;
|
||||
xmlNodePtr newNode = NULL;
|
||||
xmlNodePtr prevNode = NULL;
|
||||
NSXMLNodeKind kind = [child kind];
|
||||
NSXMLNode *cur = nil;
|
||||
xmlNodePtr curNode = NULL;
|
||||
xmlNodePtr thisNode = (xmlNodePtr)[self _node];
|
||||
xmlNodePtr childNode = (xmlNodePtr)[child _node];
|
||||
NSUInteger childCount = [self childCount];
|
||||
|
||||
// Check to make sure this is a valid addition...
|
||||
NSAssert(nil != child, NSInvalidArgumentException);
|
||||
|
@ -289,40 +290,22 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
NSAssert(NSXMLNamespaceKind != kind, NSInvalidArgumentException);
|
||||
NSAssert(NSXMLNotationDeclarationKind != kind, NSInvalidArgumentException);
|
||||
|
||||
|
||||
// Get all of the nodes...
|
||||
newNode = ((xmlNodePtr)[child _node]);
|
||||
next = [self childAtIndex: index];
|
||||
nextNode = ((xmlNodePtr)[next _node]);
|
||||
if(nextNode != NULL)
|
||||
{
|
||||
prevNode = nextNode->prev;
|
||||
}
|
||||
else if(index > 0)
|
||||
{
|
||||
prevNode = (xmlNodePtr)[[self childAtIndex: index - 1] _node];
|
||||
}
|
||||
childNode = ((xmlNodePtr)[child _node]);
|
||||
cur = [self childAtIndex: index];
|
||||
curNode = ((xmlNodePtr)[cur _node]);
|
||||
|
||||
// Make all of the links...
|
||||
/*
|
||||
if(prevNode != NULL)
|
||||
if(0 == childCount || index == childCount)
|
||||
{
|
||||
prevNode = nextNode;
|
||||
xmlAddChild(thisNode, childNode);
|
||||
}
|
||||
*/
|
||||
newNode->next = nextNode;
|
||||
newNode->prev = prevNode;
|
||||
if(nextNode != NULL)
|
||||
else if(index < childCount)
|
||||
{
|
||||
nextNode->prev = newNode;
|
||||
xmlAddNextSibling(curNode, childNode);
|
||||
}
|
||||
|
||||
if(MY_DOC->children == NULL)
|
||||
{
|
||||
MY_DOC->children = newNode;
|
||||
}
|
||||
|
||||
((xmlNodePtr)[child _node])->parent = [self _node];
|
||||
GSIVar(child, parent) = self;
|
||||
|
||||
[self _addSubNode:child];
|
||||
}
|
||||
|
||||
- (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index
|
||||
|
|
|
@ -239,16 +239,15 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
- (void) setObjectValue: (id)value
|
||||
{
|
||||
if (nil == value)
|
||||
if(nil == value)
|
||||
{
|
||||
value = @""; // May not be nil
|
||||
ASSIGN(internal->objectValue, [NSString stringWithString: @""]);
|
||||
return;
|
||||
}
|
||||
ASSIGN(internal->objectValue, value);
|
||||
}
|
||||
*/
|
||||
|
||||
- (NSArray*) namespaces
|
||||
{
|
||||
|
@ -290,10 +289,10 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index
|
||||
{
|
||||
NSXMLNodeKind kind = [child kind];
|
||||
NSXMLNode *next = nil;
|
||||
xmlNodePtr nextNode = NULL;
|
||||
xmlNodePtr newNode = NULL;
|
||||
xmlNodePtr prevNode = NULL;
|
||||
NSXMLNode *cur = nil;
|
||||
xmlNodePtr curNode = NULL;
|
||||
xmlNodePtr thisNode = (xmlNodePtr)[self _node];
|
||||
xmlNodePtr childNode = (xmlNodePtr)[child _node];
|
||||
NSUInteger childCount = [self childCount];
|
||||
|
||||
// Check to make sure this is a valid addition...
|
||||
|
@ -310,43 +309,19 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
NSAssert(NSXMLNotationDeclarationKind != kind, NSInvalidArgumentException);
|
||||
|
||||
// Get all of the nodes...
|
||||
newNode = ((xmlNodePtr)[child _node]);
|
||||
next = [self childAtIndex: index];
|
||||
nextNode = ((xmlNodePtr)[next _node]);
|
||||
if(nextNode != NULL)
|
||||
{
|
||||
prevNode = nextNode->prev;
|
||||
}
|
||||
else if(index > 0)
|
||||
{
|
||||
prevNode = (xmlNodePtr)[[self childAtIndex: index - 1] _node];
|
||||
}
|
||||
childNode = ((xmlNodePtr)[child _node]);
|
||||
cur = [self childAtIndex: index];
|
||||
curNode = ((xmlNodePtr)[cur _node]);
|
||||
|
||||
// Make all of the links...
|
||||
/*
|
||||
if(prevNode != NULL)
|
||||
if(0 == childCount || index == childCount)
|
||||
{
|
||||
prevNode = nextNode;
|
||||
xmlAddChild(thisNode, childNode);
|
||||
}
|
||||
*/
|
||||
newNode->next = nextNode;
|
||||
newNode->prev = prevNode;
|
||||
if(nextNode != NULL)
|
||||
else if(index < childCount)
|
||||
{
|
||||
nextNode->prev = newNode;
|
||||
xmlAddNextSibling(curNode, childNode);
|
||||
}
|
||||
if(prevNode != NULL)
|
||||
{
|
||||
prevNode->next = newNode;
|
||||
}
|
||||
|
||||
if(MY_NODE->children == NULL)
|
||||
{
|
||||
MY_NODE->children = newNode;
|
||||
}
|
||||
|
||||
((xmlNodePtr)[child _node])->parent = [self _node];
|
||||
//GSIVar(child, parent) = self;
|
||||
|
||||
[self _addSubNode:child];
|
||||
}
|
||||
|
||||
|
@ -407,7 +382,7 @@ extern void clearPrivatePointers(xmlNodePtr aNode);
|
|||
|
||||
- (void) normalizeAdjacentTextNodesPreservingCDATA: (BOOL)preserve
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
// FIXME: Implement this method...
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone *)zone
|
||||
|
|
|
@ -585,9 +585,12 @@ NSArray *execute_xpath(NSXMLNode *node,
|
|||
|
||||
- (void) release
|
||||
{
|
||||
if ([self retainCount] == 2)
|
||||
if(GS_EXISTS_INTERNAL)
|
||||
{
|
||||
[self releaseExternalRetain];
|
||||
if ([self retainCount] == [internal->subNodes count]) // 2)
|
||||
{
|
||||
[self releaseExternalRetain];
|
||||
}
|
||||
}
|
||||
[super release];
|
||||
}
|
||||
|
@ -683,11 +686,14 @@ NSArray *execute_xpath(NSXMLNode *node,
|
|||
case NSXMLEntityDeclarationKind:
|
||||
case NSXMLElementDeclarationKind:
|
||||
case NSXMLNotationDeclarationKind:
|
||||
case NSXMLAttributeDeclarationKind:
|
||||
node = xmlNewNode(NULL, (xmlChar *)"");
|
||||
((xmlNodePtr)node)->type = XML_ATTRIBUTE_DECL;
|
||||
// ((xmlNodePtr)node)->type = XML_ATTRIBUTE_DECL;
|
||||
theSubclass = [NSXMLDTDNode class];
|
||||
break;
|
||||
|
||||
case NSXMLAttributeDeclarationKind:
|
||||
return nil;
|
||||
break;
|
||||
|
||||
case NSXMLProcessingInstructionKind:
|
||||
node = xmlNewPI((xmlChar *)"", (xmlChar *)"");
|
||||
|
@ -985,11 +991,13 @@ NSArray *execute_xpath(NSXMLNode *node,
|
|||
|
||||
- (void) setObjectValue: (id)value
|
||||
{
|
||||
/*
|
||||
if(nil == value)
|
||||
{
|
||||
ASSIGN(internal->objectValue, [NSString stringWithString: @""]);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
ASSIGN(internal->objectValue, value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue