I'm using XSLT to generate XHTML-compliant code, and I'm trying to figure out a way to force it to include the close tag on an empty element.
The element in question is <textarea>. I've tried a few solutions, and am using some on other elements, but they dont work with textarea. To be clear,
- output: html won't work, because it needs to be valid XML
- Inserting dummy characters like '' inside won't work, because everything inside a <textarea> is treated like CDATA and is included in the field as editable text. Using a space or a return isn't a good solution either because then the form will submit it as part of the data (unless I hack every page on the server to remove it, which I'd rather not.)
I do have a solution, but it's extremely ugly, and won't work if I ever pass the XSLT processing onto the browser (since Firefox won't let you insert elements this way). But it works for now:
<xsl:text disable-output-escaping="yes"><![CDATA[<textarea id="input_description" name="description" cols="45" rows="5">]]></xsl:text>
<xsl:if test="description"><xsl:value-of select="description" disable-output-escaping="yes" /></xsl:if>
<xsl:text disable-output-escaping="yes"><![CDATA[</textarea>]]></xsl:text>
If I want to include generated content inside the <textarea> element, this gets very ugly very fast.
Anyone else have a solution?
Thanks!