Radek Pazdera, 22.08.2013 11:14:
I'm using lxml to resolve XIncludes in a document. This works very well, however, I need to know the file each element originates from for error reporting.
If I understand that correclty, the location should be stored in the 'base' and 'sourceline' variables for each element. Unfortunately, I can't seem to get the right file name from there.
What am I getting is the same base for all the included files files. The line numbers are correct though. Am I doing something wrong or could that be a bug?
The problem here is that the original document is lost after the XInclude run (from the POV of the merged tree), and it's the document that knows the original source base of the element. I.e., there is only one base URL for the whole document. The fact that it's the Element object that provides the "base" property can be considered a design quirk in that regard. In any case, I wouldn't know any way to recover the information where a specific included element originally came from after the XInclude run. Stefan