XML parse with XMLSchema doesn't give an error's position

Bug #1599292 reported by Symon
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
lxml
New
Undecided
Unassigned

Bug Description

Python : sys.version_info(major=2, minor=7, micro=10, releaselevel='final', serial=0)
lxml.etree : (3, 6, 0, 0)
libxml used : (2, 9, 0)
libxml compiled : (2, 9, 0)
libxslt used : (1, 1, 28)
libxslt compiled : (1, 1, 28)

Try this code with valid 1.xsd and invalid 1.xml:

    from lxml.etree import XMLParser, XMLSchema, parse, XMLSyntaxError
    parser = XMLParser(schema=XMLSchema(file='1.xsd'))
    try:
        xml = parse(open('1.xml', mode='rb'), parser)
    except XMLSyntaxError as e:
        for error in parser.error_log:
            print error.message, error.line, error.column

error.line and error.column are always 0.

Here is the link to stackoverflow: http://stackoverflow.com/questions/38209943/lxml-xml-validation-with-xmlschema-doesnt-give-errors-position

Revision history for this message
David Losacker (david-losacker) wrote :

Dear all,

we encountered the same problem using the following versions:

Python==3.8.4
lxml==4.5.2

as well as on

Python==3.8.0
lxml==4.4.2

Is there any update/feedback concerning this bug?
Thanks for investigating!

Revision history for this message
Mark Grandi (markgrandi) wrote :

same here:

the error_log in the XMLSyntaxError raised by the validation failing are all 0s. I thought it was because i was reading it as a string via `etree.fromstring()` but it still does it with `etree.parse`

<string>:0:0:ERROR:SCHEMASV:SCHEMAV_CVC_COMPLEX_TYPE_3_2_1: Element '{http://schemas.microsoft.com/2011/01/fabric}Parameter', attribute 'DefaultValue': The attribute 'DefaultValue' is not allowed.
<string>:0:0:ERROR:SCHEMASV:SCHEMAV_CVC_COMPLEX_TYPE_4: Element '{http://schemas.microsoft.com/2011/01/fabric}Parameter': The attribute 'Value' is required but missing.
<string>:0:0:ERROR:SCHEMASV:SCHEMAV_CVC_COMPLEX_TYPE_3_2_1: Element '{http://schemas.microsoft.com/2011/01/fabric}Parameter', attribute 'name': The attribute 'name' is not allowed.
<string>:0:0:ERROR:SCHEMASV:SCHEMAV_CVC_COMPLEX_TYPE_4: Element '{http://schemas.microsoft.com/2011/01/fabric}Parameter': The attribute 'Name' is required but missing.
<string>:0:0:ERROR:SCHEMASV:SCHEMAV_CVC_COMPLEX_TYPE_3_2_1: Element '{http://schemas.microsoft.com/2011/01/fabric}Parameter', attribute 'name': The attribute 'name' is not allowed.
<string>:0:0:ERROR:SCHEMASV:SCHEMAV_CVC_COMPLEX_TYPE_4: Element '{http://schemas.microsoft.com/2011/01/fabric}Parameter': The attribute 'Name' is required but missing.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.