XSLT - Output (Html, )

Card Puncher Data Processing


In the XSL - Stylesheet


<xsl:output method="html"/>




For method

  • the default value is xml
  • the others values can be either text or html (to produce HTML-compatible output)


When you specify XML output, you can add the indent attribute to produce nicely indented XML output.

<xsl:output method="xml" indent="yes"/>

Even if that option were available for HTML output, it would not help, because HTML elements are rarely nested.



Because an XSL stylesheet is well-formed XML to start with, you cannot easily put a tag such as

in the middle of it. The <xsl:output method=“html”/> tag solves the problem so that you can code in the stylesheet but get in the output.

That HTML output specification converts empty tags such as to their HTML form,

, on output. That conversion is important, because most browsers do not recognize the empty tags. Here is a list of the affected tags:
area      frame   isindex
base      hr      link
basefont  img     meta
br        input   param

If you actually want < to be generated as part of the HTML output, you will need to encode it as &lt;. That sequence becomes < on output, because only the & is converted to an & character.


With the specification <xsl:output method=“text”/>, generated text is not escaped. For example, if the stylesheet includes the < entity reference, it will appear as the < character in the generated text. When XML is generated, on the other hand, the < entity reference in the stylesheet would be unchanged, so it would appear as < in the generated text.

Share this page:
Follow us:
Task Runner