Skip to content

feat: implement XML parsing utilities and diagnostics for improved error handling - #1882

Open
CaiJimmy wants to merge 3 commits into
masterfrom
jimmy/better-xml-error
Open

CaiJimmy wants to merge 3 commits into
masterfrom
jimmy/better-xml-error

Conversation

@CaiJimmy

@CaiJimmy CaiJimmy commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

XML inputs are now parsed through one helper, XmlParsingUtils, so every entry point reports parse errors the same way:

Unable to parse <input> at line L, column C: <parser reason>

Previously each of fn:doc, fn:doc-available, fn:parse-xml, fn:parse-xml-fragment, jn:xml-files and serialization parameter documents created its own parser, and only fn:doc reported the position and reason.

Behavior changes

  • jn:xml-files raises FODC0002 naming the file and position, instead of a generic RuntimeException whose message contained the whole file. It also keeps the file's line breaks, so reported lines are correct.
  • fn:parse-xml and fn:parse-xml-fragment include the parser's reason and the position in the input (FODC0006, unchanged). Fragment positions are relative to the argument, not the internal wrapper element.
  • Serialization parameter documents report the file and position.
  • fn:doc-available and the parse functions no longer print parser errors to stderr.

Error metadata still points to the call in the query; the position inside the XML is part of the message. Apart from jn:xml-files, error codes are unchanged.

@CaiJimmy
CaiJimmy force-pushed the jimmy/better-xml-error branch from 1be5bb2 to 2f8467d Compare October 4, 2026 22:25
@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

QT3 Test Results - Parser: jsoniq

Regression baseline: run 37794943109

🎉 No regressions found for this build.

Summary of passed tests for jsoniq
Test Suite Passing Failing Errors Skipped Missing features Total
app 2037 27 88 5 5 2157
array 208 0 1 0 0 209
fn 10308 270 170 387 315 11135
map 220 0 0 0 0 220
math 149 0 0 0 0 149
misc 764 34 21 52 18 871
op 4339 4 23 0 0 4366
prod 11469 343 187 208 7 12207
ser 332 11 0 0 0 343
xs 155 0 0 9 0 164
Total 29981 689 490 661 345 31821

Full analysis report: see analysis-jsoniq in artifacts.

Download detailed test results

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

QT3 Test Results - Parser: xquery

Regression baseline: run 37794943109

🎉 No regressions found for this build.

Summary of passed tests for xquery
Test Suite Passing Failing Errors Skipped Missing features Total
app 2044 26 82 5 5 2157
array 209 0 0 0 0 209
fn 10330 249 169 387 315 11135
map 220 0 0 0 0 220
math 149 0 0 0 0 149
misc 768 30 21 52 18 871
op 4339 4 23 0 0 4366
prod 11550 295 154 208 7 12207
ser 343 0 0 0 0 343
xs 155 0 0 9 0 164
Total 30107 604 449 661 345 31821

Full analysis report: see analysis-xquery in artifacts.

Download detailed test results

@CaiJimmy
CaiJimmy force-pushed the jimmy/fix-element-type branch from 1edd792 to dfb2ff8 Compare October 6, 2026 21:21
@CaiJimmy
CaiJimmy force-pushed the jimmy/better-xml-error branch from 2f8467d to ad50c0c Compare October 6, 2026 21:22
@CaiJimmy
CaiJimmy force-pushed the jimmy/fix-element-type branch from dfb2ff8 to 28c5994 Compare October 6, 2026 23:39
@CaiJimmy
CaiJimmy force-pushed the jimmy/better-xml-error branch from ad50c0c to 00addb9 Compare October 6, 2026 23:39
Callers pass a description of the input, and every parse error reads
"Unable to parse <input> at line L, column C: <reason>". Fragment errors in the
synthetic closing tag are reported at the end of the input instead of at a
recomputed position. Keep one test per diagnostic behavior.
@CaiJimmy
CaiJimmy force-pushed the jimmy/better-xml-error branch from b886320 to c00d8a2 Compare October 8, 2026 20:29
@CaiJimmy
CaiJimmy changed the base branch from jimmy/fix-element-type to master October 8, 2026 20:29
@CaiJimmy
CaiJimmy marked this pull request as ready for review October 8, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant