NSXMLParser always passes empty element model strings to NSXMLParserDelegate parser:foundElementDeclarationWithName:model: (OSX)

Originator:iosdeveloperzone
Number:rdar://22358759 Date Originated:20-Aug-2015 02:41 AM
Status:Open Resolved:
Product:OS X Product Version:Mac OS X 10.10.4 (14E46)
Classification:Serious Bug Reproducible:Always
 
This is the OS X version of rdar://22358749

Summary:
When NSXMLParser encounters an element declaration it calls parser:foundElementDeclarationWithName:model:.
The final parameter is supposed to carry the element model information, however it is always an empty string.

For example, the follow XML file:

<?xml version="1.0" standalone="yes" ?>" 
<!DOCTYPE blog [
      <!ELEMENT title (#PCDATA)>
      <!ELEMENT body (#PCDATA)>
      <!ELEMENT post (title, body)>
]>
<blog>
</blog>

when parsed with NSXMLParser results in the following delegate calls (ellipses mark where parameters have been deleted for clarity): 
-[… parserDidStartDocument:…]
-[… foundElementDeclarationWithName:@"title" model:@""]
-[… foundElementDeclarationWithName:@"body" model:@""]
-[… foundElementDeclarationWithName:@"post" model:@""]
-[… didStartElement:@"blog" namespaceURI:nil qualifiedName:nil attributes:{
}]
-[… didEndElement:@"blog" namespaceURI:nil qualifiedName:nil]
-[… parserDidEndDocument:<NSXMLParser: 0x7f82e2844f50>]

Steps to Reproduce:
Run the above XML or a similar file through NSXMLParser and log the delegate calls.

Alternatively, run the test testElementDeclarationModel in the attached Xcode workspace and note the contents of the log and that the test fails. 

Expected Results:
The model string should contain the model information.

Revisiting the example above and ignoring irrelevant calls, it would be reasonable to assume the following calls to the delegate:
…
-[… foundElementDeclarationWithName:@"title" model:@"(#PCDATA)"]
-[…  foundElementDeclarationWithName:@"body" model:@"(#PCDATA)"]
-[… foundElementDeclarationWithName:@"post" model:@"(title, body)"]
…

Actual Results:
See summary above.

Regression:
I could not find a version of NSXMLParser that behaved correctly.
Both libxml2 and expat handle this correctly.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!