Skip to content

feature_request(validator): don’t exit after the first error #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Kristinita opened this issue Mar 6, 2025 · 1 comment
Open

Comments

@Kristinita
Copy link

Kristinita commented Mar 6, 2025

1. Summary

It would be nice if fast-xml-parser will not exit after the first detected error.

2. Justification

It’s standard default behavior for checkers/linters/validators. I use near 30 checkers/linters/validators, and they all not to exit after the first error.

Users may want to see all errors at once without the need to re-run the validator after correcting a single error.

3. MCVE

3.1. Files

KiraXMLFirst.xml:

<?xml version="1.0" encoding="UTF-8"?>
<kira>
	<first>Goddess!</firs>
	<second>Ideal!</secon>
	<third>Greatest!</thir>
</kira>

KiraXMLSecond.xml:

<?xml version="1.0" encoding="UTF-8"?>
<kira>
	<fourth>Amazing!</fourt>
	<fifth>Unbelievable!</fift>
	<sixth>Genius!</sixt>
</kira>

3.2. Command

Unfortunately, fast-xml-parser hasn’t supported glob patterns to run validator recursively for multiple files, so I use fd:

# [NOTE] Running commands from npm packages on Windows:
# https://github.com/sharkdp/fd/issues/1474
fd --print0 --extension xml | xargs --null fxparser -V

3.3. Behavior

3.3.1. Desired — xmllint

xmllint exits after validating all files and prints all 6 errors:

D:\SashaDebugging\KiraFastXMLParser>fd --print0 --extension xml | xargs --null xmllint --noout --pedantic
./KiraXMLFirst.xml:3: parser error : Opening and ending tag mismatch: first line 3 and firs
        <first>Goddess!</firs>
                              ^
./KiraXMLFirst.xml:4: parser error : Opening and ending tag mismatch: second line 4 and secon
        <second>Ideal!</secon>
                              ^
./KiraXMLFirst.xml:5: parser error : Opening and ending tag mismatch: third line 5 and thir
        <third>Greatest!</thir>
                               ^
./KiraXMLSecond.xml:3: parser error : Opening and ending tag mismatch: fourth line 3 and fourt
        <fourth>Amazing!</fourt>
                                ^
./KiraXMLSecond.xml:4: parser error : Opening and ending tag mismatch: fifth line 4 and fift
        <fifth>Unbelievable!</fift>
                                   ^
./KiraXMLSecond.xml:5: parser error : Opening and ending tag mismatch: sixth line 5 and sixt
        <sixth>Genius!</sixt>
                             ^
3.3.2. Non-desired — fast-xml-parser

fast-xml-parser exits after the first detected error:

D:\SashaDebugging\KiraFastXMLParser>fd --print0 --extension xml | xargs --null fxparser -V
{
  err: {
    code: 'InvalidTag',
    msg: "Expected closing tag 'fourth' (opened in line 3, col 2) instead of closing tag 'fourt'.",
    line: 3,
    col: 18
  }
}

Thanks.

Copy link

github-actions bot commented Mar 6, 2025

We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants