Permalink
Browse files

Bug fixes surrounding namespace handling and consolidation. Fixes cra…

…shes related to detaching nodes which were referencing namespaces outside themselves.
  • Loading branch information...
1 parent b2f387f commit 50e91010c4524ee4bba61b6285543c276be8f390 @robbiehanson committed Nov 2, 2011
Showing with 706 additions and 132 deletions.
  1. +9 −33 KissXML/DDXMLElement.m
  2. +437 −93 KissXML/DDXMLNode.m
  3. +21 −6 KissXML/Private/DDXMLPrivate.h
  4. +239 −0 UnitTesting/DDXMLTesting.m
View
@@ -268,22 +268,10 @@ - (BOOL)_hasAttributeWithName:(NSString *)name
return NO;
}
-- (void)_removeAttribute:(xmlAttrPtr)attr
-{
- // This is a private/internal method
-
- [[self class] removeAttribute:attr fromNode:(xmlNodePtr)genericPtr];
-}
-
-- (void)_removeAllAttributes
+- (void)_removeAttributeForName:(NSString *)name
{
// This is a private/internal method
- [[self class] removeAllAttributesFromNode:(xmlNodePtr)genericPtr];
-}
-
-- (void)_removeAttributeForName:(NSString *)name
-{
xmlAttrPtr attr = ((xmlNodePtr)genericPtr)->properties;
if (attr)
{
@@ -292,7 +280,7 @@ - (void)_removeAttributeForName:(NSString *)name
{
if (xmlStrEqual(attr->name, xmlName))
{
- [self _removeAttribute:attr];
+ [DDXMLNode removeAttribute:attr];
return;
}
attr = attr->next;
@@ -403,7 +391,7 @@ - (void)setAttributes:(NSArray *)attributes
DDXMLNotZombieAssert();
#endif
- [self _removeAllAttributes];
+ [DDXMLNode removeAllAttributesFromNode:(xmlNodePtr)genericPtr];
NSUInteger i;
for (i = 0; i < [attributes count]; i++)
@@ -419,31 +407,19 @@ - (void)setAttributes:(NSArray *)attributes
#pragma mark Namespaces
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-- (void)_removeNamespace:(xmlNsPtr)ns
-{
- // This is a private/internal method
-
- [[self class] removeNamespace:ns fromNode:(xmlNodePtr)genericPtr];
-}
-
-- (void)_removeAllNamespaces
-{
- // This is a private/internal method
-
- [[self class] removeAllNamespacesFromNode:(xmlNodePtr)genericPtr];
-}
-
- (void)_removeNamespaceForPrefix:(NSString *)name
{
+ xmlNodePtr node = (xmlNodePtr)genericPtr;
+
// If name is nil or the empty string, the user is wishing to remove the default namespace
const xmlChar *xmlName = [name length] > 0 ? [name xmlChar] : NULL;
- xmlNsPtr ns = ((xmlNodePtr)genericPtr)->nsDef;
+ xmlNsPtr ns = node->nsDef;
while (ns != NULL)
{
if (xmlStrEqual(ns->prefix, xmlName))
{
- [self _removeNamespace:ns];
+ [DDXMLNode removeNamespace:ns fromNode:node];
break;
}
ns = ns->next;
@@ -584,7 +560,7 @@ - (void)setNamespaces:(NSArray *)namespaces
DDXMLNotZombieAssert();
#endif
- [self _removeAllNamespaces];
+ [DDXMLNode removeAllNamespacesFromNode:(xmlNodePtr)genericPtr];
NSUInteger i;
for (i = 0; i < [namespaces count]; i++)
@@ -785,7 +761,7 @@ - (void)removeChildAtIndex:(NSUInteger)index
{
if (i == index)
{
- [DDXMLNode removeChild:child fromNode:(xmlNodePtr)genericPtr];
+ [DDXMLNode removeChild:child];
return;
}
Oops, something went wrong.

0 comments on commit 50e9101

Please sign in to comment.