Divs moved around after xslt transformation

Normally for xslt transformation closing tags wil collapse

<div id=”1”></div>

Will be rendered like

<div id=”1” />

This will not cause much of an issue until you have nearby empty divs like

<div id=”1”></div>
<div id=”2”></div>

After xslt transformation you will get

<div id=”1” />
<div id=”2”/>

When this has gone through html engine, it will be like

<div id=”1”><div id=”2”></div></div>

So divs are moved around and embedded.

The solution is to add following at the top of your style sheet to prevent collapsing of closing tags

<xsl:output method="html"/>


This entry was posted on Tuesday, June 28th, 2011 at 11:42 pm and is filed under General. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply