[xml] xmlSaveNoEmptyTags in XHTML documents



Hello all,

I would like to use libxml2 to process an xhtml1-strict document that needs to contain <esi:include ... /> 
tags in the minimized and empty form. Please see http://www.w3.org/TR/esi-lang for details on ESI.

My problem is that libxml2 saves these tags as <esi:include ...></esi:include> which is a problem for 
downstream processors (ESI does not assume the content is XML at all and so the exact representation of the 
tag matters).

Having read xmlsave.c I understand that libxml2 detects XHTML and ends up in xhtmlNodeDumpOutput. 
Subsequently, it will call xhtmlIsEmpty to decide whether tags should be outputted in the "compressed" form; 
that check knows about the EMPTY tags in XHTML and adherese to http://www.w3.org/TR/xhtml1/#C_3 (a feature).

The xmlSaveNoEmptyTags flag is not taken into account when processing XHTML, it is checked only in 
xmlNodeDumpOutputInternal.

Now what I would like to suggest is to change the check in xhtmlIsEmpty (around 
http://git.gnome.org/browse/libxml2/tree/xmlsave.c#n1179) so that in the case of elements that are *not* from 
the XHTML namespace tag compression would follow xmlSaveNoEmpty tags. To avoid passing the ctxt into that 
function this check could also be somewhere around line 1525 
(http://git.gnome.org/browse/libxml2/tree/xmlsave.c#n1525).

What do you think about that and would you accept that as a patch? Shall I open a bug report for it?

Kind regards
Matthias



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]