Re: NSXMLParser - howto resolve entities defined in DTD
On Jun 1, 2009, at 4:03 PM, Keary Suska wrote: All external entities must be declared in the core XML. If they aren't, your XML is not well-formed. Correction, this would not be the case for declarations in a DTD, which are part of the external subset, so the first delegate message should not be sent. But the problem still stands that the parser won't load/parse the DTD, and the delegate will have to handle it. Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXMLParser - howto resolve entities defined in DTD
On Jun 1, 2009, at 1:43 PM, Dominik Pich wrote: :) thanks but . it doesnt work for me. I read all that about NSParser just calling you back. I implemented all the delegates BUT I dont seem to be getting an appropriate callback for the Entities in the DTD, although I did set 'shouldResolveExternalEntities = YES' I get that messages asking me to PROVIDE a substitution for an entity But I never get the messages FOR the declaration of the entities, so I dont know WHAT to return as data. I hope I explained my issue? For example: In the xml I have "&nameOfPerson; goes to &nameOfCiname;" :) I never get to know about the declares (which are in the DTD. which should be loaded. no?) No. That's the point. NSXMLParser does nothing outside of parsing the particular XML. It does not load DTDs, it does not validate, it does not resolve any links. It is the responsibility of the delegate to handle such things as DTD-related functions. You can use the NSXMLDTD class for this. All external entities must be declared in the core XML. If they aren't, your XML is not well-formed. When the parser finds and external entity declaration, the delegate is sent - parser:foundExternalEntityDeclarationWithName:publicID:systemID: . This just gives you a heads-up that the XML document expects to need to resolve that entity. When it finds the entity, you should be sent - parser:resolveExternalEntityName:systemID: (if you set the option), where you return the declaration as it appears in the DTD (as NSData). I believe that NSXMLDocument may provide the functionality that you want, so you might want to look down that route. Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXMLParser - howto resolve entities defined in DTD
Dominik Pich wrote: I get that messages asking me to PROVIDE a substitution for an entity But I never get the messages FOR the declaration of the entities, so I dont know WHAT to return as data. When something like this happens, i.e. "I've set my delegate, but it's not getting called", it may mean that you've misspelled or otherwise botched the method definition in your delegate's source. There clearly ARE delegate methods that are invoked when DTD parsing occurs. You should double-check your spelling, the parameter types, etc. If nothing looks wrong, then post your delegate's code. We need to see the actual code of the actual delegate that should be receiving these DTD messages. We may also need to see the XML from the DTD that is defining the entity. If it's too big to post, break it down to a small fail-case that reliably exhibits the problem. "&nameOfPerson; goes to &nameOfCiname;" :) Is "Ciname" supposed to be "Cinema"? -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXMLParser - howto resolve entities defined in DTD
> On Mon, 2009/06/01, Keary Suska wrote: > From: Keary Suska > Subject: Re: NSXMLParser - howto resolve entities defined in DTD > To: "Cocoa-Dev (Apple)" > Date: Monday, 2009 June 1, 10:16 >> On 2009 May 31, at 4:31 PM, Dominik Pich wrote: >> I use NSXMLParser to parse large XML files-- going >> good BUT :) >> I cant get the parser to resolve the external entities >> from the DTD. >> >> I googled and read documentation and older mails... >> and I did set parser.shouldResolveExternalEntities = >> YES > Well, the docs state: 1) "An NSXMLParser notifies its > delegate about the items (elements, attributes, CDATA > blocks, comments, and so on) that it encounters as it > processes an XML document. It does not itself do > anything with those parsed items except report them." > and 2) in setShouldResolveExternalEntities, "Indicates > whether the receiver reports declarations of external > entities using the delegate method > parser:foundExternalEntityDeclarationWithName:publicID:systemID:." > > I should be clear, then, that NSXMLParser does *not* > resolve external entities in any way, only reports > them, and explains what you see. And I don't recall it saying anything about parsing and otherwise examining the DTD or XML schema file except that there were hooks for later possible development of means to check whether the XML conforms to a DTD or XML schema. My reading is that it should be possible to have it parse whatever it finds in an XML file without any regard for whether it conforms to a DTD or XML schema. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXMLParser - howto resolve entities defined in DTD
:) thanks but . it doesnt work for me. I read all that about NSParser just calling you back. I implemented all the delegates BUT I dont seem to be getting an appropriate callback for the Entities in the DTD, although I did set 'shouldResolveExternalEntities = YES' I get that messages asking me to PROVIDE a substitution for an entity But I never get the messages FOR the declaration of the entities, so I dont know WHAT to return as data. I hope I explained my issue? For example: In the xml I have "&nameOfPerson; goes to &nameOfCiname;" :) I never get to know about the declares (which are in the DTD. which should be loaded. no?) > http://developer.apple.com/documentation/Cocoa/Conceptual/XMLParsing/Articles/ValidatingXML.html#/ /apple_ref/doc/uid/20002269-BBCFBAHB On 01.06.2009, at 17:16, Keary Suska wrote: On May 31, 2009, at 4:31 PM, Dominik Pich wrote: Hi, I use NSXMLParser to parse large XML files-- going good BUT :) I cant get the parser to resolve the external entities from the DTD. I googled and read documentation and older mails... and I did set parser.shouldResolveExternalEntities = YES Well, the docs state: 1) "An NSXMLParser notifies its delegate about the items (elements, attributes, CDATA blocks, comments, and so on) that it encounters as it processes an XML document. It does not itself do anything with those parsed items except report them." and 2) in setShouldResolveExternalEntities, "Indicates whether the receiver reports declarations of external entities using the delegate method parser:foundExternalEntityDeclarationWithName:publicID:systemID:." I should be clear, then, that NSXMLParser does *not* resolve external entities in any way, only reports them, and explains what you see. I do get: - (NSData *)parser:(AQXMLParser *)parser resolveExternalEntityName: (NSString *)name systemID:(NSString *)systemID but I have no idea what to return... the entities are defined in the DTD... As the docs say, "An NSData object that contains the resolution of the given external entity" if I could get the folowing for the entries in the DTD, I would just build a table myself - (void)parser:(AQXMLParser *)parser foundInternalEntityDeclarationWithName:(NSString *)name value: (NSString *)value; Still, shouldnt NSXMLParser do entity substitution for me? somehow... :) The companion document to NSXMLParser, "Event-Driven XML Programming Guide for Cocoa", tells you what you need to do to resolve external entities. Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/dominik%40pich.info This email sent to domi...@pich.info Dominik Pich http://www.pich.info ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXMLParser - howto resolve entities defined in DTD
On May 31, 2009, at 4:31 PM, Dominik Pich wrote: Hi, I use NSXMLParser to parse large XML files-- going good BUT :) I cant get the parser to resolve the external entities from the DTD. I googled and read documentation and older mails... and I did set parser.shouldResolveExternalEntities = YES Well, the docs state: 1) "An NSXMLParser notifies its delegate about the items (elements, attributes, CDATA blocks, comments, and so on) that it encounters as it processes an XML document. It does not itself do anything with those parsed items except report them." and 2) in setShouldResolveExternalEntities, "Indicates whether the receiver reports declarations of external entities using the delegate method parser:foundExternalEntityDeclarationWithName:publicID:systemID:." I should be clear, then, that NSXMLParser does *not* resolve external entities in any way, only reports them, and explains what you see. I do get: - (NSData *)parser:(AQXMLParser *)parser resolveExternalEntityName: (NSString *)name systemID:(NSString *)systemID but I have no idea what to return... the entities are defined in the DTD... As the docs say, "An NSData object that contains the resolution of the given external entity" if I could get the folowing for the entries in the DTD, I would just build a table myself - (void)parser:(AQXMLParser *)parser foundInternalEntityDeclarationWithName:(NSString *)name value: (NSString *)value; Still, shouldnt NSXMLParser do entity substitution for me? somehow... :) The companion document to NSXMLParser, "Event-Driven XML Programming Guide for Cocoa", tells you what you need to do to resolve external entities. Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com