Due to either the dependent libxml2 version being a bit outdated with current, or some other extent behavior, XXMLNode.Options.documentXInclude results in neither an error, nor a transformation of XML content.
import Foundation
#if canImport(FoundationXML)
import FoundationXML
#endif
let mainXML = """
<?xml version="1.0" encoding="utf-8"?>
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="example.xml">
<xi:fallback>
<xi:include href="fallback.xml">
<xi:fallback><error message="UH OH" /></xi:fallback>
</xi:include>
</xi:fallback>
</xi:include>
</root>
""".data(using: .utf8)!
do {
let doc = try XMLDocument(
data: mainXML, options: [.documentTidyXML, .nodePreserveAll, .documentXInclude])
print(doc)
} catch {
print("Error parsing XML: \(error)")
}
The provided code sample should, at the very least, result in the xi:include element being replaced with at least the outer xi:fallback. Alternatively, an error should occur. Instead this fails silently and no transformations take place.
Due to either the dependent libxml2 version being a bit outdated with current, or some other extent behavior,
XXMLNode.Options.documentXIncluderesults in neither an error, nor a transformation of XML content.The provided code sample should, at the very least, result in the
xi:includeelement being replaced with at least the outerxi:fallback. Alternatively, an error should occur. Instead this fails silently and no transformations take place.