For the most part, we've been creating HTML documents from XML documents with XSLT. You might have noticed that the output documents are HTML, not XML, even though we haven't explicitly told the XSLT processor to make them HTML. That's because there is a special default rule hereif the document node of the output document is <HTML> , XSLT processors are supposed to treat the output document as HTML.
On the other hand, you can specifically specify the type of output document you want, using the XSLT <xsl:output> element. Here are the options:
To select one of these, you set the <xsl:output> element's method attribute to "xml", "html", or "text". Say that you want to create a plain text documentin that case, you can use this <xsl:output> element:
<xsl:output method = "text"/>
You can also use the media-type attribute of <xsl:output> to specify the MIME type of the output document yourself. Here's how that might look, where we're creating a rich text format (RTF) document:
Besides the method and media-type attributes, there are some other additional useful <xsl:output> attributes that let you control the output document:
That finishes our discussion of XSLT in this chapter. There's more that you can do with XSLT than we could cover in this chapter, such as sorting your output results using <xsl: sort > or creating new elements with <xsl:element> and so onif you're interested, track down a good XSLT book.