Skip to content
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

Add line numbers to xml validation error messages #91

Closed
csc-jm-zz opened this issue Jul 16, 2020 · 1 comment · Fixed by #630
Closed

Add line numbers to xml validation error messages #91

csc-jm-zz opened this issue Jul 16, 2020 · 1 comment · Fixed by #630
Assignees
Labels
enhancement New feature or request

Comments

@csc-jm-zz
Copy link

Proposed solution

Currently XMLSchemaValidationError exceptions raised by xmlschema library do not include specific line numbers of the error occurrence in the XML file. Including the line number in the error reason could be useful information for users and ParseError exceptions already include the position in the detail.reason that gets returned upon validation error.

@otahontas mentioned in #88 that one way to do this would be:

import lxml.etree as etree
root = etree.parse("XPTO.XML").getroot()
errors = [e for e in schema.iter_errors(root)]

DoD (Definition of Done)

detail.reason generated in xml validation method includes line number for any error case.

As an example, validating SRP000539_invalid6.xml could return:
Unexpected child with tag 'BAD_ELEMENT' at position 2, line 34.

Testing

Unit tests

@csc-jm-zz csc-jm-zz added the enhancement New feature or request label Jul 16, 2020
@blankdots
Copy link
Contributor

might be fixed with: sissaschool/xmlschema#164

@blankdots blankdots linked a pull request Nov 2, 2022 that will close this issue
3 tasks
@csc-jm csc-jm closed this as completed Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants