[lxml-dev] Question about newlines
Stefan Behnel
stefan_ml at behnel.de
Sun Dec 9 08:48:17 CET 2007
Hi,
Noah Slater wrote:
> When serialising a document there are two places that I would expect
> lxml to insert newlines and yet there are non.
Serialisation will never alter content.
That said, there is a separate serialisation API in libxml2 (the xmlSave*
functions) that inserts a newline at the end, maybe also after PIs (don't
know). But it will not be used in lxml for a while due to API stability issues.
> 1) When adding a PI via the element.addprevious method and PI has
> it's tail trimmed and so when serialising the PI runs into the
> root element.
>
> 2) At the very end of the document. POSIX states that all files must
> end in a newline so I consider this to be a bug.
XML works on more systems than those that support POSIX. :)
One reason these don't happen automatically is that ET doesn't insert newlines
either. This is not a hard reason, and maybe we could even change this in 2.0.
I'll think about it. Any other opinions on this?
Stefan
More information about the lxml-dev
mailing list