Archive for the ‘XSL’ Category
Every once in a while you will wan’t to do the something like the following an xsl stylesheet:
Unfortunately as XML is well formed and HTML isn’t the resulting HTML will be invalid e.g
The solution to this is quite simple, all you need to do is to tell the transform engine you are generating HTML using the output tag e.g.
<xsl:output method="html" />
Also note that if your target html is actually xhtml then using html as the output method will have some side effect e.g.
will be incorrectly replaced with
So what do you do if you want xhtml and empty elements which require a closing tag and not short form?
Well I’ve found two methods:-
1. Use a text node with output escaping disabled
2. Use a xsl comment
The first means you need to escape all of you < / >, which is cumbersome the second adds unneeded comments to your output, so its up to you which downside you prefer 😉