]> err.no Git - sope/blobdiff - sope-ical/versitSaxDriver/VSSaxDriver.m
added some vCard model objects
[sope] / sope-ical / versitSaxDriver / VSSaxDriver.m
index 4f0881be084aa0abb018fa10bce188d7189bd836..a82e1abdc87dd70631a2ea999b573b63f80c778a 100644 (file)
@@ -381,8 +381,8 @@ static VSStringFormatter *stringFormatter = nil;
 
   if (_attrs == nil || [_attrs count] == 0)
     return nil;
-
-  attributes = [[NSMutableDictionary alloc] init];
+  
+  attributes = [[NSMutableDictionary alloc] initWithCapacity:4];
   retAttrs   = [[[SaxAttributes alloc] init] autorelease];
   
   attrEnum = [_attrs objectEnumerator];
@@ -391,11 +391,14 @@ static VSStringFormatter *stringFormatter = nil;
           forTag:_tagName
           intoAttr:&mappedAttr
           intoValue:&mappedValue];
-    if ((oldValue = [attributes objectForKey:mappedAttr])) {
+    if ((oldValue = [attributes objectForKey:mappedAttr]) != nil) {
       NSString *val;
+      
       /* ZNeK: duh! */
-      val = [NSString stringWithFormat:@"%@ %@",oldValue, mappedValue];
+      // TODO: hh asks: what does 'duh' is supposed to mean?
+      val = [[NSString alloc] initWithFormat:@"%@ %@",oldValue, mappedValue];
       [attributes setObject:val forKey:mappedAttr];
+      [val release];
     }
     else  
       [attributes setObject:mappedValue forKey:mappedAttr];
@@ -403,6 +406,16 @@ static VSStringFormatter *stringFormatter = nil;
 
   attrEnum = [attributes keyEnumerator];
   while ((curAttr = [attrEnum nextObject]) != nil) {
+    /*
+      TODO: values are not always mapped to CDATA! Eg in the dawson draft:
+        | TYPE for TEL   | tel.type   | NMTOKENS  | 'VOICE'         |
+        | TYPE for EMAIL | email.type | NMTOKENS  | 'INTERNET'      |
+        | TYPE for PHOTO,| img.type   | CDATA     | REQUIRED        |
+        |  and LOGO      |            |           |                 |
+        | TYPE for SOUND | aud.type   | CDATA     | REQUIRED        |
+        | VALUE          | value      | NOTATION  | See elements    |
+    */
+    
     [retAttrs addAttribute:curAttr uri:self->prefixURI rawName:curAttr
              type:@"CDATA" value:[attributes objectForKey:curAttr]];
   }