Section 18.3.  Using HTML with XSLT

Prev don't be afraid of buying books Next

18.3. Using HTML with XSLT

Many XSLT implementations allow transformations from XML into HTML. This is good for serving to today's mainstream browsers (6.x and up) and the legacy (3.x-5.x) browsers that most websites must still support.

It also takes advantage of many Web designers' knowledge of HTML. If you format a document using element types from HTML, the page will look to a browser as if it had been created in HTML directly. You can think of this process as a conversion from XML markup to HTML markup. It is a useful way to publish XML documents to the Web.

Because basic HTML is widely understood, we will use HTML element types in most of our examples. We will restrict our usage to only a few HTML types, namely:

  • h1 and h2 element types for top-level and second-level headings;

  • p element type for paragraphs;

  • body element type to contain the document's content; and the

  • em element type to emphasize a series of characters.

A stylesheet that generates HTML elements might have a root element that looks like Example 18-2.

Example 18-2. XSLT stylesheet using HTML elements
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                 version="1.0"> <xsl:output method="html"/>     <!-- template rules go here --> </xsl:stylesheet> 

Amazon


XML in Office 2003. Information Sharing with Desktop XML
XML in Office 2003: Information Sharing with Desktop XML
ISBN: 013142193X
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net