How to return data for NXSMLParserDelegate's -parser:resolveExternalEntityName:systemID:

Steve Mills

What is the expected value of the returned NSData supposed to be for this method? The docs says "An NSData object that contains the resolution of the given external entity." To me, that means that for entity "nbsp", I should return "&#xa0" as:

[@"&#xa0" dataUsingEncoding:NSUTF8StringEncoding]

But the parser just stops parsing after that and never calls any delegate methods. The parser fails and has error:

The operation couldn't be completed. (NSXMLParserErrorDomain error 111.)

Of course, error 111 isn't listed in the NSXMLParserError enum. It's all so cryptic. Oh, but if I implement -parser:parseErrorOccurred:, that gives me error 26, NSXMLParserUndeclaredEntityError. Still, pretty cryptic when it comes to documenting what is expected of -parser:resolveExternalEntityName:systemID:

Can anyone decipher what Apple really means? I even tried just returning plain ol' unescaped text in the data, [@"x" dataUsingEncoding:NSUTF8StringEncoding] and got the same result.

Steve Mills
Drummer, Mac geek

Join to automatically receive all group messages.