NSXMLParser not getting all DTD information
NSXMLParser not getting all DTD information
- Subject: NSXMLParser not getting all DTD information
- From: Roland King <email@hidden>
- Date: Sun, 11 Nov 2012 16:52:15 +0800
I have an NSXMLParser with a delegate which is just currently printing stuff out. I have an embedded DTD at the top of the xml I'm feeding it. Here are two of the implemented delegate methods
-(void)parser:(NSXMLParser *)parser foundAttributeDeclarationWithName:(NSString *)attributeName forElement:(NSString *)elementName type:(NSString *)type defaultValue:(NSString *)defaultValue
{
NSLog( @"Parser found attribute declaration for %@ for element %@ type '%@' defaultValue %@", attributeName, elementName, type, defaultValue );
}
-(void)parser:(NSXMLParser *)parser foundElementDeclarationWithName:(NSString *)elementName model:(NSString *)model
{
NSLog( @"Parser found element declaration for %@ model '%@'", elementName, model );
}
however I'm always getting an empty string for type in the first of those two logs .. and an empty string for model in the second. Here's the top of the XML going in
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE defined_objects [
<!ELEMENT defined_objects (defined_object)+ >
<!ELEMENT defined_object (segment_list)+ >
<!ELEMENT segment_list (basic_segment|parallel_segment)+ >
... more elements ...
<!ATTLIST defined_object
name ID #REQUIRED
>
... more attributes ...
Here's what I get in the log, and the parse is successful.
2012-11-11 16:27:54.179 [3351:c07] Parser started document
2012-11-11 16:27:54.180 [3351:c07] Parser found element declaration for defined_objects model ''
2012-11-11 16:27:54.181 [3351:c07] Parser found element declaration for defined_object model ''
2012-11-11 16:27:54.181 [3351:c07] Parser found element declaration for segment_list model ''
...
2012-11-11 16:27:54.187 [3351:c07] Parser found attribute declaration for name for element defined_object type '' defaultValue (null)
I expected that the model string would return "(defined_object)+" and type would return "ID" in the case of the name attribute. I've implemented every delegate method, including the text and whitespace ones, those strings don't turn up anywhere. It's definitely being parsed in some way as, if I put a syntax error into one of those ELEMENT models, like an extra paren, I get a parse error. I've messed about a bit adding extra parens and putting the pluses inside the parens etc but .. no dice.
Is my XML wrong, especially the headers which XML always seems a bit finicky about, is there a parser option needs setting, an obvious stupid mistake or is my understanding of what NSXML parser does flawed or is it broken (this on iOS 6.0 by the way)?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden