|
Description:
New XSLT users often have problems creating empty elements like <link>, <br>, <hr> and so forth in XSLT stylesheets. This recipe shows how.
Source: Text Source
<xsl:template match="/">
<html>
<title>Demonstrate line breaking</title>
<p>This is a paragraph with a line break,<br/> in it.</p>
Horizontal rule:<hr/>
</html>
</xsl:template>
The license for this recipe is available here.
Discussion:
The "secret" is that you have to use XML syntax in the XSLT stylesheet even though the final output will be in HTML syntax. The XSLT stylesheet must be a well-formed document! But your XSLT implementation should do the "right thing" when it sees that the top-most element is an HTML element.
|