spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / authoring / languages / xml / insidexslt / chap2 / 5 To page 1current pageTo page 3To page 4
[previous] [next]

Inside XSLT

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Output Method: HTML

The planets.xsl stylesheet we've been working with doesn't use the <xsl:output> element; it turns out that I've been relying on the default output rules with that stylesheet. By default, the output type is XML, unless the XSLT processor sees an <HTML> or <html> tag. (Note that this is not a formal requirement, just a convention, so you can't expect all XSLT processors to honor it.) I've used the <HTML> tag in planets.xsl like this:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/PLANETS">
    <HTML>
      <HEAD>
        <TITLE>
          The Planets Table
        </TITLE>
      </HEAD>
    .
    .
    .

However, if you remove this tag:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/PLANETS">

      <HEAD>
        <TITLE>
          The Planets Table
        </TITLE>
      </HEAD>
    .
    .
    .

Then this is the kind of output you'll get from James Clark's XT. Note the XML processing instruction at the beginning:

<?xml version="1.0" encoding="utf-8"?>
  <HEAD>
    <TITLE>
      The Planets Table
    </TITLE>
  </HEAD>
  .
  .
  .

On the other hand, you can explicitly specify the output type as HTML with the <xsl:output> element, even without using the <HTML> element:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>

  <xsl:template match="/PLANETS">
    <HEAD>
      <TITLE>
        The Planets Table
      </TITLE>
    </HEAD>
    .
    .
    .

Here's the output from XT in this case-just an HTML fragment, no XML processing instruction:

<HEAD>
  <TITLE>
    The Planets Table
  </TITLE>
</HEAD>
    .
    .
    .

Automatic <meta> Elements Added to HTML
If you do use the <xml:output method="html"/> element explicitly, some XSLT processors, such as Saxon, add a <meta> element to the output document's <head> element something like this:
<meta http-equiv= "Content-Type" content="text/html; charset=utf-8">.

In general, XSLT processors are supposed to realize that certain elements, such as <br>, <img>, <frame>, and so on are empty in HTML. Also, spaces and other characters in URI attribute values are converted as specified in the HTML specification (a space becomes "%20" and so on), processing instructions are terminated with > rather than ?>, and the fact that standalone attributes are not assigned a value is recognized.


home / authoring / languages / xml / insidexslt / chap2 / 5 To page 1current pageTo page 3To page 4
[previous] [next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

Created: October 11, 2001
Revised: October 11, 2001


URL: http://webreference.com/authoring/languages/xml/insidexslt/chap2/5/2.html