Re: [xml] XHTML DTD changes behaviour for empty tags



On 29/05/2008, Matthias Pigulla <mp webfactory de> wrote:
Dear all,

 could anybody please give me a hint why xmllint'ing the following two
 files makes a difference regarding the handling of the empty <test> tag?
 It's printed as "<test></test>" if the DTD is present.

This is the XHTML1 specific compatibility serialisation rules, you can
disable with any of the xmlSave* functions that take xmlSaveOption and
XML_SAVE_NO_XHTML:
<http://www.w3.org/TR/xhtml1/#C_3>
<http://xmlsoft.org/html/libxml-xmlsave.html#xmlSaveOption>
Don't think there's an equivalent xmllint switch, but (for reasons
below), you probably want the --dropdtd switch anyway.

 I already played around with xmlSaveNoEmptyTags in my code to get around
 that but that seems not to make a difference. libxml2 is 2.6.32.

 Thanks!
 Matthias

Note though, "<elem/>", "<elem />", and "<elem></elem>" are the same
from the perspective of an XML parser (they would result in identical
trees).
Also, if you're embedding foreign grammars in XHTML (as the 'test'
element is here - it's not in the DTD as an empty element, so is
expanded to open-and-close form), you should namespace them, and can't
validate against the default DTDs.

Martin



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