Re: [xsl] Rescuing XSLT from Niche Status

Subject: Re: [xsl] Rescuing XSLT from Niche Status
From: "Steve Muench" <Steve.Muench@xxxxxxxxxx>
Date: Fri, 16 Feb 2001 13:19:08 -0800
| 
| http://www.xfront.com/rescuing-xslt.html
|

Roger, David,

One of the features that the XSLT 1.0 spec provides
to cater to the first-time-HTML-savvy user, is the
verbosely-named "literal-result element as stylesheet"
capability. Stylesheets that use this capability
are often called "single-root-template" stylesheets
or stylesheets written in the "simple form".

Use of this could further improve on David's smooth-slope
introduction to XSLT for first-time users. It's a technique
that I use for simple HTML and XML transformations in my
"Building Oracle XML Applications" book.

That is, instead of writing:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">
  <xsl:template match="/">
    <HTML>
      <HEAD>
        <TITLE>Welcome</TITLE>
      </HEAD>
      <BODY>
        <FONT bgcolor="{member/favoriteColor}">
          Welcome <xsl:value-of select="member/name"/>!
        </FONT>
        <TABLE>
          <TR><TH>Type</TH><TH>Number</TH></TR>
          <xsl:for-each select="member/phone">
            <TR>
              <TD><xsl:value-of select="@type"/></TD>
              <TD><xsl:value-of select="."/></TD>
            </TR>
          </xsl:for-each>
        </TABLE>
      </BODY>
  </HTML>
</xsl:template>
</xsl:stylesheet>

You can write:

<HTML xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <HEAD>
    <TITLE>Welcome</TITLE>
  </HEAD>
  <BODY>
    <FONT bgcolor="{member/favoriteColor}">
      Welcome <xsl:value-of select="member/name"/>!
    </FONT>
    <TABLE>
      <TR><TH>Type</TH><TH>Number</TH></TR>
      <xsl:for-each select="member/phone">
        <TR>
          <TD><xsl:value-of select="@type"/></TD>
          <TD><xsl:value-of select="."/></TD>
        </TR>
      </xsl:for-each>
    </TABLE>
  </BODY>
</HTML>

And you can teach people that the steps to
get started are to:

  (1) Get an HTML template from your web design folks
  (2) Use Dave Raggett's "tidy" with the "-asxml" option
      to convert the HTML to well-formed HTML
  (3) Add an "xsl:version" to the <HTML> root element
  (4) Begin "peppering" in <xsl:value-of>, attribute value
      templates, and <xsl:for-each>'s to suit.

______________________________________________________________
Steve Muench, Lead XML Evangelist & Consulting Product Manager
BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG
Author "Building Oracle XML Applications", O'Reilly
http://www.oreilly.com/catalog/orxmlapp/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread