#include "VSSaxDriver.h"
#include "VSStringFormatter.h"
#include <SaxObjC/SaxException.h>
+#include <NGExtensions/NGQuotedPrintableCoding.h>
#include "common.h"
@interface VSSaxTag : NSObject
- (id)initWithContentString:(NSString *)_data;
- (NSString *)tagName;
+- (NSString *)group;
- (BOOL)isStartTag;
- (BOOL)isEndTag;
- (BOOL)isTag;
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];
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];
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]];
}
[self _endComponent:tagName value:tagValue];
}
else {
+ // TODO: make this more generic, this one is used with Outlook vCards
+ if ([tagAttributes containsObject:@"ENCODING=QUOTED-PRINTABLE"]) {
+ // TODO: QP is charset specific! The one below decodes in Unicode!
+ tagValue = [tagValue stringByDecodingQuotedPrintable];
+ [tagAttributes removeObject:@"ENCODING=QUOTED-PRINTABLE"];
+ }
+
[self _reportContentAsTag:[self _mapTagName:tagName]
group:[self _groupFromTagName:tagName]
- withAttrs:[self _mapAttrs:tagAttributes forTag:tagName]
+ withAttrs:[self _mapAttrs:tagAttributes forTag:tagName]
andContent:tagValue];
}