NSXMLParser and DTD-file
NSXMLParser and DTD-file
- Subject: NSXMLParser and DTD-file
- From: Joakim Danielson <email@hidden>
- Date: Wed, 24 Nov 2004 15:04:08 +0100
Hello
I have an XML file for my application that describes the mapping between my business classes and my database tables. The XML file uses a DTD document. The problem is that I can't get NSXMLParser to use the DTD file.
I think I have set everything up according to the documentation but I can't get it to work.
The code for initializing the parser looks like this:
...
NSData *xmlData = [[NSData alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"PersistenceMapper" ofType:@"xml"]];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:xmlData];
[parser setShouldResolveExternalEntities:YES];
JDPersistenceXMLMapper *mapper = [[JDPersistenceXMLMapper alloc] initWithReceiver:self];
[parser setDelegate:mapper];
[parser parse];
...
and in the delegate I have implemented:
- (NSData *)parser:(NSXMLParser *)parser resolveExternalEntityName:(NSString *)entityName systemID:(NSString *)systemID {
NSLog(@"External Entity. Name: %@, system id: %@", entityName, systemID);
return [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"PersistenceMapper" ofType:@"dtd"]];
}
and my xml file starts with:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE persistencemapper SYSTEM "PersistenceMapper.dtd">
But parser:resolveExternalEntityName:systemID never gets called. Could someone help me out with this.
Joakim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden