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


Glenn L. Austin
 

On Dec 11, 2019, at 8:52 AM, Steve Mills via Groups.Io <sjmills@...> wrote:

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
Have you tried returning a full XML entity, e.g. "<string>&#xa0</string>"?

That would be my next experiment...

--
Glenn L. Austin, Computer Wizard and Race Car Driver <><
<http://www.austinsoft.com>

Join {cocoa@apple-dev.groups.io to automatically receive all group messages.