[lxml-dev] Details of XML Validation errors with lxml
Hi, Eric Garin wrote:
I've found some informations here http://codespeak.net/lxml/dev/api.html#error-handling-on-exceptions
and most likely also http://codespeak.net/lxml/dev/validation.html
Where Can I found the documentation API for error_log ?
The section in api.html which you mentioned above is already the main source. You might also try 'help(etree)', which will tell you what fields there are in the error log entries, or read the source code, class _LogEntry in http://codespeak.net/svn/lxml/trunk/src/lxml/xmlerror.pxi
I've found a bit by chance how to render the line number error but I would like for example to be abble to give to the users the offset (or position in line) where the error occur.
Sadly, this information is not provided by libxml2, so lxml can't provide it either. Note also that the document might be constructed by hand (don't know your application), in which case a line number would be meaningless already. This is obviously a problem in 1-line XML documents, but a work around could be to pretty print the document, parse it back in and then run the validation a second time. This will give you a meaningful line number that you can then use to provide the user with more context such as the surrounding tags. Stefan
Stefan Behnel wrote:
Eric Garin wrote:
I've found a bit by chance how to render the line number error but I would like for example to be abble to give to the users the offset (or position in line) where the error occur.
Sadly, this information is not provided by libxml2
Sorry, looks like I was mistaken here. This information *is* provided by libxml2 in some contexts, so I'll try to make it available at the lxml API level. Please check the SVN trunk (becoming lxml 1.3) to see how things advance. Stefan
participants (2)
-
Eric Garin
-
Stefan Behnel