Is it possible to show line numbers over 65535 when checking an xml file using lxml?

I am trying to check an xml file with approximately 1 million lines using lxml. This is my code.

import codecs
import lxml.etree as ET

xsd_file = codecs.open(r'test.xsd', 'rb', 'utf-8')
xml_file = codecs.open(r'test.xml', 'rb', 'utf-8')

xmlschema_doc = ET.parse(xsd_file)
xmlschema = ET.XMLSchema(xmlschema_doc)

doc = ET.parse(xml_file)

print (xmlschema.error_log.filter_from_errors())

But I found that the output always says “65535: 0” if the line with the error exceeds 65535. That is

file:///C:test.xml:65535:0:ERROR:SCHEMASV:SCHEMAV_ELEMENT_CONTENT: Element 'word': Missing child element(s). 
file:///C:test.xml:65535:0:ERROR:SCHEMASV:SCHEMAV_ELEMENT_CONTENT: Element 'word': Missing child element(s).
file:///C:test.xml:65535:0:ERROR:SCHEMASV:SCHEMAV_ELEMENT_CONTENT: Element 'word': Missing child element(s).

Therefore, I cannot determine where the lines above are. Are there any solutions?

+4
source share
1 answer

It looks like a bug in libXML , not in LXML persay itself , and it has existed since 2006. It seems to be difficult to fix due to backward compatibility issues.

+1
source

All Articles