Closed bwetherfield closed 4 years ago
I can't quite figure out if
func parser(_: XMLParser,
didStartElement elementName: String,
namespaceURI: String?,
qualifiedName: String?,
attributes attributeDict: [String: String] = [:])
and
func parser(_: XMLParser,
didEndElement _: String,
namespaceURI _: String?,
qualifiedName _: String?)
in XMLStackParser
get called differently for these two cases in the XMLParser
implementation. If so, then maybe we could tweak the parser delegate implementation, but I'm not too sure. AFAIK, XML implementations wouldn't tend to distinguish in this way as a rule, so would this cause compatibility issues more broadly?
@bwetherfield thank you for polishing this and finding new edge cases! 🙏
Overview
Fixes #123 and extends #145 to accommodate decoding of arrays of empty strings or mixed arrays of non-empty and empty strings.
Example
We may now decode
into the following type
where
We can also decode a value of the following type
from
Further, following from #145 we can decode arrays of empty strings
as
and variants.
Source Compatibility
In cases where we decode an array of type
[String?]
, an empty element is now decoded as""
rather thannil
, the justification being thatString
can itself take empty values. We use the convention thatnil
signifies the absence of an element (if 0 or 1 of the element are allowed) as in the updated BreakfastTest and in the following error-throwing test case.