*** base/trunk/Source/Additions/GSXML.m	2010-10-23 02:36:07.000000000 -0700
--- GNUstepBase/GSXML.m	2010-11-08 22:48:59.000000000 -0800
***************
*** 55,61 ****
--- 55,63 ----
  #import "GNUstepBase/GSXML.h"
  #import "Foundation/NSArray.h"
  #import "Foundation/NSBundle.h"
+ #if (!(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
  #import "Foundation/NSCalendarDate.h"
+ #endif
  #import "Foundation/NSCharacterSet.h"
  #import "Foundation/NSData.h"
  #import "Foundation/NSDictionary.h"
***************
*** 67,73 ****
--- 69,77 ----
  #import "Foundation/NSTimer.h"
  #import "Foundation/NSTimeZone.h"
  #import "Foundation/NSURL.h"
+ #if (!(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
  #import "Foundation/NSURLHandle.h"
+ #endif
  #import "Foundation/NSValue.h"
  
  /* Avoid problems on systems where the xml headers use 'id'
***************
*** 215,221 ****
--- 219,233 ----
   */
  @implementation GSXMLAttribute
  
+ /**
+  * NSMapTable is not available on iOS. On OS X, it is depricated from 10.6 on.
+  */
+ #if !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
  static NSMapTable	*attrNames = 0;
+ #else
+ static NSMutableDictionary *attrNames = nil;
+ #define NO_NSMapTable 1
+ #endif
  
  + (void) initialize
  {
***************
*** 223,228 ****
--- 235,275 ----
      {
        if (cacheDone == NO)
  	setupCache();
+ #if NO_NSMapTable
+       attrNames = [NSMutableDictionary new];
+       
+       [attrNames setObject:(void*)@"XML_ATTRIBUTE_CDATA" 
+                     forKey:(void*)XML_ATTRIBUTE_CDATA];
+ 
+       [attrNames setObject:(void*)@"XML_ATTRIBUTE_ID" 
+                     forKey:(void*)XML_ATTRIBUTE_ID];
+ 
+       [attrNames setObject:(void*)@"XML_ATTRIBUTE_IDREF" 
+                     forKey:(void*)XML_ATTRIBUTE_IDREF];
+ 
+       [attrNames setObject:(void*)@"XML_ATTRIBUTE_IDREFS" 
+                     forKey:(void*)XML_ATTRIBUTE_IDREFS];
+ 
+       [attrNames setObject:(void*)@"XML_ATTRIBUTE_ENTITY" 
+                     forKey:(void*)XML_ATTRIBUTE_ENTITY];
+ 
+       [attrNames setObject:(void*)@"XML_ATTRIBUTE_ENTITIES" 
+                     forKey:(void*)XML_ATTRIBUTE_ENTITIES];
+ 
+       [attrNames setObject:(void*)@"XML_ATTRIBUTE_NMTOKEN" 
+                     forKey:(void*)XML_ATTRIBUTE_NMTOKEN];
+ 
+       [attrNames setObject:(void*)@"XML_ATTRIBUTE_NMTOKENS" 
+                     forKey:(void*)XML_ATTRIBUTE_NMTOKENS];
+ 
+       [attrNames setObject:(void*)@"XML_ATTRIBUTE_ENUMERATION" 
+                     forKey:(void*)XML_ATTRIBUTE_ENUMERATION];
+ 
+       [attrNames setObject:(void*)@"XML_ATTRIBUTE_NOTATION" 
+                     forKey:(void*)XML_ATTRIBUTE_NOTATION];
+     }
+   
+ #else
        attrNames = NSCreateMapTable(NSIntMapKeyCallBacks,
  	NSNonRetainedObjectMapValueCallBacks, 0);
        NSMapInsert(attrNames,
***************
*** 246,274 ****
        NSMapInsert(attrNames,
  	(void*)XML_ATTRIBUTE_NOTATION, (void*)@"XML_ATTRIBUTE_NOTATION");
      }
  }
  
  + (NSInteger) typeFromDescription: (NSString*)desc
  {
-   NSMapEnumerator	enumerator;
-   NSString		*val;
    void			*key;
! 
    enumerator = NSEnumerateMapTable(attrNames);
    while (NSNextMapEnumeratorPair(&enumerator, &key, (void**)&val))
      {
!       if ([desc isEqual: val] == YES)
! 	{
! 	  return (NSInteger)(intptr_t)key;
! 	}
      }
    return -1;
  }
  
  + (NSString*) descriptionFromType: (NSInteger)type
  {
    NSString	*desc = (NSString*)NSMapGet(attrNames, (void*)(intptr_t)type);
! 
    return desc;
  }
  
--- 293,339 ----
        NSMapInsert(attrNames,
  	(void*)XML_ATTRIBUTE_NOTATION, (void*)@"XML_ATTRIBUTE_NOTATION");
      }
+ #endif
  }
  
  + (NSInteger) typeFromDescription: (NSString*)desc
  {
    void			*key;
! #ifndef NO_NSMapTable
!   NSString		*val = nil;
!   NSMapEnumerator	enumerator;
    enumerator = NSEnumerateMapTable(attrNames);
    while (NSNextMapEnumeratorPair(&enumerator, &key, (void**)&val))
+   {
+     if ([desc isEqual: val] == YES)
      {
!       return (NSInteger)(intptr_t)key;
!     }
!   }
! #else
!   NSEnumerator	* enumerator;
!   enumerator = [attrNames keyEnumerator];
! 
!   while ((key = [enumerator nextObject]))
!   {
!     if ([desc isEqual: [attrNames objectForKey:key]] == YES)
!     {
!       return (NSInteger)(intptr_t)key;
      }
+   }
+ #endif
+ 
+   
    return -1;
  }
  
  + (NSString*) descriptionFromType: (NSInteger)type
  {
+ #ifndef NO_NSMapTable
    NSString	*desc = (NSString*)NSMapGet(attrNames, (void*)(intptr_t)type);
! #else
!   NSString	*desc = (NSString*)[attrNames objectForKey:[NSNumber numberWithInteger: type]];
! #endif
    return desc;
  }
  
***************
*** 281,287 ****
--- 346,356 ----
  {
    NSString	*desc;
  
+ #ifndef NO_NSMapTable
    desc = (NSString*)NSMapGet(attrNames, (void*)(intptr_t)[self type]);
+ #else
+   desc = (NSString*)[attrNames objectForKey:[NSNumber numberWithInteger: [self type]]];
+ #endif
    if (desc == nil)
      {
        desc = @"Unknown attribute type";
***************
*** 571,585 ****
   */
  @implementation GSXMLNamespace
  
  static NSMapTable	*nsNames = 0;
  
  /**
   * Return the string representation of the specified numeric type.
   */
  + (NSString*) descriptionFromType: (NSInteger)type
  {
    NSString	*desc = (NSString*)NSMapGet(nsNames, (void*)(intptr_t)type);
! 
    return desc;
  }
  
--- 640,662 ----
   */
  @implementation GSXMLNamespace
  
+ #ifndef NO_NSMapTable
  static NSMapTable	*nsNames = 0;
+ #else
+ static NSMutableDictionary *nsNames = nil;
+ #endif
  
  /**
   * Return the string representation of the specified numeric type.
   */
  + (NSString*) descriptionFromType: (NSInteger)type
  {
+ #ifndef NO_NSMapTable
    NSString	*desc = (NSString*)NSMapGet(nsNames, (void*)(intptr_t)type);
! #else
!   NSString	*desc = (NSString*)[nsNames objectForKey:[NSNumber numberWithInteger: type]];
! #endif
!   
    return desc;
  }
  
***************
*** 589,598 ****
--- 666,681 ----
      {
        if (cacheDone == NO)
  	setupCache();
+ #ifndef NO_NSMapTable
        nsNames = NSCreateMapTable(NSIntMapKeyCallBacks,
  	NSNonRetainedObjectMapValueCallBacks, 0);
        NSMapInsert(nsNames,
  	(void*)XML_LOCAL_NAMESPACE, (void*)@"XML_LOCAL_NAMESPACE");
+ #else
+       nsNames = [NSMutableDictionary new];
+       [nsNames setObject:@"XML_LOCAL_NAMESPACE"
+                   forKey:[NSNumber numberWithInt: XML_LOCAL_NAMESPACE]];
+ #endif
      }
  }
  
***************
*** 607,624 ****
   */
  + (NSInteger) typeFromDescription: (NSString*)desc
  {
-   NSMapEnumerator	enumerator;
    NSString		*val;
    void			*key;
! 
    enumerator = NSEnumerateMapTable(nsNames);
    while (NSNextMapEnumeratorPair(&enumerator, &key, (void**)&val))
      {
!       if ([desc isEqual: val] == YES)
! 	{
! 	  return (NSInteger)(intptr_t)key;
! 	}
      }
    return -1;
  }
  
--- 690,722 ----
   */
  + (NSInteger) typeFromDescription: (NSString*)desc
  {
    NSString		*val;
    void			*key;
! #ifndef NO_NSMapTable
!   NSMapEnumerator	enumerator;
!   
    enumerator = NSEnumerateMapTable(nsNames);
    while (NSNextMapEnumeratorPair(&enumerator, &key, (void**)&val))
+   {
+     if ([desc isEqual: val] == YES)
      {
!       return (NSInteger)(intptr_t)key;
      }
+   }
+ #else
+   NSEnumerator	* enumerator = [nsNames keyEnumerator];
+   
+   while ((key = [enumerator nextObject])) {
+     val = [nsNames objectForKey:key];
+     
+     if ([desc isEqual: val] == YES)
+     {
+       return (NSInteger)(intptr_t)key;
+     }
+     
+   }  
+   
+ #endif
    return -1;
  }
  
***************
*** 710,717 ****
  - (NSString*) typeDescription
  {
    NSString	*desc;
! 
    desc = (NSString*)NSMapGet(nsNames, (void*)(intptr_t)[self type]);
    if (desc == nil)
      {
        desc = @"Unknown namespace type";
--- 808,819 ----
  - (NSString*) typeDescription
  {
    NSString	*desc;
! #ifndef NO_NSMapTable
    desc = (NSString*)NSMapGet(nsNames, (void*)(intptr_t)[self type]);
+ #else
+   desc = (NSString*)[nsNames objectForKey:[NSNumber numberWithInteger:[self type]]];
+ #endif
+   
    if (desc == nil)
      {
        desc = @"Unknown namespace type";
***************
*** 748,763 ****
   * underlying libxml library.  It may have a parent, siblings, and children.
   */
  @implementation GSXMLNode
! 
  static NSMapTable	*nodeNames = 0;
  
  /**
   * Return the string constant value for the node type given.
   */
  + (NSString*) descriptionFromType: (NSInteger)type
  {
    NSString	*desc = (NSString*)NSMapGet(nodeNames, (void*)(intptr_t)type);
! 
    return desc;
  }
  
--- 850,872 ----
   * underlying libxml library.  It may have a parent, siblings, and children.
   */
  @implementation GSXMLNode
! #ifndef NO_NSMapTable
  static NSMapTable	*nodeNames = 0;
+ #else
+ static NSMutableDictionary *nodeNames = nil;
+ #endif
  
  /**
   * Return the string constant value for the node type given.
   */
  + (NSString*) descriptionFromType: (NSInteger)type
  {
+ #ifndef NO_NSMapTable
    NSString	*desc = (NSString*)NSMapGet(nodeNames, (void*)(intptr_t)type);
! #else
!   NSString	*desc = [nodeNames objectForKey:[NSNumber numberWithInteger:type]];
! #endif
!   
    return desc;
  }
  
***************
*** 767,772 ****
--- 876,882 ----
      {
        if (cacheDone == NO)
  	setupCache();
+ #ifndef NO_NSMapTable
        nodeNames = NSCreateMapTable(NSIntMapKeyCallBacks,
  	NSNonRetainedObjectMapValueCallBacks, 0);
        NSMapInsert(nodeNames,
***************
*** 803,808 ****
--- 913,955 ----
  	(void*)XML_ATTRIBUTE_DECL, (void*)@"XML_ATTRIBUTE_DECL");
        NSMapInsert(nodeNames,
  	(void*)XML_ENTITY_DECL, (void*)@"XML_ENTITY_DECL");
+ #else
+       nodeNames = [NSMutableDictionary new];
+       
+       [nodeNames setObject:(void*)@"XML_ELEMENT_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_ATTRIBUTE_CDATA]];
+       [nodeNames setObject:(void*)@"XML_ATTRIBUTE_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_ATTRIBUTE_NODE]];
+       [nodeNames setObject:(void*)@"XML_TEXT_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_TEXT_NODE]];
+       [nodeNames setObject:(void*)@"XML_CDATA_SECTION_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_CDATA_SECTION_NODE]];
+       [nodeNames setObject:(void*)@"XML_ENTITY_REF_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_ENTITY_REF_NODE]];
+       [nodeNames setObject:(void*)@"XML_ENTITY_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_ENTITY_NODE]];
+       [nodeNames setObject:(void*)@"XML_PI_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_PI_NODE]];
+       [nodeNames setObject:(void*)@"XML_COMMENT_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_COMMENT_NODE]];
+       [nodeNames setObject:(void*)@"XML_DOCUMENT_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_DOCUMENT_NODE]];
+       [nodeNames setObject:(void*)@"XML_DOCUMENT_TYPE_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_DOCUMENT_TYPE_NODE]];
+       [nodeNames setObject:(void*)@"XML_DOCUMENT_FRAG_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_NOTATION_NODE]];
+       [nodeNames setObject:(void*)@"XML_HTML_DOCUMENT_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_HTML_DOCUMENT_NODE]];
+       [nodeNames setObject:(void*)@"XML_DTD_NODE" 
+                     forKey:[NSNumber numberWithInt:XML_DTD_NODE]];
+       [nodeNames setObject:(void*)@"XML_ELEMENT_DECL" 
+                     forKey:[NSNumber numberWithInt:XML_ELEMENT_DECL]];
+       [nodeNames setObject:(void*)@"XML_ATTRIBUTE_DECL" 
+                     forKey:[NSNumber numberWithInt:XML_ATTRIBUTE_DECL]];
+       [nodeNames setObject:(void*)@"XML_ENTITY_DECL" 
+                     forKey:[NSNumber numberWithInt:XML_ENTITY_DECL]];
+       
+ #endif
      }
  }
  
***************
*** 835,852 ****
   */
  + (NSInteger) typeFromDescription: (NSString*)desc
  {
-   NSMapEnumerator	enumerator;
    NSString		*val;
    void			*key;
! 
    enumerator = NSEnumerateMapTable(nodeNames);
    while (NSNextMapEnumeratorPair(&enumerator, &key, (void**)&val))
      {
!       if ([desc isEqual: val] == YES)
! 	{
! 	  return (NSInteger)(intptr_t)key;
! 	}
      }
    return -1;
  }
  
--- 982,1014 ----
   */
  + (NSInteger) typeFromDescription: (NSString*)desc
  {
    NSString		*val;
    void			*key;
! #ifndef NO_NSMapTable
!   NSMapEnumerator	enumerator;
!   
    enumerator = NSEnumerateMapTable(nodeNames);
    while (NSNextMapEnumeratorPair(&enumerator, &key, (void**)&val))
+   {
+     if ([desc isEqual: val] == YES)
      {
!       return (NSInteger)(intptr_t)key;
      }
+   }
+ #else
+   NSEnumerator	* enumerator = [nodeNames keyEnumerator];
+   
+   while ((key = [enumerator nextObject])) {
+     val = [nodeNames objectForKey:key];
+ 
+     if ([desc isEqual: val] == YES)
+     {
+       return [(NSNumber*)key integerValue];
+     }
+     
+   }
+ 
+ #endif
    return -1;
  }
  
***************
*** 1565,1572 ****
  - (NSString*) typeDescription
  {
    NSString	*desc;
! 
    desc = (NSString*)NSMapGet(nodeNames, (void*)(intptr_t)[self type]);
    if (desc == nil)
      {
        desc = @"Unknown node type";
--- 1727,1738 ----
  - (NSString*) typeDescription
  {
    NSString	*desc;
! #ifndef NO_NSMapTable
    desc = (NSString*)NSMapGet(nodeNames, (void*)(intptr_t)[self type]);
+ #else
+   desc = [nodeNames objectForKey:[NSNumber numberWithInteger:[self type]]];
+ #endif
+   
    if (desc == nil)
      {
        desc = @"Unknown node type";
***************
*** 4745,4751 ****
  @end
  
  
! 
  /*
   * Convert incoming XMLRPC value to a normal Objective-C object.
   */
--- 4911,4917 ----
  @end
  
  
! #ifndef NO_NSMapTable
  /*
   * Convert incoming XMLRPC value to a normal Objective-C object.
   */
***************
*** 5658,5662 ****
--- 5824,5829 ----
  }
  @end
  
+ #endif /* NO_NSMapTable */
  #endif	/* HAVE_LIBXML */
  
