Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent XslCompiledTransform from using self-closing tags

I am using XslCompiledTransform to convert an XML file to HTML. Is there a way I can prevent it from using self-closing tags.

e.g.

<span></span> <!-- I want this even if content empty -->
<span/> <!-- stop doing this! ->

The self-closing tags on span's are messing up my document no matter which browser I use, though it is valid XML, it's just that 'span' is not allowed to have self-closing tags.

Is there a setting I can put in my xsl, or in my C#.Net code to prevent self-closing tags from being used?

like image 208
Sheamus Avatar asked Aug 22 '11 21:08

Sheamus


1 Answers

Though I couldn't classify this as a direct solution (as it doesn't emit an empty element), the workaround I used was to put a space (using xsl:text) in the element -- since this is HTML markup, and if you are activating Standards mode (not quirks), the extra space doesn't change the rendered content. I also didn't have control over the invocation of the transform object.

<div class="clearBoth"><xsl:text> </xsl:text></div>
like image 123
mlhDev Avatar answered Nov 13 '22 23:11

mlhDev