FROM : Joakim Danielson
DATE : Wed Nov 24 15:04:08 2004
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
DATE : Wed Nov 24 15:04:08 2004
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
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

