[lxml-dev] No error position when validating against XMLSchema

Hello, I'm calling creating object with "etree.iterparse(open('NotValidFile.xml'), schema=schema)" and iterating over it raises etree.XMLSyntaxError, as expected. Unfortunately, value of 'position' attribute of that error is (0,0). Value of 'offset' attribute is None. Is there a way to get at least the line number of the offending tag in my XML file? When etree.XMLSyntaxError is raised in etree.XML(), it contains position info pointing precisely to the place where error occured. Is it possible also when using iterparse() ? Regards, Adam Bielański.

I would be interested in a solution to that issue, too. On Wed, Jul 7, 2010 at 16:25, Adam Bielański <ab@rdprojekt.pl> wrote:
-- Simon Hirscher http://simonhirscher.de

Hello, I'm running "for x in etree.iterparse(open('NotValidFile.xml'), schema=schema)", where 'NotValidFile.xml' is a file that won't validate against provided schema. Iterating over raises etree.XMLSyntaxError, which is expected and ok. But the value of 'position' attribute of that error is (0,0) and value of 'offset' attribute is None. Is there a way to get at least the line number in which the error occurred? Is current behaviour a bug in etree.iterparse or is it expected behaviour, that errors raised by etree.iterparse doesn't tell anything about their position in XML file? Regards, Adam Bielański.

I would be interested in a solution to that issue, too. On Wed, Jul 7, 2010 at 16:25, Adam Bielański <ab@rdprojekt.pl> wrote:
-- Simon Hirscher http://simonhirscher.de

Hello, I'm running "for x in etree.iterparse(open('NotValidFile.xml'), schema=schema)", where 'NotValidFile.xml' is a file that won't validate against provided schema. Iterating over raises etree.XMLSyntaxError, which is expected and ok. But the value of 'position' attribute of that error is (0,0) and value of 'offset' attribute is None. Is there a way to get at least the line number in which the error occurred? Is current behaviour a bug in etree.iterparse or is it expected behaviour, that errors raised by etree.iterparse doesn't tell anything about their position in XML file? Regards, Adam Bielański.
participants (2)
-
Adam Bielański
-
codethief