Validating NSXMLDocument against external DTD
Validating NSXMLDocument against external DTD
- Subject: Validating NSXMLDocument against external DTD
- From: Rainer Standke <email@hidden>
- Date: Tue, 19 Jan 2010 20:02:23 -0800
Hello,
I am trying to validate an NSXMLDocument against an external DTD. Here
is what I do:
NSError *error = nil;
NSXMLDocument *doc = [[[NSXMLDocument alloc]
initWithXMLString:beamedXML options:NSXMLNodeOptionsNone error:&error]
autorelease];
if (!doc) {
NSLog(@"error: %@", error);
}
NSXMLElement *root = [doc rootElement];
//NSLog(@"%@", [root description]);
//NSBundle *theBundle = [NSBundle mainBundle];
//NSLog(@"%@", [theBundle description]);
NSString *dtdPath = [[NSBundle mainBundle]
pathForResource:@"FCPXMLv5" ofType:@"dtd"];
NSLog(@"dtdPath: %@", dtdPath);
NSURL *dtdUrl = [NSURL fileURLWithPath:dtdPath isDirectory:NO];
error = nil;
NSXMLDTD *theDtd = [[[NSXMLDTD alloc] initWithContentsOfURL:dtdUrl
options:NSXMLNodePreserveWhitespace error:&error] autorelease];
if (!theDtd) {
NSLog(@"error: %@", error);
}
//NSLog(@"theDtd: %@", theDtd);
[doc setDTD:theDtd];
error = nil;
if (! [doc validateAndReturnError:&error]) {
NSLog(@"error: %@", error);
}
And this is what I get:
Error Domain=NSXMLParserErrorDomain Code=1 UserInfo=0xdc17a50 "no DTD
found!
It seems to me that the DTD is expected to be found inside the XML
document. (The DTD seems to be created alright, since I can log it's
description.) In this case that not what I need or want. The Tree-
Based XML Programming Guide for Cocoa talks about external DTDs but I
can't find a clue as how to do this. Is it even possible?
Thanks,
Rainer
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden