Skip to content

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

@Kristinita

Description

@Kristinita

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions