From 69f800d479c4aec68fa1353d37f403efe6ea78cc Mon Sep 17 00:00:00 2001 From: Alex Billingsley Date: Thu, 8 Dec 2011 13:21:43 -0500 Subject: [PATCH 1/3] implement interface for replacement class for easy subclassing --- KissXML/Additions/DDXMLElementAdditions.m | 9 +- KissXML/DDXMLDocument.m | 21 +++- KissXML/DDXMLElement.m | 48 +++++--- KissXML/DDXMLNode.m | 129 +++++++++++++++------- 4 files changed, 149 insertions(+), 58 deletions(-) diff --git a/KissXML/Additions/DDXMLElementAdditions.m b/KissXML/Additions/DDXMLElementAdditions.m index 6977bf68..5597a853 100644 --- a/KissXML/Additions/DDXMLElementAdditions.m +++ b/KissXML/Additions/DDXMLElementAdditions.m @@ -7,7 +7,8 @@ @implementation DDXMLElement (DDAdditions) **/ + (DDXMLElement *)elementWithName:(NSString *)name xmlns:(NSString *)ns { - DDXMLElement *element = [DDXMLElement elementWithName:name]; + Class type = [[self class] replacementClassForClass:[DDXMLElement class]]; + DDXMLElement *element = [type elementWithName:name]; [element setXmlns:ns]; return element; } @@ -83,7 +84,8 @@ - (void)setXmlns:(NSString *)ns // // This applies to both Apple's NSXML and DDXML. - [self addNamespace:[DDXMLNode namespaceWithName:@"" stringValue:ns]]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [self addNamespace:[type namespaceWithName:@"" stringValue:ns]]; } /** @@ -107,7 +109,8 @@ - (NSString *)compactXMLString **/ - (void)addAttributeWithName:(NSString *)name stringValue:(NSString *)string { - [self addAttribute:[DDXMLNode attributeWithName:name stringValue:string]]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [self addAttribute:[type attributeWithName:name stringValue:string]]; } /** diff --git a/KissXML/DDXMLDocument.m b/KissXML/DDXMLDocument.m index dabecbbd..fa2b38e8 100644 --- a/KissXML/DDXMLDocument.m +++ b/KissXML/DDXMLDocument.m @@ -21,13 +21,26 @@ @implementation DDXMLDocument ++ (Class)replacementClassForClass:(Class)currentClass { + if ( currentClass == [DDXMLElement class] ) { + return [DDXMLElement class]; + } + else if ( currentClass == [DDXMLNode class] ) { + return [DDXMLNode class]; + } + else { + return [DDXMLDocument class]; + } +} + /** * Returns a DDXML wrapper object for the given primitive node. * The given node MUST be non-NULL and of the proper type. **/ + (id)nodeWithDocPrimitive:(xmlDocPtr)doc owner:(DDXMLNode *)owner { - return [[[DDXMLDocument alloc] initWithDocPrimitive:doc owner:owner] autorelease]; + Class type = [[self class] replacementClassForClass:[DDXMLDocument class]]; + return [[[type alloc] initWithDocPrimitive:doc owner:owner] autorelease]; } - (id)initWithDocPrimitive:(xmlDocPtr)doc owner:(DDXMLNode *)inOwner @@ -116,8 +129,10 @@ - (DDXMLElement *)rootElement xmlNodePtr rootNode = xmlDocGetRootElement(doc); - if (rootNode != NULL) - return [DDXMLElement nodeWithElementPrimitive:rootNode owner:self]; + if (rootNode != NULL){ + Class type = [[self class] replacementClassForClass:[DDXMLElement class]]; + return [type nodeWithElementPrimitive:rootNode owner:self]; + } else return nil; } diff --git a/KissXML/DDXMLElement.m b/KissXML/DDXMLElement.m index a8cae781..cc88e18d 100644 --- a/KissXML/DDXMLElement.m +++ b/KissXML/DDXMLElement.m @@ -21,13 +21,26 @@ @implementation DDXMLElement ++ (Class)replacementClassForClass:(Class)currentClass { + if ( currentClass == [DDXMLElement class] ) { + return [DDXMLElement class]; + } + else if ( currentClass == [DDXMLNode class] ) { + return [DDXMLNode class]; + } + else { + return [DDXMLDocument class]; + } +} + /** * Returns a DDXML wrapper object for the given primitive node. * The given node MUST be non-NULL and of the proper type. **/ + (id)nodeWithElementPrimitive:(xmlNodePtr)node owner:(DDXMLNode *)owner { - return [[[DDXMLElement alloc] initWithElementPrimitive:node owner:owner] autorelease]; + Class type = [[self class] replacementClassForClass:[DDXMLElement class]]; + return [[[type alloc] initWithElementPrimitive:node owner:owner] autorelease]; } - (id)initWithElementPrimitive:(xmlNodePtr)node owner:(DDXMLNode *)inOwner @@ -103,7 +116,8 @@ - (id)initWithName:(NSString *)name stringValue:(NSString *)string - (id)initWithXMLString:(NSString *)string error:(NSError **)error { - DDXMLDocument *doc = [[DDXMLDocument alloc] initWithXMLString:string options:0 error:error]; + Class type = [[self class] replacementClassForClass:[DDXMLDocument class]]; + DDXMLDocument *doc = [[type alloc] initWithXMLString:string options:0 error:error]; if (doc == nil) { [self release]; @@ -177,7 +191,8 @@ - (NSArray *)_elementsForName:(NSString *)name if (match) { - [result addObject:[DDXMLElement nodeWithElementPrimitive:child owner:self]]; + Class type = [[self class] replacementClassForClass:[DDXMLElement class]]; + [result addObject:[type nodeWithElementPrimitive:child owner:self]]; } } @@ -210,7 +225,8 @@ - (NSArray *)elementsForName:(NSString *)name NSString *prefix; NSString *localName; - [DDXMLNode getPrefix:&prefix localName:&localName forName:name]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [type getPrefix:&prefix localName:&localName forName:name]; if ([prefix length] > 0) { @@ -253,7 +269,8 @@ - (NSArray *)elementsForLocalName:(NSString *)localName URI:(NSString *)uri NSString *prefix; NSString *realLocalName; - [DDXMLNode getPrefix:&prefix localName:&realLocalName forName:localName]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [type getPrefix:&prefix localName:&realLocalName forName:localName]; return [self _elementsForName:localName localName:realLocalName prefix:prefix uri:uri]; } @@ -297,7 +314,8 @@ - (void)_removeAttributeForName:(NSString *)name { if (xmlStrEqual(attr->name, xmlName)) { - [DDXMLNode removeAttribute:attr]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [type removeAttribute:attr]; return; } attr = attr->next; @@ -407,8 +425,8 @@ - (void)setAttributes:(NSArray *)attributes #if DDXML_DEBUG_MEMORY_ISSUES DDXMLNotZombieAssert(); #endif - - [DDXMLNode removeAllAttributesFromNode:(xmlNodePtr)genericPtr]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [type removeAllAttributesFromNode:(xmlNodePtr)genericPtr]; NSUInteger i; for (i = 0; i < [attributes count]; i++) @@ -436,7 +454,8 @@ - (void)_removeNamespaceForPrefix:(NSString *)name { if (xmlStrEqual(ns->prefix, xmlName)) { - [DDXMLNode removeNamespace:ns fromNode:node]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [type removeNamespace:ns fromNode:node]; break; } ns = ns->next; @@ -577,7 +596,8 @@ - (void)setNamespaces:(NSArray *)namespaces DDXMLNotZombieAssert(); #endif - [DDXMLNode removeAllNamespacesFromNode:(xmlNodePtr)genericPtr]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [type removeAllNamespacesFromNode:(xmlNodePtr)genericPtr]; NSUInteger i; for (i = 0; i < [namespaces count]; i++) @@ -778,7 +798,8 @@ - (void)removeChildAtIndex:(NSUInteger)index { if (i == index) { - [DDXMLNode removeChild:child]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [type removeChild:child]; return; } @@ -793,8 +814,9 @@ - (void)setChildren:(NSArray *)children #if DDXML_DEBUG_MEMORY_ISSUES DDXMLNotZombieAssert(); #endif - - [DDXMLNode removeAllChildrenFromNode:(xmlNodePtr)genericPtr]; + + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [type removeAllChildrenFromNode:(xmlNodePtr)genericPtr]; NSUInteger i; for (i = 0; i < [children count]; i++) diff --git a/KissXML/DDXMLNode.m b/KissXML/DDXMLNode.m index 094cd75b..6d0e3560 100644 --- a/KissXML/DDXMLNode.m +++ b/KissXML/DDXMLNode.m @@ -40,6 +40,18 @@ @implementation DDXMLNode #endif ++ (Class)replacementClassForClass:(Class)currentClass { + if ( currentClass == [DDXMLElement class] ) { + return [DDXMLElement class]; + } + else if ( currentClass == [DDXMLNode class] ) { + return [DDXMLNode class]; + } + else { + return [DDXMLDocument class]; + } +} + /** * From Apple's Documentation: * @@ -76,17 +88,20 @@ + (void)initialize + (id)elementWithName:(NSString *)name { - return [[[DDXMLElement alloc] initWithName:name] autorelease]; + Class type = [[self class] replacementClassForClass:[DDXMLElement class]]; + return [[[type alloc] initWithName:name] autorelease]; } + (id)elementWithName:(NSString *)name stringValue:(NSString *)string { - return [[[DDXMLElement alloc] initWithName:name stringValue:string] autorelease]; + Class type = [[self class] replacementClassForClass:[DDXMLElement class]]; + return [[[type alloc] initWithName:name stringValue:string] autorelease]; } + (id)elementWithName:(NSString *)name children:(NSArray *)children attributes:(NSArray *)attributes { - DDXMLElement *result = [[[DDXMLElement alloc] initWithName:name] autorelease]; + Class type = [[self class] replacementClassForClass:[DDXMLElement class]]; + DDXMLElement *result = [[[type alloc] initWithName:name] autorelease]; [result setChildren:children]; [result setAttributes:attributes]; @@ -95,7 +110,8 @@ + (id)elementWithName:(NSString *)name children:(NSArray *)children attributes:( + (id)elementWithName:(NSString *)name URI:(NSString *)URI { - return [[[DDXMLElement alloc] initWithName:name URI:URI] autorelease]; + Class type = [[self class] replacementClassForClass:[DDXMLElement class]]; + return [[[type alloc] initWithName:name URI:URI] autorelease]; } + (id)attributeWithName:(NSString *)name stringValue:(NSString *)stringValue @@ -137,7 +153,8 @@ + (id)processingInstructionWithName:(NSString *)name stringValue:(NSString *)str if (procInst == NULL) return nil; - return [[[DDXMLNode alloc] initWithPrimitive:(xmlKindPtr)procInst owner:nil] autorelease]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [[[type alloc] initWithPrimitive:(xmlKindPtr)procInst owner:nil] autorelease]; } + (id)commentWithStringValue:(NSString *)stringValue @@ -146,7 +163,8 @@ + (id)commentWithStringValue:(NSString *)stringValue if (comment == NULL) return nil; - return [[[DDXMLNode alloc] initWithPrimitive:(xmlKindPtr)comment owner:nil] autorelease]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [[[type alloc] initWithPrimitive:(xmlKindPtr)comment owner:nil] autorelease]; } + (id)textWithStringValue:(NSString *)stringValue @@ -155,7 +173,8 @@ + (id)textWithStringValue:(NSString *)stringValue if (text == NULL) return nil; - return [[[DDXMLNode alloc] initWithPrimitive:(xmlKindPtr)text owner:nil] autorelease]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [[[type alloc] initWithPrimitive:(xmlKindPtr)text owner:nil] autorelease]; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -166,11 +185,13 @@ + (id)nodeWithUnknownPrimitive:(xmlKindPtr)kindPtr owner:(DDXMLNode *)owner { if (kindPtr->type == XML_DOCUMENT_NODE) { - return [DDXMLDocument nodeWithDocPrimitive:(xmlDocPtr)kindPtr owner:owner]; + Class type = [[self class] replacementClassForClass:[DDXMLDocument class]]; + return [type nodeWithDocPrimitive:(xmlDocPtr)kindPtr owner:owner]; } else if (kindPtr->type == XML_ELEMENT_NODE) { - return [DDXMLElement nodeWithElementPrimitive:(xmlNodePtr)kindPtr owner:owner]; + Class type = [[self class] replacementClassForClass:[DDXMLElement class]]; + return [type nodeWithElementPrimitive:(xmlNodePtr)kindPtr owner:owner]; } else if (kindPtr->type == XML_NAMESPACE_DECL) { @@ -184,7 +205,8 @@ + (id)nodeWithUnknownPrimitive:(xmlKindPtr)kindPtr owner:(DDXMLNode *)owner } else { - return [DDXMLNode nodeWithPrimitive:kindPtr owner:owner]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [type nodeWithPrimitive:kindPtr owner:owner]; } } @@ -194,7 +216,8 @@ + (id)nodeWithUnknownPrimitive:(xmlKindPtr)kindPtr owner:(DDXMLNode *)owner **/ + (id)nodeWithPrimitive:(xmlKindPtr)kindPtr owner:(DDXMLNode *)owner { - return [[[DDXMLNode alloc] initWithPrimitive:kindPtr owner:owner] autorelease]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [[[type alloc] initWithPrimitive:kindPtr owner:owner] autorelease]; } /** @@ -310,7 +333,8 @@ - (id)copyWithZone:(NSZone *)zone if (copyDocPtr == NULL) return nil; - return [[DDXMLDocument alloc] initWithDocPrimitive:copyDocPtr owner:nil]; + Class type = [[self class] replacementClassForClass:[DDXMLDocument class]]; + return [[type alloc] initWithDocPrimitive:copyDocPtr owner:nil]; } if (IsXmlNodePtr(genericPtr)) @@ -319,10 +343,14 @@ - (id)copyWithZone:(NSZone *)zone if (copyNodePtr == NULL) return nil; - if ([self isKindOfClass:[DDXMLElement class]]) - return [[DDXMLElement alloc] initWithElementPrimitive:copyNodePtr owner:nil]; - else - return [[DDXMLNode alloc] initWithPrimitive:(xmlKindPtr)copyNodePtr owner:nil]; + if ([self isKindOfClass:[DDXMLElement class]]){ + Class type = [[self class] replacementClassForClass:[DDXMLElement class]]; + return [[type alloc] initWithElementPrimitive:copyNodePtr owner:nil]; + } + else{ + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [[type alloc] initWithPrimitive:(xmlKindPtr)copyNodePtr owner:nil]; + } } if (IsXmlAttrPtr(genericPtr)) @@ -349,7 +377,8 @@ - (id)copyWithZone:(NSZone *)zone if (copyDtdPtr == NULL) return nil; - return [[DDXMLNode alloc] initWithPrimitive:(xmlKindPtr)copyDtdPtr owner:nil]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [[type alloc] initWithPrimitive:(xmlKindPtr)copyDtdPtr owner:nil]; } return nil; @@ -561,8 +590,10 @@ - (DDXMLDocument *)rootDocument if (node == NULL || node->doc == NULL) return nil; - else - return [DDXMLDocument nodeWithDocPrimitive:node->doc owner:self]; + else{ + Class type = [[self class] replacementClassForClass:[DDXMLDocument class]]; + return [type nodeWithDocPrimitive:node->doc owner:self]; + } } /** @@ -584,8 +615,10 @@ - (DDXMLNode *)parent if (node->parent == NULL) return nil; - else - return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)node->parent owner:self]; + else{ + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [type nodeWithUnknownPrimitive:(xmlKindPtr)node->parent owner:self]; + } } /** @@ -638,7 +671,8 @@ - (NSArray *)children xmlNodePtr child = ((xmlStdPtr)genericPtr)->children; while (child != NULL) { - [result addObject:[DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)child owner:self]]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [result addObject:[type nodeWithUnknownPrimitive:(xmlKindPtr)child owner:self]]; child = child->next; } @@ -682,7 +716,8 @@ - (DDXMLNode *)childAtIndex:(NSUInteger)index { if (i == index) { - return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)child owner:self]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [type nodeWithUnknownPrimitive:(xmlKindPtr)child owner:self]; } i++; @@ -713,8 +748,10 @@ - (DDXMLNode *)previousSibling if (node->prev == NULL) return nil; - else - return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)node->prev owner:self]; + else{ + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [type nodeWithUnknownPrimitive:(xmlKindPtr)node->prev owner:self]; + } } /** @@ -736,8 +773,10 @@ - (DDXMLNode *)nextSibling if (node->next == NULL) return nil; - else - return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)node->next owner:self]; + else{ + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [type nodeWithUnknownPrimitive:(xmlKindPtr)node->next owner:self]; + } } /** @@ -775,12 +814,14 @@ - (DDXMLNode *)previousNode lastChild = lastChild->last; } - return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)lastChild owner:self]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [type nodeWithUnknownPrimitive:(xmlKindPtr)lastChild owner:self]; } else { // The previous sibling has no children, so the previous node is simply the previous sibling - return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)previousSibling owner:self]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [type nodeWithUnknownPrimitive:(xmlKindPtr)previousSibling owner:self]; } } @@ -790,8 +831,10 @@ - (DDXMLNode *)previousNode if (node->parent == NULL || node->parent->type == XML_DOCUMENT_NODE) return nil; - else - return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)node->parent owner:self]; + else{ + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [type nodeWithUnknownPrimitive:(xmlKindPtr)node->parent owner:self]; + } } /** @@ -831,8 +874,10 @@ - (DDXMLNode *)nextNode while (parent != NULL) { xmlNodePtr parentNextSibling = parent->next; - if (parentNextSibling != NULL) - return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)parentNextSibling owner:self]; + if (parentNextSibling != NULL){ + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [type nodeWithUnknownPrimitive:(xmlKindPtr)parentNextSibling owner:self]; + } else parent = parent->parent; } @@ -1271,7 +1316,8 @@ - (NSArray *)nodesForXPath:(NSString *)xpath error:(NSError **)error { xmlNodePtr node = xpathObj->nodesetval->nodeTab[i]; - [mResult addObject:[DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)node owner:self]]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [mResult addObject:[type nodeWithUnknownPrimitive:(xmlKindPtr)node owner:self]]; } result = mResult; @@ -2330,8 +2376,10 @@ - (DDXMLDocument *)rootDocument if (node == NULL || node->doc == NULL) return nil; - else - return [DDXMLDocument nodeWithDocPrimitive:node->doc owner:self]; + else{ + Class type = [[self class] replacementClassForClass:[DDXMLDocument class]]; + return [type nodeWithDocPrimitive:node->doc owner:self]; + } } - (DDXMLNode *)parent @@ -2342,8 +2390,10 @@ - (DDXMLNode *)parent if (nsParentPtr == NULL) return nil; - else - return [DDXMLNode nodeWithUnknownPrimitive:(xmlKindPtr)nsParentPtr owner:self]; + else{ + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + return [type nodeWithUnknownPrimitive:(xmlKindPtr)nsParentPtr owner:self]; + } } - (NSUInteger)childCount @@ -2417,7 +2467,8 @@ - (void)detach if (nsParentPtr != NULL) { - [DDXMLNode detachNamespace:(xmlNsPtr)genericPtr fromNode:nsParentPtr]; + Class type = [[self class] replacementClassForClass:[DDXMLNode class]]; + [type detachNamespace:(xmlNsPtr)genericPtr fromNode:nsParentPtr]; [owner release]; owner = nil; From 70db28a286053b08e2a558dfc1b3dc3e7c224afb Mon Sep 17 00:00:00 2001 From: Alex Billingsley Date: Thu, 8 Dec 2011 13:39:20 -0500 Subject: [PATCH 2/3] need to add replacementClass method to XMLElement (Additions) --- KissXML/Additions/DDXMLElementAdditions.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/KissXML/Additions/DDXMLElementAdditions.m b/KissXML/Additions/DDXMLElementAdditions.m index 6977bf68..4c772015 100644 --- a/KissXML/Additions/DDXMLElementAdditions.m +++ b/KissXML/Additions/DDXMLElementAdditions.m @@ -2,6 +2,18 @@ @implementation DDXMLElement (DDAdditions) ++ (Class)replacementClassForClass:(Class)currentClass { + if ( currentClass == [DDXMLElement class] ) { + return [DDXMLElement class]; + } + else if ( currentClass == [DDXMLNode class] ) { + return [DDXMLNode class]; + } + else { + return [DDXMLDocument class]; + } +} + /** * Quick method to create an element **/ From f9a1086e8123c5e873114800d225546f190bdddf Mon Sep 17 00:00:00 2001 From: Alex Billingsley Date: Thu, 8 Dec 2011 15:20:46 -0500 Subject: [PATCH 3/3] simplify replacement class by default we should just return the current class --- KissXML/Additions/DDXMLElementAdditions.m | 10 +--------- KissXML/DDXMLDocument.m | 10 +--------- KissXML/DDXMLElement.m | 10 +--------- KissXML/DDXMLNode.m | 10 +--------- 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/KissXML/Additions/DDXMLElementAdditions.m b/KissXML/Additions/DDXMLElementAdditions.m index f0249956..915d89ba 100644 --- a/KissXML/Additions/DDXMLElementAdditions.m +++ b/KissXML/Additions/DDXMLElementAdditions.m @@ -3,15 +3,7 @@ @implementation DDXMLElement (DDAdditions) + (Class)replacementClassForClass:(Class)currentClass { - if ( currentClass == [DDXMLElement class] ) { - return [DDXMLElement class]; - } - else if ( currentClass == [DDXMLNode class] ) { - return [DDXMLNode class]; - } - else { - return [DDXMLDocument class]; - } + return currentClass; } /** diff --git a/KissXML/DDXMLDocument.m b/KissXML/DDXMLDocument.m index fa2b38e8..2e05dc9a 100644 --- a/KissXML/DDXMLDocument.m +++ b/KissXML/DDXMLDocument.m @@ -22,15 +22,7 @@ @implementation DDXMLDocument + (Class)replacementClassForClass:(Class)currentClass { - if ( currentClass == [DDXMLElement class] ) { - return [DDXMLElement class]; - } - else if ( currentClass == [DDXMLNode class] ) { - return [DDXMLNode class]; - } - else { - return [DDXMLDocument class]; - } + return currentClass; } /** diff --git a/KissXML/DDXMLElement.m b/KissXML/DDXMLElement.m index cc88e18d..a0e44242 100644 --- a/KissXML/DDXMLElement.m +++ b/KissXML/DDXMLElement.m @@ -22,15 +22,7 @@ @implementation DDXMLElement + (Class)replacementClassForClass:(Class)currentClass { - if ( currentClass == [DDXMLElement class] ) { - return [DDXMLElement class]; - } - else if ( currentClass == [DDXMLNode class] ) { - return [DDXMLNode class]; - } - else { - return [DDXMLDocument class]; - } + return currentClass; } /** diff --git a/KissXML/DDXMLNode.m b/KissXML/DDXMLNode.m index 6d0e3560..46af8553 100644 --- a/KissXML/DDXMLNode.m +++ b/KissXML/DDXMLNode.m @@ -41,15 +41,7 @@ @implementation DDXMLNode #endif + (Class)replacementClassForClass:(Class)currentClass { - if ( currentClass == [DDXMLElement class] ) { - return [DDXMLElement class]; - } - else if ( currentClass == [DDXMLNode class] ) { - return [DDXMLNode class]; - } - else { - return [DDXMLDocument class]; - } + return currentClass; } /**