• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Validating NSXMLDocument against external DTD
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Help Understanding CFRunLoopSourceSignal and CFRunLoopWakeUp
  • Next by Date: RE: NSDictionary trouble
  • Previous by thread: Re: Help Understanding CFRunLoopSourceSignal and CFRunLoopWakeUp
  • Next by thread: Re: Validating NSXMLDocument against external DTD
  • Index(es):
    • Date
    • Thread