Re: [xsl] XSL transformation removing closing tag for empty div

Subject: Re: [xsl] XSL transformation removing closing tag for empty div
From: Abel Braaksma <>
Date: Sun, 03 Jun 2007 15:19:20 +0200
Michael Kay wrote:
Presumably if the recipient can't handle an empty element tag that means
it's expecting HTML rather than XML, so use <xsl:output method="html">.

The OP is using an AJAX call. AJAX usually means that XMLHttpRequest is used to receive XML from a server. It is possible to use the text content of the response, in which case HTML would suffice. But if the OP uses the returned XML as DOM object, the DOM object will be empty or null when the the output method on the server is set to HTML.

And if the OP is indeed using the DOM, (s)he can use the DOM to manipulate the result. I use AJAX daily and never have any problem with minimized tags, because I use the DOM directly and add the DOM to the HTML DOM of the page (in which case it doesn't matter at all how the element would be serialized).

I am guessing here: if the OP is using, for some reason, the serialized version of the response object of XMLHttpRequest, and tries to insert that with innerHTML for example, it might give well-known rendering problems to have certain tags in minimized form. A workaround is to add some content into the DIV, since the content is going to be replaced anyway. I.e.:

<div><!-- some comment node --></div>

-- Abel Braaksma

Current Thread