On Fri, Apr 21, 2017 at 9:10 AM, Stefan Behnel <stefan_ml@behnel.de> wrote:
Thanks for bringing up this topic and looking into it. I can see that this would be a nice feature.
Thanks very much for your very thorough reply.
Would it help you to get an XPath expression targeting the node in error?
That would be a perfect solution.
I can see two drawbacks of that proposal: it takes a bit of time to calculate that expression (even though we could store the UTF-8 C string in the end and postpone the conversion to a Python object), and it might not always be clear which tree to apply it to, e.g. in the case of XInclude failures or other cases where multiple trees are involved (schema imports?). But both could be considered acceptable.
I agree that postponing conversion (as you have done for a couple of the other properties) would be helpful. There might even be a way to let lxml know globally whether to collect this information at all (though I'll leave it to you to decide whether that optimization is worth the extra clutter). I'm not sure I understand the second issue. Isn't libxml2 sort of making that decision for us, but giving us the xmlNode pointer, which we'd be passing to their xmlGetNodePath function?
What do you think about that approach?
Ausgezeichnet! Wish I'd thought of it myself. :-) Let me see what I can come up with. Cheers, Bob