non-portable plist DTD URL
non-portable plist DTD URL
- Subject: non-portable plist DTD URL
- From: Scout <email@hidden>
- Date: Thu, 1 Aug 2002 19:04:02 -0700
Is there a better way to write a cocoa plist?
The problem is with the doctype reference in plist files, pretty
non-portable as XML:
<!DOCTYPE plist SYSTEM
"file://localhost/System/Library/DTDs/PropertyList.dtd">
Fortunately cocoa seems to pay no attention to doctype at all, thus if
you remove the line in the brutal fashion, the file still works on Mac,
and parses on machines with validating XML parsers.
NSMutableDictionary *aDict = [[NSMutableDictionary alloc] init];
[aDict setObject:@"foo value" forKey:@"fooKey"];
[aDict setObject:@"bar value" forKey:@"barKey"];
[aDict writeToFile:@"/tmp/foo" atomically:YES];
{
NSMutableString *d = [NSMutableString
stringWithContentsOfFile:@"/tmp/foo"];
NSString *xdtd = @"<!DOCTYPE plist SYSTEM
\"file://localhost/System/Library/DTDs/PropertyList.dtd\">";
NSRange r = [d rangeOfString:xdtd];
[d replaceCharactersInRange:r withString:@""];
NSLog(@"Plist Data sans bad doctype reference: %@", d);
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.