Skip to content

Retire XML DOM Management: ES SII and XML VAT Declaration (native XML) - #12641

Draft
Darrick (darjoo) wants to merge 1 commit into
mainfrom
darjoo-xml-dom-es-sii
Draft

Darrick (darjoo) wants to merge 1 commit into
mainfrom
darjoo-xml-dom-es-sii

Conversation

@darjoo

@darjoo Darrick (darjoo) commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What & why

This is part of retiring BaseApp codeunit 6224 XML DOM Management (Remove/Reduce dotnet). It covers the ES SII area and the ES XML VAT Declaration report. These now build XML with native AL XmlDocument / XmlElement / XmlNode / XmlAttribute instead of cu 6224 and DotNet System.Xml. Other areas are handled in separate PRs, and a final PR obsoletes the codeunit. Follows the pattern of #10755, #12254, #12324 and #12606. Tag is 30.0 / CLEAN30, which matches BaseApp app.json 30.0.0.0 and #12606.

In scope

  • SII XML Creator (cu 10750)
    • About 185 AddElementWithPrefix and 35 FindNode('..') calls now go through two small local native helpers.
    • The Envelope root (declaration plus xmlns:sii, xmlns:siiLR, xmlns:soapenv) is read from text. That keeps the declaration (no standalone="") and the namespace-declaration order the DotNet writer produced. Child elements are created in the namespace and take their prefix from the root, so element names, order and number/date formatting are unchanged.
    • New GenerateXml(...; var XMLDocOut: XmlDocument; ...) overload. The OnPrem DotNet overload is kept under #if not CLEAN30 and marked obsolete. It wraps the native one and loads the result into the DotNet document.
    • The 12 integration events whose signatures had DotNet XmlNode get native replacements with a V2 suffix, for example OnBeforeContraparteNodeV2. The old events are kept under #if not CLEAN30 and marked obsolete. They are no longer raised. The document is now native, so there is no live DotNet node to pass, and a copied node would silently drop subscriber changes. The obsolete reason says this.
    • OnAfterFillDetalleIVANode and OnAfterInitializePurchXmlBody pass the node's inner XML as text and are unchanged. The text has the same form as DotNet InnerXml. When a subscriber changes it, the text is parsed back and redundant root namespace declarations are dropped, as DotNet did.
    • OnBeforeGenerateXmlDocument and OnAfterGenerateXmlDocument keep their copy semantics.
  • SII Session (table 10753): XMLTextIndent uses a native XmlDocument. Whitespace-only text nodes are removed first so the indented output matches DotNet Load + Save.
  • XML VAT Declaration (report 10718): the file is built with native types and the root element is written without a declaration. The old code never appended its processing instruction, so there was no declaration before either. New native AppendVATStatementLine overload; the DotNet one is obsolete under CLEAN30.

Outside the listed scope, needed because the Clean build removes the DotNet GenerateXml (agreed with the coordinating session; no other session touches these files)

  • SII Doc. Upload Management: TryGenerateXml calls the native overload and loads the result into the existing DotNet XmlDocument that the HTTP code still uses. Nothing else in that file changes.
  • ES SII tests (25 codeunits) and Library - SII: XMLDoc variables and library parameters are now native XmlDocument. Library helpers use XPath with a namespace manager in place of GetElementsByTagName. Two tests asserted the DotNet "variable not instantiated" error text to prove sii:CodigoPais is absent; they now call ValidateNoElementsByName.

Linked work

Fixes AB#649587
Part of AB#647963

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome

  • Compiled locally with alc.exe from artifact bcinsider/Sandbox/30.0.55871.0, with CodeCop, UICop and src/rulesets/base.ruleset.json, on the composed ES view (New-GDLView -CountryCode ES):

    • ES Base Application, normal and CLEAN25..CLEAN30: passed. The only remaining reference to "XML DOM Management" in this area is gone.
    • ES Application, Application Test Library, Tests-TestLibraries and Tests-Local, normal and Clean: passed.
    • Analyzer warnings for every changed file compared with the same build of main: no new warnings in either mode.
  • Output equivalence was checked in PowerShell 7 against System.Xml and System.Xml.Linq (the types behind AL native XML):

    • Envelope namespace order (sii, siiLR, soapenv) matches DotNet.
    • Empty elements serialize as <x /> and escaping matches.
    • The per-child inner XML text matches DotNet InnerXml, including xmlns: on top-level children.
    • Indented XML VAT Declaration output with no declaration and no BOM matches DotNet Save(file).
  • Pending (not run yet):

    • ES SII test codeunits (147521-147564, 147594-147595, 148000) and Test VAT Statement (147590) in an ES BC container.
    • Byte-equality harness. It runs the old DotNet SII XML Creator beside the native one on every SII test scenario, compares OuterXml and the text passed to the inner-XML events, and compares the XML VAT Declaration file output byte-for-byte.

    Both are built. They're waiting for a free container slot because the previous slot needs a manual repair. This PR stays in draft until they pass.

Risk & compatibility

  • Behavior change for subscribers: the 12 obsolete DotNet XmlNode events are no longer raised. Subscribers must move to the ...V2 events, which have the same parameters with a native XmlNode. This is called out in each obsolete reason.
  • The obsolete DotNet GenerateXml and AppendVATStatementLine overloads still work and are removed with CLEAN30.
  • Library - SII public verification procedures now take a native XmlDocument. The only callers are the ES SII tests updated here.
  • No schema or data upgrade impact.

Build the SII XML (SII XML Creator), format SII Session request/response XML,
and generate the XML VAT Declaration file with native AL XML types instead of
codeunit 6224 "XML DOM Management" and DotNet System.Xml.

- SII XML Creator: native XmlDocument/XmlElement/XmlNode. The Envelope is read
  from text so the declaration and namespace declaration order match the old
  DotNet output; child elements resolve sii/siiLR/soapenv prefixes from it.
  New GenerateXml overload with XmlDocument; DotNet overload obsoleted
  (CLEAN30). 12 integration events with DotNet XmlNode parameters get native
  *V2 replacements; the old events are obsoleted and no longer raised.
  InnerXml text events keep DotNet-compatible text.
- SII Doc. Upload Management: uses the native GenerateXml overload and converts
  to its existing DotNet XmlDocument (no other change).
- SII Session: XMLTextIndent uses native XmlDocument.
- XML VAT Declaration: native XmlDocument; DotNet AppendVATStatementLine
  overload obsoleted (CLEAN30).
- ES SII tests and Library - SII moved to native XmlDocument.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Team: Finance GitHub request for Finance area label Oct 9, 2026
@github-actions github-actions Bot added this to the Version 30.0 milestone Oct 9, 2026

This branch was successfully deployed

1 active deployment
triage — d1a2267e Deployed Oct 9, 2026 by darjoo via Classify team ownership #7369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team: Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant