Skip to content

.documentXInclude does nothing #5430

Description

@bruxisma

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions