>> English << | Français | Deutsch | Magyar | 中文 | Polski ZVON > Tutorials > XSLT Tutorial
>> Page 58 << | Prev | Next | Contents | Element Index

The xsl:output element allows stylesheet authors to specify how they wish the result tree to be output. If an XSLT processor outputs the result tree, it should do so as specified by the xsl:output element; however, it is not required to do so. The xsl:output element is only allowed as a top-level element. XSLT stylesheet 1 outputs as html and XSLT stylesheet 2 as xml. Compare how empty tags are outputed.

XSLT stylesheet 1

XML Source
<source>

<hr/>
<hr/>
<hr/>

</source>

Output
<source>
  
  <hr>
  
  <hr>
  
  <hr>
  
</source>

HTML view
XSLT stylesheet
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output method="html"/>
<xsl:template match="/">
     <xsl:copy-of select="/source"/>
</xsl:template>


</xsl:stylesheet>


XSLT stylesheet 2

XML Source
<source>

<hr/>
<hr/>
<hr/>

</source>

Output
<source>
<hr/>
<hr/>
<hr/>
</source>

HTML view
XSLT stylesheet
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output method="xml"/>
<xsl:template match="/">
     <xsl:copy-of select="/source"/>
</xsl:template>


</xsl:stylesheet>